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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/lib/commonjs/components/CollapsibleContainer.js +4 -2
  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} +5 -5
  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 +73 -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} +6 -6
  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/index.js +21 -12
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/{types.js → types.d.js} +1 -1
  30. package/lib/commonjs/{types.js.map → types.d.js.map} +0 -0
  31. package/lib/commonjs/{hooks/withCollapsibleContext.js → withCollapsibleContext.js} +8 -4
  32. package/lib/commonjs/{hooks/withCollapsibleContext.js.map → withCollapsibleContext.js.map} +1 -1
  33. package/lib/module/components/CollapsibleContainer.js +1 -1
  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} +2 -2
  38. package/lib/module/components/{CollapsibleHeaderContainer.js.map → header/CollapsibleHeaderContainer.js.map} +1 -1
  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 +55 -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} +27 -27
  52. package/lib/module/components/scrollable/CollapsibleFlatList.js.map +1 -0
  53. package/lib/module/components/{CollapsibleScrollView.js → scrollable/CollapsibleScrollView.js} +5 -5
  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/index.js +6 -5
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/types.d.js +2 -0
  62. package/lib/module/{types.js.map → types.d.js.map} +0 -0
  63. package/lib/module/{hooks/withCollapsibleContext.js → withCollapsibleContext.js} +5 -4
  64. package/lib/module/withCollapsibleContext.js.map +1 -0
  65. package/lib/typescript/components/{AnimatedTopView.d.ts → header/AnimatedTopView.d.ts} +0 -0
  66. package/lib/typescript/components/{CollapsibleHeaderContainer.d.ts → header/CollapsibleHeaderContainer.d.ts} +0 -0
  67. package/lib/typescript/components/{StickyView.d.ts → header/StickyView.d.ts} +0 -0
  68. package/lib/typescript/components/pullToRefresh/PullToRefreshContainer.d.ts +8 -0
  69. package/lib/typescript/components/pullToRefresh/PullToRefreshProvider.d.ts +6 -0
  70. package/lib/typescript/components/pullToRefresh/RefreshControl.d.ts +9 -0
  71. package/lib/typescript/components/pullToRefresh/usePullToRefreshContext.d.ts +4 -0
  72. package/lib/typescript/components/pullToRefresh/utils.d.ts +20 -0
  73. package/lib/typescript/components/{CollapsibleFlatList.d.ts → scrollable/CollapsibleFlatList.d.ts} +1 -1
  74. package/lib/typescript/components/{CollapsibleScrollView.d.ts → scrollable/CollapsibleScrollView.d.ts} +1 -1
  75. package/lib/typescript/{hooks → components/scrollable}/useAnimatedScroll.d.ts +0 -0
  76. package/lib/typescript/hooks/useInternalCollapsibleContext.d.ts +1 -1
  77. package/lib/typescript/index.d.ts +6 -5
  78. package/lib/typescript/{hooks/withCollapsibleContext.d.ts → withCollapsibleContext.d.ts} +0 -0
  79. package/package.json +4 -2
  80. package/src/components/CollapsibleContainer.tsx +1 -1
  81. package/src/components/{AnimatedTopView.tsx → header/AnimatedTopView.tsx} +0 -0
  82. package/src/components/{CollapsibleHeaderContainer.tsx → header/CollapsibleHeaderContainer.tsx} +3 -3
  83. package/src/components/{StickyView.tsx → header/StickyView.tsx} +2 -2
  84. package/src/components/pullToRefresh/PullToRefreshContainer.tsx +65 -0
  85. package/src/components/pullToRefresh/PullToRefreshProvider.tsx +27 -0
  86. package/src/components/pullToRefresh/RefreshControl.tsx +80 -0
  87. package/src/components/pullToRefresh/usePullToRefreshContext.ts +13 -0
  88. package/src/components/pullToRefresh/utils.ts +49 -0
  89. package/src/components/{CollapsibleFlatList.tsx → scrollable/CollapsibleFlatList.tsx} +34 -28
  90. package/src/components/{CollapsibleScrollView.tsx → scrollable/CollapsibleScrollView.tsx} +6 -6
  91. package/src/{hooks → components/scrollable}/useAnimatedScroll.ts +2 -2
  92. package/src/hooks/useInternalCollapsibleContext.ts +1 -1
  93. package/src/index.tsx +6 -5
  94. package/src/{types.ts → types.d.ts} +7 -0
  95. package/src/{hooks/withCollapsibleContext.tsx → withCollapsibleContext.tsx} +8 -5
  96. package/lib/commonjs/components/CollapsibleFlatList.js.map +0 -1
  97. package/lib/commonjs/components/CollapsibleHeaderContainer.js.map +0 -1
  98. package/lib/commonjs/components/CollapsibleScrollView.js.map +0 -1
  99. package/lib/commonjs/components/StickyView.js.map +0 -1
  100. package/lib/module/components/CollapsibleFlatList.js.map +0 -1
  101. package/lib/module/components/CollapsibleScrollView.js.map +0 -1
  102. package/lib/module/components/StickyView.js.map +0 -1
  103. package/lib/module/hooks/withCollapsibleContext.js.map +0 -1
  104. package/lib/module/types.js +0 -2
  105. package/lib/typescript/types.d.ts +0 -34
