@rific/scroll-view 0.1.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 (46) hide show
  1. package/README.md +319 -0
  2. package/dist/index.d.mts +210 -0
  3. package/dist/index.d.ts +210 -0
  4. package/dist/index.js +2760 -0
  5. package/dist/index.mjs +2709 -0
  6. package/package.json +105 -0
  7. package/src/CustomList.tsx +127 -0
  8. package/src/FlatList.tsx +139 -0
  9. package/src/PullSearch.tsx +99 -0
  10. package/src/ScrollView.tsx +89 -0
  11. package/src/ScrollViewContext.ts +50 -0
  12. package/src/ScrollViewFooter.tsx +48 -0
  13. package/src/ScrollViewHeader.tsx +159 -0
  14. package/src/ScrollViewProvider.tsx +62 -0
  15. package/src/ScrollViewSettingsContext.ts +27 -0
  16. package/src/ScrollViewSettingsProvider.tsx +31 -0
  17. package/src/SectionList.tsx +195 -0
  18. package/src/__mocks__/auto-paper.ts +8 -0
  19. package/src/__mocks__/flash-list.ts +20 -0
  20. package/src/__mocks__/react-native-gesture-handler.ts +13 -0
  21. package/src/__mocks__/react-native-keyboard-controller.ts +11 -0
  22. package/src/__mocks__/react-native-paper.ts +22 -0
  23. package/src/__mocks__/react-native-reanimated.ts +30 -0
  24. package/src/__mocks__/react-native-safe-area-context.ts +2 -0
  25. package/src/__mocks__/react-native.ts +30 -0
  26. package/src/__tests__/CustomList.test.tsx +61 -0
  27. package/src/__tests__/FlatList.test.tsx +52 -0
  28. package/src/__tests__/PullSearch.test.tsx +38 -0
  29. package/src/__tests__/ScrollView.test.tsx +23 -0
  30. package/src/__tests__/ScrollViewHeader.test.tsx +28 -0
  31. package/src/__tests__/ScrollViewProvider.test.tsx +65 -0
  32. package/src/__tests__/SectionList.test.tsx +88 -0
  33. package/src/index.ts +26 -0
  34. package/src/internal/FAB.tsx +6 -0
  35. package/src/internal/HorizontalDots.tsx +99 -0
  36. package/src/internal/RefreshControl.tsx +5 -0
  37. package/src/internal/ScrollViewChip.tsx +22 -0
  38. package/src/internal/useScrollHandler.ts +101 -0
  39. package/src/internal/useScrollList.ts +64 -0
  40. package/src/internal/useStickyHeaders.ts +149 -0
  41. package/src/out.txt +61 -0
  42. package/src/redux/scrollViewSlice.ts +14 -0
  43. package/src/useKeyboardInset.ts +21 -0
  44. package/src/useScrollInit.ts +112 -0
  45. package/src/useScrollView.ts +8 -0
  46. package/src/useScrollViewSettings.ts +5 -0