@@ -0,0 +1,80 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import React, { useCallback, useEffect } from 'react';
3
+ import { StyleSheet } from 'react-native';
4
+ import Animated, {
5
+ runOnJS,
6
+ useAnimatedProps,
7
+ useAnimatedReaction,
8
+ useAnimatedStyle,
9
+ withTiming,
10
+ } from 'react-native-reanimated';
11
+ import usePullToRefreshContext from './usePullToRefreshContext';
12
+
13
+ type Props = {
14
+ height?: number;
15
+ refreshing: boolean;
16
+ onRefresh: () => void;
17
+ renderAnimation: (animatedProps: any) => React.ReactNode;
18
+ };
19
+
20
+ export default function RefreshControl({
21
+ height = 100,
22
+ refreshing,
23
+ onRefresh,
24
+ renderAnimation,
25
+ }: Props) {
26
+ const { refreshValue, internalRefreshing, internalHeight } =
27
+ usePullToRefreshContext();
28
+
29
+ useEffect(() => {
30
+ internalHeight.value = height;
31
+ }, [height]);
32
+
33
+ useEffect(() => {
34
+ internalRefreshing.value = refreshing;
35
+ }, [refreshing]);
36
+
37
+ const animatedStyle = useAnimatedStyle(() => {
38
+ return {
39
+ height: refreshValue.value,
40
+ };
41
+ }, []);
42
+
43
+ const handleRefresh = useCallback(() => {
44
+ console.log('refresh');
45
+ onRefresh();
46
+ }, [onRefresh]);
47
+
48
+ useAnimatedReaction(
49
+ () => internalRefreshing.value,
50
+ (result, prev) => {
51
+ if (result !== prev) {
52
+ if (result) {
53
+ runOnJS(handleRefresh)();
54
+ } else {
55
+ refreshValue.value = withTiming(0);
56
+ }
57
+ }
58
+ }
59
+ );
60
+
61
+ const animatedProps = useAnimatedProps(() => {
62
+ return {
63
+ progress: internalRefreshing.value
64
+ ? undefined
65
+ : Math.min(refreshValue.value / height, 1),
66
+ };
67
+ }, [height]);
68
+
69
+ return (
70
+ <Animated.View style={[styles.container, animatedStyle]}>
71
+ {renderAnimation(animatedProps)}
72
+ </Animated.View>
73
+ );
74
+ }
75
+
76
+ const styles = StyleSheet.create({
77
+ container: {
78
+ overflow: 'hidden',
79
+ },
80
+ });
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { PullToRefreshContextType } from '../../types';
3
+
4
+ // @ts-ignore
5
+ export const PullToRefreshContext = createContext<PullToRefreshContextType>({});
6
+
7
+ export default function usePullToRefreshContext() {
8
+ const ctx = useContext(PullToRefreshContext);
9
+ if (!ctx) {
10
+ throw new Error('Component should be wrapped with withCollapsibleContext');
11
+ }
12
+ return ctx;
13
+ }
@@ -0,0 +1,49 @@
1
+ export const springConfig = (velocity: number) => {
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
+
15
+ export function clamp(value: number, lowerbound: number, upperbound: number) {
16
+ 'worklet';
17
+
18
+ return Math.min(Math.max(value, lowerbound), upperbound);
19
+ }
20
+
21
+ /**
22
+ * calculates rubber value
23
+ *
24
+ * @param x distance from the edge
25
+ * @param dim dimension, either width or height
26
+ * @param coeff constant value, UIScrollView uses 0.55
27
+ * @returns rubber = (1.0 – (1.0 / ((x * coeff / dim) + 1.0))) * dim
28
+ */
29
+ export const rubberBandClamp = (x: number, dim: number, coeff: number) => {
30
+ 'worklet';
31
+
32
+ return (1.0 - 1.0 / ((x * coeff) / dim + 1.0)) * dim;
33
+ };
34
+
35
+ export const rubberClamp = (
36
+ y: number,
37
+ topBound: number,
38
+ bottomBound: number,
39
+ coeff = 0.55
40
+ ) => {
41
+ 'worklet';
42
+
43
+ const clampedY = clamp(y, topBound, bottomBound);
44
+ const diff = Math.abs(y - clampedY);
45
+ const sign = clampedY > y ? -1 : 1;
46
+ const dimension = bottomBound - topBound;
47
+
48
+ return clampedY + sign * rubberBandClamp(diff, dimension, coeff);
49
+ };
@@ -5,16 +5,17 @@ import React, {
5
5
  useRef,
6
6
  useState,
7
7
  } from 'react';
8
- import { FlatListProps, FlatList, View, StyleSheet } from 'react-native';
8
+ import { FlatListProps, View, StyleSheet, FlatList } from 'react-native';
9
9
  import Animated, {
10
10
  runOnJS,
11
11
  useAnimatedReaction,
12
12
  } from 'react-native-reanimated';
13
- import AnimatedTopView from './AnimatedTopView';
14
- import useAnimatedScroll from '../hooks/useAnimatedScroll';
15
- import useCollapsibleContext from '../hooks/useCollapsibleContext';
16
- import type { CollapsibleProps } from '../types';
17
- import { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';
13
+ import AnimatedTopView from '../header/AnimatedTopView';
14
+ import useAnimatedScroll from './useAnimatedScroll';
15
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
16
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
17
+ import type { CollapsibleProps } from '../../types';
18
+ import PullToRefreshContainer from '../pullToRefresh/PullToRefreshContainer';
18
19
 
19
20
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
20
21
 
@@ -25,9 +26,9 @@ export default function CollapsibleFlatList<Data>({
25
26
  headerSnappable = true,
26
27
  ...props
27
28
  }: Props<Data>) {
28
- const scrollView = useRef<FlatList>(null);
29
- const { headerHeight } = useCollapsibleContext();
29
+ const { headerHeight, scrollY } = useCollapsibleContext();
30
30
  const { contentMinHeight } = useInternalCollapsibleContext();
31
+ const scrollRef = useRef<any>(null);
31
32
  const mounted = useRef(true);
32
33
  const contentHeight = useRef(0);
33
34
 
@@ -37,12 +38,15 @@ export default function CollapsibleFlatList<Data>({
37
38
  };
38
39
  }, []);
39
40
 
40
- const scrollTo = useCallback((yValue: number, animated = true) => {
41
- scrollView.current?.scrollToOffset({
42
- offset: yValue,
43
- animated,
44
- });
45
- }, []);
41
+ const scrollTo = useCallback(
42
+ (yValue: number, animated = true) => {
43
+ scrollRef.current?.scrollToOffset({
44
+ offset: yValue,
45
+ animated,
46
+ });
47
+ },
48
+ [scrollRef]
49
+ );
46
50
 
47
51
  const handleInternalContentHeight = useCallback((value: number) => {
48
52
  if (mounted.current) {
@@ -96,20 +100,22 @@ export default function CollapsibleFlatList<Data>({
96
100
  );
97
101
 
98
102
  return (
99
- // @ts-ignore
100
- <AnimatedFlatList
101
- ref={scrollView}
102
- bounces={false}
103
- keyboardDismissMode="on-drag"
104
- keyboardShouldPersistTaps="handled"
105
- scrollEventThrottle={16}
106
- {...props}
107
- style={[styles.container, props.style]}
108
- contentContainerStyle={contentContainerStyle}
109
- onScroll={scrollHandler}
110
- ListHeaderComponent={renderListHeader()}
111
- onContentSizeChange={handleContentSizeChange}
112
- />
103
+ <PullToRefreshContainer scrollY={scrollY}>
104
+ {/* @ts-ignore */}
105
+ <AnimatedFlatList
106
+ ref={scrollRef}
107
+ bounces={false}
108
+ keyboardDismissMode="on-drag"
109
+ keyboardShouldPersistTaps="handled"
110
+ scrollEventThrottle={1}
111
+ {...props}
112
+ style={[styles.container, props.style]}
113
+ contentContainerStyle={contentContainerStyle}
114
+ onScroll={scrollHandler}
115
+ ListHeaderComponent={renderListHeader()}
116
+ onContentSizeChange={handleContentSizeChange}
117
+ />
118
+ </PullToRefreshContainer>
113
119
  );
114
120
  }
115
121
 
@@ -1,11 +1,11 @@
1
- import AnimatedTopView from './AnimatedTopView';
2
- import useAnimatedScroll from '../hooks/useAnimatedScroll';
1
+ import AnimatedTopView from '../header/AnimatedTopView';
2
+ import useAnimatedScroll from './useAnimatedScroll';
3
3
  import React, { ReactNode, useCallback, useMemo, useRef } from 'react';
4
4
  import { ScrollViewProps, StyleSheet } from 'react-native';
5
5
  import Animated, { useAnimatedStyle } from 'react-native-reanimated';
6
- import type { CollapsibleProps } from '../types';
7
- import useCollapsibleContext from '../hooks/useCollapsibleContext';
8
- import { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';
6
+ import type { CollapsibleProps } from '../../types';
7
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
8
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
9
9
 
10
10
  type Props = ScrollViewProps &
11
11
  CollapsibleProps & {
@@ -52,7 +52,7 @@ export default function CollapsibleScrollView({
52
52
  onScroll={scrollHandler}
53
53
  keyboardDismissMode="on-drag"
54
54
  keyboardShouldPersistTaps="handled"
55
- scrollEventThrottle={16}
55
+ scrollEventThrottle={1}
56
56
  >
57
57
  <Animated.View style={animatedStyle}>
58
58
  <AnimatedTopView height={headerHeight} />
@@ -6,8 +6,8 @@ import {
6
6
  useAnimatedScrollHandler,
7
7
  useSharedValue,
8
8
  } from 'react-native-reanimated';
9
- import useCollapsibleContext from './useCollapsibleContext';
10
- import { useInternalCollapsibleContext } from './useInternalCollapsibleContext';
9
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
10
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
11
11
 
12
12
  const { height: wHeight } = Dimensions.get('window');
13
13
 
@@ -5,7 +5,7 @@ export const InternalCollapsibleContext =
5
5
  // @ts-ignore
6
6
  createContext<CollapsibleContextInternalType>();
7
7
 
8
- export function useInternalCollapsibleContext() {
8
+ export default function useInternalCollapsibleContext() {
9
9
  const ctx = useContext(InternalCollapsibleContext);
10
10
  if (!ctx) {
11
11
  throw new Error('Component should be wrapped with withCollapsibleContext');
package/src/index.tsx CHANGED
@@ -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
 
4
4
  export { default as CollapsibleContainer } from './components/CollapsibleContainer';
5
- export { default as CollapsibleFlatList } from './components/CollapsibleFlatList';
6
- export { default as CollapsibleScrollView } from './components/CollapsibleScrollView';
7
- export { default as CollapsibleHeaderContainer } from './components/CollapsibleHeaderContainer';
5
+ export { default as CollapsibleFlatList } from './components/scrollable/CollapsibleFlatList';
6
+ export { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';
7
+ export { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';
8
+ export { default as StickyView } from './components/header/StickyView';
9
+ export { default as RefreshControl } from './components/pullToRefresh/RefreshControl';
8
10
  export { default as CollapsibleView } from './components/CollapsibleView';
9
- export { default as StickyView } from './components/StickyView';
10
11
  export * from './components/CollapsibleView';
@@ -1,3 +1,4 @@
1
+ import type { RefObject } from 'react';
1
2
  import type React from 'react';
2
3
  import type { View } from 'react-native';
3
4
  import type Animated from 'react-native-reanimated';
@@ -40,3 +41,9 @@ export type CollapsibleContextInternalType = {
40
41
  export type CollapsibleProps = {
41
42
  headerSnappable?: boolean;
42
43
  };
44
+
45
+ export type PullToRefreshContextType = {
46
+ refreshValue: Animated.SharedValue<number>;
47
+ internalRefreshing: Animated.SharedValue<boolean>;
48
+ internalHeight: Animated.SharedValue<number>;
49
+ };
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable no-shadow */
2
2
  /* eslint-disable react-hooks/exhaustive-deps */
3
3
  import React, { FC, useCallback, useMemo, useRef } from 'react';
4
- import type { CollapsibleHandles, LayoutParams } from '../types';
5
- import { CollapsibleContext } from './useCollapsibleContext';
6
- import { InternalCollapsibleContext } from './useInternalCollapsibleContext';
4
+ import type { CollapsibleHandles, LayoutParams } from './types';
5
+ import { CollapsibleContext } from './hooks/useCollapsibleContext';
6
+ import { InternalCollapsibleContext } from './hooks/useInternalCollapsibleContext';
7
7
  import {
8
8
  useAnimatedReaction,
9
9
  useDerivedValue,
@@ -11,7 +11,8 @@ import {
11
11
  withTiming,
12
12
  } from 'react-native-reanimated';
13
13
  import type { View } from 'react-native';
14
- import { debounce } from '../utils/debounce';
14
+ import { debounce } from './utils/debounce';
15
+ import PullToRefreshProvider from './components/pullToRefresh/PullToRefreshProvider';
15
16
 
16
17
  export default function withCollapsibleContext<T>(Component: FC<T>) {
17
18
  return (props: T) => {
@@ -190,7 +191,9 @@ export default function withCollapsibleContext<T>(Component: FC<T>) {
190
191
  return (
191
192
  <CollapsibleContext.Provider value={context}>
192
193
  <InternalCollapsibleContext.Provider value={internalContext}>
193
- <Component {...props} />
194
+ <PullToRefreshProvider>
195
+ <Component {...props} />
196
+ </PullToRefreshProvider>
194
197
  </InternalCollapsibleContext.Provider>
195
198
  </CollapsibleContext.Provider>
196
199
  );
@@ -1 +0,0 @@
1
- {"version":3,"sources":["CollapsibleFlatList.tsx"],"names":["AnimatedFlatList","Animated","createAnimatedComponent","FlatList","CollapsibleFlatList","headerSnappable","props","scrollView","headerHeight","contentMinHeight","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","StyleSheet","create","absoluteFillObject","flexGrow","topView","position","top","left","right"],"mappings":";;;;;;;AAAA;;AAOA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,MAAMA,gBAAgB,GAAGC,+BAASC,uBAAT,CAAiCC,qBAAjC,CAAzB;;AAKe,SAASC,mBAAT,CAAmC;AAChDC,EAAAA,eAAe,GAAG,IAD8B;AAEhD,KAAGC;AAF6C,CAAnC,EAGC;AACd,QAAMC,UAAU,GAAG,mBAAiB,IAAjB,CAAnB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qCAAzB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,mEAA7B;AACA,QAAMC,OAAO,GAAG,mBAAO,IAAP,CAAhB;AACA,QAAMC,aAAa,GAAG,mBAAO,CAAP,CAAtB;AAEA,wBAAU,MAAM;AACd,WAAO,MAAM;AACXD,MAAAA,OAAO,CAACE,OAAR,GAAkB,KAAlB;AACD,KAFD;AAGD,GAJD,EAIG,EAJH;AAMA,QAAMC,QAAQ,GAAG,wBAAY,CAACC,MAAD,EAAiBC,QAAQ,GAAG,IAA5B,KAAqC;AAAA;;AAChE,2BAAAR,UAAU,CAACK,OAAX,4EAAoBI,cA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iB,IAAA,MAAM,EAAExB;AAAzB,IADF,EAEGF,KAAK,CAAC2B,mBAFT,CADF;;AAOA;AAAA;AACE;AACA,iCAAC,gBAAD;AACE,MAAA,GAAG,EAAE1B,UADP;AAEE,MAAA,OAAO,EAAE,KAFX;AAGE,MAAA,mBAAmB,EAAC,SAHtB;AAIE,MAAA,yBAAyB,EAAC,SAJ5B;AAKE,MAAA,mBAAmB,EAAE;AALvB,OAMMD,KANN;AAOE,MAAA,KAAK,EAAE,CAACoB,MAAM,CAACQ,SAAR,EAAmB5B,KAAK,CAAC6B,KAAzB,CAPT;AAQE,MAAA,qBAAqB,EAAEV,qBARzB;AASE,MAAA,QAAQ,EAAEJ,aATZ;AAUE,MAAA,mBAAmB,EAAEW,gBAAgB,EAVvC;AAWE,MAAA,mBAAmB,EAAEH;AAXvB;AAFF;AAgBD;;AAED,MAAMH,MAAM,GAAGU,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE,EACT,GAAGE,wBAAWE;AADL,GADoB;AAI/BX,EAAAA,gBAAgB,EAAE;AAChBY,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":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FlatListProps, FlatList, View, StyleSheet } from 'react-native';\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n} from 'react-native-reanimated';\nimport AnimatedTopView from './AnimatedTopView';\nimport useAnimatedScroll from '../hooks/useAnimatedScroll';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\nimport type { CollapsibleProps } from '../types';\nimport { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';\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 scrollView = useRef<FlatList>(null);\n const { headerHeight } = useCollapsibleContext();\n const { contentMinHeight } = 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 scrollView.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 // @ts-ignore\n <AnimatedFlatList\n ref={scrollView}\n bounces={false}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={16}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n ListHeaderComponent={renderListHeader()}\n onContentSizeChange={handleContentSizeChange}\n />\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 +0,0 @@
1
- {"version":3,"sources":["CollapsibleHeaderContainer.tsx"],"names":["key","CollapsibleHeaderContainer","children","containerStyle","contentKey","scrollY","handleHeaderContainerLayout","headerHeight","undefined","handleHeaderLayout","nativeEvent","layout","height","value","duration","headerTranslate","Animated","Extrapolate","CLAMP","headerStyle","transform","translateY","minHeight","internalStyle","zIndex","styles","container","StyleSheet","create","backgroundColor","marginTop","Platform","OS"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AAQA;;AAOA;;;;;;;;AAlBA;AAyBA,IAAIA,GAAG,GAAG,CAAV;;AAEe,SAASC,0BAAT,CAAoC;AACjDC,EAAAA,QADiD;AAEjDC,EAAAA;AAFiD,CAApC,EAGL;AACR,QAAMC,UAAU,GAAG,oBAAQ,MAAO,sBAAqBJ,GAAG,EAAG,EAA1C,EAA6C,EAA7C,CAAnB;AACA,QAAM;AAAEK,IAAAA;AAAF,MAAc,qCAApB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkC,mEAAxC;AACA,QAAMC,YAAY,GAAG,2CAAe,CAAf,CAArB;AAEA,wBAAU,MAAM;AACd,WAAO,MAAMD,2BAA2B,CAACF,UAAD,EAAaI,SAAb,CAAxC;AACD,GAFD,EAEG,EAFH;AAIA,QAAMC,kBAAkB,GAAG,wBACzB,CAAC;AACCC,IAAAA,WAAW,EAAE;AACXC,MAAAA,MAAM,EAAE;AAAEC,QAAAA;AAAF;AADG;AADd,GAAD,KAIyB;AACvBL,IAAAA,YAAY,CAACM,KAAb,GAAqB,uCAAWD,MAAX,EAAmB;AACtCE,MAAAA,QAAQ,EAAE;AAD4B,KAAnB,CAArB;AAGAR,IAAAA,2BAA2B,CAACF,UAAD,EAAaQ,MAAb,CAA3B;AACD,GAVwB,E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/* eslint-disable react-hooks/exhaustive-deps */\nimport { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';\nimport React, { ReactNode, useCallback, useEffect, useMemo } from 'react';\nimport {\n LayoutChangeEvent,\n Platform,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native';\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\n\ntype Props = {\n children: ReactNode;\n containerStyle?: StyleProp<ViewStyle>;\n};\n\nlet key = 0;\n\nexport default function CollapsibleHeaderContainer({\n children,\n containerStyle,\n}: Props) {\n const contentKey = useMemo(() => `collapsible-header-${key++}`, []);\n const { scrollY } = useCollapsibleContext();\n const { handleHeaderContainerLayout } = useInternalCollapsibleContext();\n const headerHeight = useSharedValue(0);\n\n useEffect(() => {\n return () => handleHeaderContainerLayout(contentKey, undefined);\n }, []);\n\n const handleHeaderLayout = useCallback(\n ({\n nativeEvent: {\n layout: { height },\n },\n }: LayoutChangeEvent) => {\n headerHeight.value = withTiming(height, {\n duration: 200,\n });\n handleHeaderContainerLayout(contentKey, height);\n },\n [contentKey, handleHeaderContainerLayout]\n );\n\n const headerTranslate = useDerivedValue(\n () =>\n interpolate(\n scrollY.value,\n // FIXME: can improve by geting maxY value of header and sticky views\n [-250, 0, 100000],\n [250, 0, -100000],\n Animated.Extrapolate.CLAMP\n ),\n []\n );\n\n const headerStyle = useAnimatedStyle(() => {\n return {\n transform: [{ translateY: headerTranslate.value }],\n minHeight: headerHeight.value,\n };\n }, [headerHeight, headerTranslate]);\n\n const internalStyle = useMemo(() => {\n return {\n zIndex: 100000 - key,\n };\n }, []);\n\n return (\n <Animated.View\n style={[headerStyle, internalStyle]}\n pointerEvents=\"box-none\"\n >\n <View\n key={contentKey}\n onLayout={handleHeaderLayout}\n pointerEvents=\"box-none\"\n style={[styles.container, containerStyle]}\n >\n {children}\n </View>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: 'white',\n marginTop: Platform.OS === 'android' ? -1 : 0\n },\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["CollapsibleScrollView.tsx"],"names":["CollapsibleScrollView","headerSnappable","children","props","scrollView","contentMinHeight","headerHeight","scrollTo","yValue","animated","current","y","scrollHandler","animatedStyle","minHeight","value","contentContainerStyle","styles","contentContainer","container","style","StyleSheet","create","absoluteFillObject","flexGrow","topView","position","top","left","right"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAOe,SAASA,qBAAT,CAA+B;AAC5CC,EAAAA,eAAe,GAAG,IAD0B;AAE5CC,EAAAA,QAF4C;AAG5C,KAAGC;AAHyC,CAA/B,EAIL;AACR,QAAMC,UAAU,GAAG,mBAA4B,IAA5B,CAAnB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,mEAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qCAAzB;AAEA,QAAMC,QAAQ,GAAG,wBAAY,CAACC,MAAD,EAAiBC,QAAQ,GAAG,IAA5B,KAAqC;AAAA;;AAChE;AACA,2BAAAL,UAAU,CAACM,OAAX,4EAAoBH,QAApB,CAA6B;AAAEI,MAAAA,CAAC,EAAEH,MAAL;AAAaC,MAAAA;AAAb,KAA7B;AACD,GAHgB,EAGd,EAHc,CAAjB;AAKA,QAAM;AAAEG,IAAAA;AAAF,MAAoB,gCAAkB;AAC1CX,IAAAA,eAD0C;AAE1CM,IAAAA;AAF0C,GAAlB,CAA1B;AAKA,QAAMM,aAAa,GAAG,6CAAiB,MAAM;AAC3C,WAAO;AACLC,MAAAA,SAAS,EAAET,gBAAgB,CAACU;AADvB,KAAP;AAGD,GAJqB,EAInB,EAJmB,CAAtB;AAMA,QAAMC,qBAAqB,GAAG,oBAC5B,MAAM,CAACC,MAAM,CAACC,gBAAR,EAA0Bf,KAAK,CAACa,qBAAhC,CADsB,EAE5B,CAACb,KAAK,CAACa,qBAAP,CAF4B,CAA9B;AAKA,sBACE,6BAAC,8BAAD,CAAU,UAAV;AACE,IAAA,GAAG,EAAEZ,UADP;AAEE,IAAA,OAAO,EAAE;AAFX,KAGMD,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,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEC;AAAtB,kBACE,6BAAC,wBAAD;AAAiB,IAAA,MAAM,EAAEP;AAAzB,IADF,EAEGJ,QAFH,CAXF,CADF;AAkBD;;AAED,MAAMe,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE,EACT,GAAGE,wBAAWE;AADL,GADoB;AAI/BL,EAAAA,gBAAgB,EAAE;AAChBM,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":["import AnimatedTopView from './AnimatedTopView';\nimport useAnimatedScroll from '../hooks/useAnimatedScroll';\nimport React, { ReactNode, useCallback, useMemo, useRef } 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 scrollView = useRef<Animated.ScrollView>(null);\n const { contentMinHeight } = useInternalCollapsibleContext();\n const { headerHeight } = useCollapsibleContext();\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n // @ts-ignore\n scrollView.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={scrollView}\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={16}\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["StickyView.tsx"],"names":["stickyKey","StickyView","children","style","key","viewRef","handleStickyViewLayout","stickyViewTops","stickyViewPositions","scrollY","undefined","handleLayout","translateY","top","value","layoutValues","inputMid","Extrapolate","CLAMP","animatedStyle","transform","styles","container","StyleSheet","create","backgroundColor","zIndex"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AALA;AAiBA,IAAIA,SAAS,GAAG,CAAhB;;AAEe,SAASC,UAAT,CAAoB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;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BAAD,CAAU,IAAV;AACE,IAAA,GAAG,EAAEV,GADP,CAEE;AAFF;AAGE,IAAA,GAAG,EAAEC,OAHP;AAIE,IAAA,QAAQ,EAAEM,YAJZ;AAKE,IAAA,KAAK,EAAE,CAACU,MAAM,CAACC,SAAR,EAAmBH,aAAnB,EAAkChB,KAAlC,CALT;AAME,IAAA,aAAa,EAAC;AANhB,KAQGD,QARH,CADF;AAYD;;AAED,MAAMmB,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,eAAe,EAAE,OADR;AAETC,IAAAA,MAAM,EAAE;AAFC;AADoB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\nimport Animated, {\n Extrapolate,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n} from 'react-native-reanimated';\n\ntype Props = {\n style?: StyleProp<ViewStyle>;\n children: Element;\n};\n\nlet stickyKey = 0;\n\nexport default function StickyView({ children, style }: Props) {\n const key = useMemo(() => `sticky_${stickyKey++}`, []);\n const viewRef = useRef<View>(null);\n const { handleStickyViewLayout, stickyViewTops, stickyViewPositions } =\n useInternalCollapsibleContext();\n const { scrollY } = useCollapsibleContext();\n\n useEffect(() => {\n return () => handleStickyViewLayout(key, undefined);\n }, []);\n\n const handleLayout = useCallback(() => {\n handleStickyViewLayout(key, viewRef);\n }, [handleStickyViewLayout, key]);\n\n const translateY = useDerivedValue(() => {\n const top = stickyViewTops.value[key] || 0;\n const layoutValues = stickyViewPositions.value[key] || { top: 0 };\n const inputMid = layoutValues.top - top;\n return interpolate(\n scrollY.value,\n [0, inputMid, inputMid + 100000],\n [0, 0, 100000],\n Extrapolate.CLAMP\n );\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [\n {\n translateY: translateY.value,\n },\n ],\n };\n }, []);\n\n return (\n <Animated.View\n key={key}\n // @ts-ignore\n ref={viewRef}\n onLayout={handleLayout}\n style={[styles.container, animatedStyle, style]}\n pointerEvents=\"box-none\"\n >\n {children}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: 'white',\n zIndex: 10,\n },\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["CollapsibleFlatList.tsx"],"names":["React","useCallback","useEffect","useMemo","useRef","useState","FlatList","View","StyleSheet","Animated","runOnJS","useAnimatedReaction","AnimatedTopView","useAnimatedScroll","useCollapsibleContext","useInternalCollapsibleContext","AnimatedFlatList","createAnimatedComponent","CollapsibleFlatList","headerSnappable","props","scrollView","headerHeight","contentMinHeight","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,OAAOA,KAAP,IACEC,WADF,EAEEC,SAFF,EAGEC,OAHF,EAIEC,MAJF,EAKEC,QALF,QAMO,OANP;AAOA,SAAwBC,QAAxB,EAAkCC,IAAlC,EAAwCC,UAAxC,QAA0D,cAA1D;AACA,OAAOC,QAAP,IACEC,OADF,EAEEC,mBAFF,QAGO,yBAHP;AAIA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,4BAA9B;AACA,OAAOC,qBAAP,MAAkC,gCAAlC;AAEA,SAASC,6BAAT,QAA8C,wCAA9C;AAEA,MAAMC,gBAAgB,GAAGP,QAAQ,CAACQ,uBAAT,CAAiCX,QAAjC,CAAzB;AAKA,eAAe,SAASY,mBAAT,CAAmC;AAChDC,EAAAA,eAAe,GAAG,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,UAAU,CAAC0C,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE,EACT,GAAGxC,UAAU,CAAC2C;AADL,GADoB;AAI/BV,EAAAA,gBAAgB,EAAE;AAChBW,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":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FlatListProps, FlatList, View, StyleSheet } from 'react-native';\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n} from 'react-native-reanimated';\nimport AnimatedTopView from './AnimatedTopView';\nimport useAnimatedScroll from '../hooks/useAnimatedScroll';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\nimport type { CollapsibleProps } from '../types';\nimport { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';\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 scrollView = useRef<FlatList>(null);\n const { headerHeight } = useCollapsibleContext();\n const { contentMinHeight } = 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 scrollView.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 // @ts-ignore\n <AnimatedFlatList\n ref={scrollView}\n bounces={false}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={16}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n ListHeaderComponent={renderListHeader()}\n onContentSizeChange={handleContentSizeChange}\n />\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 +0,0 @@
1
- {"version":3,"sources":["CollapsibleScrollView.tsx"],"names":["AnimatedTopView","useAnimatedScroll","React","useCallback","useMemo","useRef","StyleSheet","Animated","useAnimatedStyle","useCollapsibleContext","useInternalCollapsibleContext","CollapsibleScrollView","headerSnappable","children","props","scrollView","contentMinHeight","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,OAAOA,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,4BAA9B;AAC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ACE,IAAA,GAAG,EAAEZ,UADP;AAEE,IAAA,OAAO,EAAE;AAFX,KAGMD,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":["import AnimatedTopView from './AnimatedTopView';\nimport useAnimatedScroll from '../hooks/useAnimatedScroll';\nimport React, { ReactNode, useCallback, useMemo, useRef } 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 scrollView = useRef<Animated.ScrollView>(null);\n const { contentMinHeight } = useInternalCollapsibleContext();\n const { headerHeight } = useCollapsibleContext();\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n // @ts-ignore\n scrollView.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={scrollView}\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={16}\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["StickyView.tsx"],"names":["useInternalCollapsibleContext","React","useCallback","useEffect","useMemo","useRef","StyleSheet","useCollapsibleContext","Animated","Extrapolate","interpolate","useAnimatedStyle","useDerivedValue","stickyKey","StickyView","children","style","key","viewRef","handleStickyViewLayout","stickyViewTops","stickyViewPositions","scrollY","undefined","handleLayout","translateY","top","value","layoutValues","inputMid","CLAMP","animatedStyle","transform","styles","container","create","backgroundColor","zIndex"],"mappings":"AAAA;AACA,SAASA,6BAAT,QAA8C,wCAA9C;AACA,OAAOC,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,OAAxC,EAAiDC,MAAjD,QAA+D,OAA/D;AACA,SAAoBC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AAzB,CAFgB,EAGhB,CAAC,CAAD,EAAI,CAAJ,EAAO,MAAP,CAHgB,EAIhBpB,WAAW,CAACqB,KAJI,CAAlB;AAMD,GAViC,EAU/B,EAV+B,CAAlC;AAYA,QAAMC,aAAa,GAAGpB,gBAAgB,CAAC,MAAM;AAC3C,WAAO;AACLqB,MAAAA,SAAS,EAAE,CACT;AACEP,QAAAA,UAAU,EAAEA,UAAU,CAACE;AADzB,OADS;AADN,KAAP;AAOD,GARqC,EAQnC,EARmC,CAAtC;AAUA,sBACE,oBAAC,QAAD,CAAU,IAAV;AACE,IAAA,GAAG,EAAEV,GADP,CAEE;AAFF;AAGE,IAAA,GAAG,EAAEC,OAHP;AAIE,IAAA,QAAQ,EAAEM,YAJZ;AAKE,IAAA,KAAK,EAAE,CAACS,MAAM,CAACC,SAAR,EAAmBH,aAAnB,EAAkCf,KAAlC,CALT;AAME,IAAA,aAAa,EAAC;AANhB,KAQGD,QARH,CADF;AAYD;AAED,MAAMkB,MAAM,GAAG3B,UAAU,CAAC6B,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,eAAe,EAAE,OADR;AAETC,IAAAA,MAAM,EAAE;AAFC;AADoB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\nimport Animated, {\n Extrapolate,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n} from 'react-native-reanimated';\n\ntype Props = {\n style?: StyleProp<ViewStyle>;\n children: Element;\n};\n\nlet stickyKey = 0;\n\nexport default function StickyView({ children, style }: Props) {\n const key = useMemo(() => `sticky_${stickyKey++}`, []);\n const viewRef = useRef<View>(null);\n const { handleStickyViewLayout, stickyViewTops, stickyViewPositions } =\n useInternalCollapsibleContext();\n const { scrollY } = useCollapsibleContext();\n\n useEffect(() => {\n return () => handleStickyViewLayout(key, undefined);\n }, []);\n\n const handleLayout = useCallback(() => {\n handleStickyViewLayout(key, viewRef);\n }, [handleStickyViewLayout, key]);\n\n const translateY = useDerivedValue(() => {\n const top = stickyViewTops.value[key] || 0;\n const layoutValues = stickyViewPositions.value[key] || { top: 0 };\n const inputMid = layoutValues.top - top;\n return interpolate(\n scrollY.value,\n [0, inputMid, inputMid + 100000],\n [0, 0, 100000],\n Extrapolate.CLAMP\n );\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [\n {\n translateY: translateY.value,\n },\n ],\n };\n }, []);\n\n return (\n <Animated.View\n key={key}\n // @ts-ignore\n ref={viewRef}\n onLayout={handleLayout}\n style={[styles.container, animatedStyle, style]}\n pointerEvents=\"box-none\"\n >\n {children}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: 'white',\n zIndex: 10,\n },\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["withCollapsibleContext.tsx"],"names":["React","useCallback","useMemo","useRef","CollapsibleContext","InternalCollapsibleContext","useAnimatedReaction","useDerivedValue","useSharedValue","withTiming","debounce","withCollapsibleContext","Component","props","collapsibleHandlers","headerHeight","scrollY","stickyViewRefs","stickyViewTops","stickyViewPositionsRef","stickyViewPositions","fixedHeaderHeight","stickyHeaderHeight","containerHeight","firstStickyViewY","headerContainersHeight","containerRef","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,W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,sBAJK;AAKLwC,MAAAA,qBALK;AAML3C,MAAAA,gBANK;AAOLN,MAAAA,cAPK;AAQLE,MAAAA,mBARK;AASLC,MAAAA,iBATK;AAULY,MAAAA;AAVK,KAAP,CAD6B,EAa7B,CACEN,sBADF,EAEE8B,sBAFF,EAGEQ,2BAHF,EAIEE,qBAJF,EAKE3C,gBALF,EAMEN,cANF,EAOEE,mBAPF,EAQEC,iBARF,EASEY,gBATF,CAb6B,CAA/B;AA0BA,wBACE,oBAAC,kBAAD,CAAoB,QAApB;AAA6B,MAAA,KAAK,EAAEmC;AAApC,oBACE,oBAAC,0BAAD,CAA4B,QAA5B;AAAqC,MAAA,KAAK,EAAEM;AAA5C,oBACE,oBAAC,SAAD,EAAe7D,KAAf,CADF,CADF,CADF;AAOD,GApLD;AAqLD","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 './useCollapsibleContext';\nimport { InternalCollapsibleContext } from './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';\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\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 : 200,\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 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 <Component {...props} />\n </InternalCollapsibleContext.Provider>\n </CollapsibleContext.Provider>\n );\n };\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,34 +0,0 @@
1
- import type React from 'react';
2
- import type { View } from 'react-native';
3
- import type Animated from 'react-native-reanimated';
4
- export declare type CollapsibleHandles = {
5
- collapse: () => void;
6
- expand: () => void;
7
- scrollTo: (offset: number, animate?: boolean) => void;
8
- };
9
- export declare type CollapsibleContextType = CollapsibleHandles & {
10
- scrollY: Animated.SharedValue<number>;
11
- headerHeight: Animated.SharedValue<number>;
12
- headerCollapsed: Animated.SharedValue<boolean>;
13
- };
14
- export declare type LayoutParams = {
15
- top: number;
16
- left: number;
17
- width: number;
18
- height: number;
19
- };
20
- export declare type CollapsibleContextInternalType = {
21
- containerRef: React.RefObject<View>;
22
- contentMinHeight: Animated.SharedValue<number>;
23
- firstStickyViewY: Animated.SharedValue<number>;
24
- stickyViewPositions: Animated.SharedValue<Record<string, LayoutParams>>;
25
- stickyViewTops: Animated.SharedValue<Record<string, number>>;
26
- fixedHeaderHeight: Animated.SharedValue<number>;
27
- handleContainerHeight: (height: number) => void;
28
- handleStickyViewLayout: (viewKey: string, viewRef?: React.RefObject<View>) => void;
29
- handleHeaderContainerLayout: (viewKey: string, height?: number) => void;
30
- setCollapsibleHandlers: (handlers: CollapsibleHandles) => void;
31
- };
32
- export declare type CollapsibleProps = {
33
- headerSnappable?: boolean;
34
- };