@@ -0,0 +1,210 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, ReactNode, RefObject } from 'react';
3
+ import { NativeSyntheticEvent, NativeScrollEvent, StyleProp, ViewStyle, FlatListProps as FlatListProps$1, FlatList as FlatList$1, ScrollViewProps as ScrollViewProps$1, ScrollView as ScrollView$1, SectionListProps as SectionListProps$1, SectionList as SectionList$1 } from 'react-native';
4
+ import { GestureType } from 'react-native-gesture-handler';
5
+ import * as redux from 'redux';
6
+ import * as _reduxjs_toolkit from '@reduxjs/toolkit';
7
+ import { PayloadAction } from '@reduxjs/toolkit';
8
+ import * as react_native_reanimated from 'react-native-reanimated';
9
+ import { SharedValue } from 'react-native-reanimated';
10
+
11
+ type ScrollToOffsetRef = {
12
+ scrollToOffset: (params: {
13
+ animated?: boolean;
14
+ offset: number;
15
+ }) => void;
16
+ };
17
+ type CustomListProps<P extends object> = Omit<P, 'contentInset' | 'contentOffset' | 'onScroll' | 'refreshControl' | 'scrollEventThrottle'> & {
18
+ component: ComponentType<P>;
19
+ renderFilters?: ReactNode;
20
+ footerFixed?: boolean;
21
+ gesture?: GestureType;
22
+ headerFixed?: boolean;
23
+ keyboardAware?: boolean;
24
+ onMomentumScrollEnd?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
25
+ onRefresh?: () => Promise<void> | void;
26
+ onScrollBeginDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
27
+ onScrollEndDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
28
+ pullSearchHeight?: number;
29
+ scrollRef?: RefObject<ScrollToOffsetRef | null>;
30
+ style?: StyleProp<ViewStyle>;
31
+ };
32
+ declare const CustomListInner: <P extends object>({ component: List, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollRef, style, ...props }: CustomListProps<P>) => react.JSX.Element;
33
+ declare const CustomList: typeof CustomListInner;
34
+
35
+ type FlatListProps<T> = Omit<FlatListProps$1<T>, 'onRefresh' | 'refreshing'> & {
36
+ renderFilters?: ReactNode;
37
+ footerFixed?: boolean;
38
+ gesture?: GestureType;
39
+ headerFixed?: boolean;
40
+ keyboardAware?: boolean;
41
+ onMomentumScrollEnd?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
42
+ onRefresh?: () => Promise<void> | void;
43
+ onScrollBeginDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
44
+ onScrollEndDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
45
+ pullSearchHeight?: number;
46
+ ref?: RefObject<FlatList$1 | null>;
47
+ };
48
+ declare const FlatListInner: <T>({ contentContainerStyle: externalContentContainerStyle, data, initialNumToRender, maxToRenderPerBatch, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pagingEnabled, pullSearchHeight, removeClippedSubviews, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, onContentSizeChange, ref: externalRef, windowSize, ...props }: FlatListProps<T>) => react.JSX.Element;
49
+ declare const FlatList: typeof FlatListInner;
50
+
51
+ type PullSearchHandle = {
52
+ blur: () => void;
53
+ focus: () => void;
54
+ };
55
+ type PullSearchProps = {
56
+ debounce?: boolean;
57
+ onChangeText: (text: string) => void;
58
+ onHeightChange: (height: number) => void;
59
+ placeholder?: string;
60
+ value?: string;
61
+ };
62
+ declare const PullSearch: react.ForwardRefExoticComponent<PullSearchProps & react.RefAttributes<PullSearchHandle>>;
63
+
64
+ type ScrollViewSettings = {
65
+ backActionFixed: boolean;
66
+ footerFixed: boolean;
67
+ headerFixed: boolean;
68
+ snapBack: boolean;
69
+ snapBackFooter?: boolean;
70
+ snapBackHeader?: boolean;
71
+ };
72
+ declare const defaultScrollViewSettings: ScrollViewSettings;
73
+ type ScrollViewSettingsContextType = {
74
+ settings: ScrollViewSettings;
75
+ set: (patch: Partial<ScrollViewSettings>) => void;
76
+ };
77
+ declare const ScrollViewSettingsContext: react.Context<ScrollViewSettingsContextType>;
78
+
79
+ declare const scrollViewActions: _reduxjs_toolkit.CaseReducerActions<{
80
+ initialize: (_state: {
81
+ backActionFixed: boolean;
82
+ footerFixed: boolean;
83
+ headerFixed: boolean;
84
+ snapBack: boolean;
85
+ snapBackFooter?: boolean | undefined;
86
+ snapBackHeader?: boolean | undefined;
87
+ }, action: PayloadAction<ScrollViewSettings>) => ScrollViewSettings;
88
+ }, "scrollView">;
89
+ declare const scrollViewReducer: redux.Reducer<ScrollViewSettings>;
90
+
91
+ type ScrollViewProps = ScrollViewProps$1 & {
92
+ footerFixed?: boolean;
93
+ gesture?: GestureType;
94
+ headerFixed?: boolean;
95
+ keyboardAware?: boolean;
96
+ onRefresh?: () => void;
97
+ onScrollBeginDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
98
+ onScrollEndDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
99
+ pullSearchHeight?: number;
100
+ ref?: RefObject<ScrollView$1 | null>;
101
+ refreshing?: boolean;
102
+ };
103
+ declare const ScrollViewInner: ({ children, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, style, ...props }: ScrollViewProps) => react.JSX.Element;
104
+ declare const ScrollView: typeof ScrollViewInner;
105
+
106
+ type ScrollViewContextType = {
107
+ blur: boolean;
108
+ footerHeight: number;
109
+ footerHeightShared: SharedValue<number>;
110
+ footerFixed: boolean;
111
+ footerOffset: SharedValue<number>;
112
+ headerHeight: number;
113
+ headerHeightShared: SharedValue<number>;
114
+ headerFixed: boolean;
115
+ headerOffset: SharedValue<number>;
116
+ progress: number | null;
117
+ pullSearchHeightShared: SharedValue<number>;
118
+ snapBackFooterShared: SharedValue<boolean>;
119
+ snapBackHeaderShared: SharedValue<boolean>;
120
+ progressing: boolean;
121
+ scrollHeight: number;
122
+ scrollPosition: SharedValue<number>;
123
+ setFooterHeight: (h: number) => void;
124
+ setHeaderHeight: (h: number) => void;
125
+ setProgress: (p: number | null) => void;
126
+ setProgressing: (b: boolean) => void;
127
+ tabBarHeight: number;
128
+ };
129
+ declare const ScrollViewContext: react.Context<ScrollViewContextType>;
130
+
131
+ type ScrollViewFooterProps = {
132
+ children?: ReactNode | ReactNode[];
133
+ style?: ViewStyle;
134
+ };
135
+ declare const ScrollViewFooter: ({ children, style }: ScrollViewFooterProps) => react.JSX.Element;
136
+
137
+ type ScrollViewHeaderProps = {
138
+ actionSize?: number;
139
+ actionStyle?: ViewStyle;
140
+ backAction?: () => void;
141
+ backActionFixed?: boolean;
142
+ caption?: string;
143
+ centerContent?: ReactNode;
144
+ children?: ReactNode | ReactNode[];
145
+ iconSize?: number;
146
+ style?: ViewStyle;
147
+ title?: string;
148
+ topInset?: boolean;
149
+ trailingAction?: ReactNode;
150
+ trailingActionFixed?: boolean;
151
+ };
152
+ declare const ScrollViewHeader: ({ actionSize, actionStyle, backAction, backActionFixed, caption, centerContent, children, iconSize, style, title, topInset, trailingAction, trailingActionFixed }: ScrollViewHeaderProps) => react.JSX.Element;
153
+
154
+ type ScrollViewProviderProps = {
155
+ blur?: boolean;
156
+ children: ReactNode;
157
+ fixed?: boolean;
158
+ footerFixed?: boolean;
159
+ headerFixed?: boolean;
160
+ snapBack?: boolean;
161
+ snapBackFooter?: boolean;
162
+ snapBackHeader?: boolean;
163
+ tabBarHeight?: number;
164
+ };
165
+ declare const ScrollViewProvider: ({ blur, children, fixed, footerFixed, headerFixed, snapBack, snapBackFooter, snapBackHeader, tabBarHeight }: ScrollViewProviderProps) => react.JSX.Element;
166
+
167
+ type ScrollViewSettingsProviderProps = {
168
+ children: ReactNode;
169
+ onChange?: (settings: ScrollViewSettings) => void;
170
+ value?: Partial<ScrollViewSettings>;
171
+ };
172
+ declare const ScrollViewSettingsProvider: ({ children, onChange, value }: ScrollViewSettingsProviderProps) => react.JSX.Element;
173
+
174
+ type SectionListProps<ItemT, SectionT extends {
175
+ data: ReadonlyArray<ItemT>;
176
+ } = {
177
+ data: ReadonlyArray<ItemT>;
178
+ }> = Omit<SectionListProps$1<ItemT, SectionT>, 'horizontal'> & {
179
+ renderFilters?: ReactNode;
180
+ footerFixed?: boolean;
181
+ gesture?: GestureType;
182
+ headerFixed?: boolean;
183
+ keyboardAware?: boolean;
184
+ onMomentumScrollEnd?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
185
+ onScrollBeginDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
186
+ onScrollEndDrag?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
187
+ pullSearchHeight?: number;
188
+ ref?: RefObject<SectionList$1<ItemT, SectionT> | null>;
189
+ };
190
+ declare const SectionListInner: <ItemT, SectionT extends {
191
+ data: ReadonlyArray<ItemT>;
192
+ } = {
193
+ data: ReadonlyArray<ItemT>;
194
+ }>({ contentContainerStyle: externalContentContainerStyle, initialNumToRender, maxToRenderPerBatch, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onContentSizeChange, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, removeClippedSubviews, sections, showsVerticalScrollIndicator, style, ref: externalRef, windowSize, ...props }: SectionListProps<ItemT, SectionT>) => react.JSX.Element;
195
+ declare const SectionList: typeof SectionListInner;
196
+
197
+ declare const useKeyboardInset: () => number;
198
+
199
+ declare const useScrollView: () => {
200
+ progress: number | null;
201
+ progressing: boolean;
202
+ scrollHeight: number;
203
+ scrollPosition: react_native_reanimated.SharedValue<number>;
204
+ setProgress: (p: number | null) => void;
205
+ setProgressing: (b: boolean) => void;
206
+ };
207
+
208
+ declare const useScrollViewSettings: () => ScrollViewSettingsContextType;
209
+
210
+ export { CustomList, type CustomListProps, FlatList, type FlatListProps, PullSearch, type PullSearchHandle, type PullSearchProps, ScrollView, ScrollViewContext, type ScrollViewContextType, ScrollViewFooter, type ScrollViewFooterProps, ScrollViewHeader, type ScrollViewHeaderProps, type ScrollViewProps, ScrollViewProvider, type ScrollViewProviderProps, type ScrollViewSettings, ScrollViewSettingsContext, type ScrollViewSettingsContextType, ScrollViewSettingsProvider, type ScrollViewSettingsProviderProps, SectionList, type SectionListProps, defaultScrollViewSettings, scrollViewActions, scrollViewReducer, useKeyboardInset, useScrollView, useScrollViewSettings };