react-native-collapsible-header-tab-view 1.0.3 → 1.0.5
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.
- package/README.md +33 -8
- package/dist/index.js +140 -59
- package/dist/index.mjs +156 -65
- package/dist/src/TabSectionList.d.ts +9 -0
- package/dist/src/TabSectionList.d.ts.map +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/{index.d.ts.map → src/index.d.ts.map} +1 -1
- package/dist/{types.d.ts → src/types.d.ts} +2 -2
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{TabFlatList.d.ts → src/TabFlatList.d.ts} +0 -0
- /package/dist/{TabFlatList.d.ts.map → src/TabFlatList.d.ts.map} +0 -0
- /package/dist/{TabScrollView.d.ts → src/TabScrollView.d.ts} +0 -0
- /package/dist/{TabScrollView.d.ts.map → src/TabScrollView.d.ts.map} +0 -0
- /package/dist/{context.d.ts → src/context.d.ts} +0 -0
- /package/dist/{context.d.ts.map → src/context.d.ts.map} +0 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
✨ **轻量级** - 不依赖 react-native-reanimated
|
|
10
10
|
🎯 **高性能** - 优化的滚动性能
|
|
11
11
|
📱 **吸顶效果** - 完整的粘性头部和标签栏支持
|
|
12
|
-
🔄 **灵活** - 支持 FlatList 和 ScrollView
|
|
12
|
+
🔄 **灵活** - 支持 FlatList、SectionList 和 ScrollView
|
|
13
13
|
⚡ **TypeScript** - 完整的类型支持
|
|
14
14
|
|
|
15
15
|
## 安装
|
|
@@ -31,8 +31,18 @@ npm install react-native-pager-view
|
|
|
31
31
|
|
|
32
32
|
### 基础示例
|
|
33
33
|
|
|
34
|
+
`TabFlatList`、`TabSectionList`、`TabScrollView` 可以在同一个 `CollapsibleTabView` 中混合使用,每个子组件对应一个 Tab 页。
|
|
35
|
+
|
|
34
36
|
```jsx
|
|
35
|
-
import CollapsibleTabView
|
|
37
|
+
import CollapsibleTabView, {
|
|
38
|
+
TabFlatList,
|
|
39
|
+
TabSectionList,
|
|
40
|
+
} from 'react-native-collapsible-header-tab-view';
|
|
41
|
+
|
|
42
|
+
const sections = [
|
|
43
|
+
{ title: 'A', data: ['Alice', 'Amy'] },
|
|
44
|
+
{ title: 'B', data: ['Bob', 'Ben'] },
|
|
45
|
+
];
|
|
36
46
|
|
|
37
47
|
export function App() {
|
|
38
48
|
return (
|
|
@@ -40,15 +50,18 @@ export function App() {
|
|
|
40
50
|
renderHeader={() => <HeaderComponent />}
|
|
41
51
|
renderTabBar={(props) => <TabBarComponent {...props} />}
|
|
42
52
|
>
|
|
53
|
+
{/* Tab 1: FlatList */}
|
|
43
54
|
<TabFlatList
|
|
44
|
-
data={
|
|
55
|
+
data={data}
|
|
45
56
|
renderItem={({ item }) => <ItemComponent item={item} />}
|
|
46
57
|
keyExtractor={(item) => item.id}
|
|
47
58
|
/>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
{/* Tab 2: SectionList */}
|
|
60
|
+
<TabSectionList
|
|
61
|
+
sections={sections}
|
|
62
|
+
renderItem={({ item }) => <Text>{item}</Text>}
|
|
63
|
+
renderSectionHeader={({ section }) => <Text>{section.title}</Text>}
|
|
64
|
+
keyExtractor={(item, index) => item + index}
|
|
52
65
|
/>
|
|
53
66
|
</CollapsibleTabView>
|
|
54
67
|
);
|
|
@@ -75,13 +88,25 @@ export function App() {
|
|
|
75
88
|
|
|
76
89
|
### TabFlatList
|
|
77
90
|
|
|
91
|
+
继承所有 `FlatList` 的 Props。
|
|
92
|
+
|
|
78
93
|
| 属性 | 类型 | 说明 |
|
|
79
94
|
|------|------|------|
|
|
80
|
-
| index | `number` | 必需,标签页索引 |
|
|
81
95
|
| data | `T[]` | 列表数据 |
|
|
82
96
|
| renderItem | `(info: { item: T, index: number }) => ReactNode` | 列表项渲染函数 |
|
|
83
97
|
| keyExtractor | `(item: T, index: number) => string` | 列表项 key |
|
|
84
98
|
|
|
99
|
+
### TabSectionList
|
|
100
|
+
|
|
101
|
+
继承所有 `SectionList` 的 Props。
|
|
102
|
+
|
|
103
|
+
| 属性 | 类型 | 说明 |
|
|
104
|
+
|------|------|------|
|
|
105
|
+
| sections | `SectionListData[]` | 分组数据 |
|
|
106
|
+
| renderItem | `(info: { item: T, index: number, section: S }) => ReactNode` | 列表项渲染函数 |
|
|
107
|
+
| renderSectionHeader | `(info: { section: S }) => ReactNode` | 分组头部渲染函数 |
|
|
108
|
+
| keyExtractor | `(item: T, index: number) => string` | 列表项 key |
|
|
109
|
+
|
|
85
110
|
## Ref Methods
|
|
86
111
|
|
|
87
112
|
```typescript
|
package/dist/index.js
CHANGED
|
@@ -32,11 +32,12 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
TabFlatList: () => TabFlatList,
|
|
34
34
|
TabScrollView: () => TabScrollView,
|
|
35
|
+
TabSectionList: () => TabSectionList,
|
|
35
36
|
default: () => index_default
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
39
|
+
var import_react5 = __toESM(require("react"));
|
|
40
|
+
var import_react_native4 = require("react-native");
|
|
40
41
|
var import_react_native_pager_view = __toESM(require("react-native-pager-view"));
|
|
41
42
|
|
|
42
43
|
// src/context.ts
|
|
@@ -180,8 +181,76 @@ var TabScrollView = (0, import_react3.forwardRef)(
|
|
|
180
181
|
}
|
|
181
182
|
);
|
|
182
183
|
|
|
184
|
+
// src/TabSectionList.tsx
|
|
185
|
+
var import_react4 = __toESM(require("react"));
|
|
186
|
+
var import_react_native3 = require("react-native");
|
|
187
|
+
var AnimatedSectionListComponent = import_react_native3.Animated.createAnimatedComponent(import_react_native3.SectionList);
|
|
188
|
+
var AnimatedSectionList = AnimatedSectionListComponent;
|
|
189
|
+
var TabSectionListInner = ({ contentContainerStyle, onScroll, ListHeaderComponent, ...props }, ref) => {
|
|
190
|
+
const index = useTabIndex();
|
|
191
|
+
const {
|
|
192
|
+
scrollY,
|
|
193
|
+
activeIndex,
|
|
194
|
+
stickyEnabled,
|
|
195
|
+
headerHeight,
|
|
196
|
+
tabBarHeight,
|
|
197
|
+
renderHeader,
|
|
198
|
+
renderTabBar,
|
|
199
|
+
registerRef,
|
|
200
|
+
syncScrollY
|
|
201
|
+
} = useCollapsible();
|
|
202
|
+
const innerRef = (0, import_react4.useRef)(null);
|
|
203
|
+
const isActive = activeIndex === index;
|
|
204
|
+
(0, import_react4.useEffect)(() => {
|
|
205
|
+
registerRef(index, innerRef.current);
|
|
206
|
+
return () => registerRef(index, null);
|
|
207
|
+
}, [index]);
|
|
208
|
+
(0, import_react4.useImperativeHandle)(ref, () => innerRef.current, []);
|
|
209
|
+
const handleScroll = (0, import_react4.useCallback)(
|
|
210
|
+
(e) => {
|
|
211
|
+
const y = e.nativeEvent.contentOffset.y;
|
|
212
|
+
syncScrollY(index, y);
|
|
213
|
+
onScroll?.(e);
|
|
214
|
+
},
|
|
215
|
+
[index, onScroll, syncScrollY]
|
|
216
|
+
);
|
|
217
|
+
const mergedHeader = (0, import_react4.useMemo)(() => {
|
|
218
|
+
if (stickyEnabled) return ListHeaderComponent;
|
|
219
|
+
const OriginalHeader = typeof ListHeaderComponent === "function" ? /* @__PURE__ */ import_react4.default.createElement(ListHeaderComponent, null) : ListHeaderComponent ?? null;
|
|
220
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react_native3.View, null, renderHeader?.(), renderTabBar?.(), OriginalHeader);
|
|
221
|
+
}, [stickyEnabled, ListHeaderComponent, renderHeader, renderTabBar]);
|
|
222
|
+
const paddingTop = stickyEnabled ? headerHeight + tabBarHeight : 0;
|
|
223
|
+
const collapseRange = stickyEnabled ? headerHeight : 0;
|
|
224
|
+
const [containerHeight, setContainerHeight] = (0, import_react4.useState)(0);
|
|
225
|
+
const handleLayout = (0, import_react4.useCallback)((e) => {
|
|
226
|
+
setContainerHeight(e.nativeEvent.layout.height);
|
|
227
|
+
}, []);
|
|
228
|
+
const minHeight = containerHeight > 0 ? containerHeight + collapseRange : 0;
|
|
229
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
230
|
+
AnimatedSectionList,
|
|
231
|
+
{
|
|
232
|
+
...props,
|
|
233
|
+
ref: innerRef,
|
|
234
|
+
onLayout: handleLayout,
|
|
235
|
+
ListHeaderComponent: mergedHeader,
|
|
236
|
+
contentContainerStyle: [
|
|
237
|
+
paddingTop > 0 && { paddingTop },
|
|
238
|
+
minHeight > 0 && { minHeight },
|
|
239
|
+
contentContainerStyle
|
|
240
|
+
],
|
|
241
|
+
onScroll: isActive && stickyEnabled ? import_react_native3.Animated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], {
|
|
242
|
+
useNativeDriver: true,
|
|
243
|
+
listener: handleScroll
|
|
244
|
+
}) : handleScroll,
|
|
245
|
+
scrollEventThrottle: 16,
|
|
246
|
+
showsVerticalScrollIndicator: false
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
var TabSectionList = (0, import_react4.forwardRef)(TabSectionListInner);
|
|
251
|
+
|
|
183
252
|
// src/index.tsx
|
|
184
|
-
var CollapsibleTabView = (0,
|
|
253
|
+
var CollapsibleTabView = (0, import_react5.forwardRef)(
|
|
185
254
|
({
|
|
186
255
|
children,
|
|
187
256
|
renderHeader,
|
|
@@ -196,13 +265,13 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
196
265
|
swipeEnabled = true,
|
|
197
266
|
style
|
|
198
267
|
}, ref) => {
|
|
199
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
200
|
-
const pagerRef = (0,
|
|
201
|
-
const pages = (0,
|
|
202
|
-
() =>
|
|
268
|
+
const [activeIndex, setActiveIndex] = (0, import_react5.useState)(initialTabIndex);
|
|
269
|
+
const pagerRef = (0, import_react5.useRef)(null);
|
|
270
|
+
const pages = (0, import_react5.useMemo)(
|
|
271
|
+
() => import_react5.default.Children.toArray(children).filter(import_react5.default.isValidElement),
|
|
203
272
|
[children]
|
|
204
273
|
);
|
|
205
|
-
(0,
|
|
274
|
+
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
206
275
|
scrollToTab: (index, animated = true) => {
|
|
207
276
|
if (index === activeIndex || index < 0 || index >= pages.length) return;
|
|
208
277
|
syncTabOnSwitch(index);
|
|
@@ -217,17 +286,17 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
217
286
|
getActiveIndex: () => activeIndex
|
|
218
287
|
}));
|
|
219
288
|
const hasEstimate = estimatedHeaderHeight > 0;
|
|
220
|
-
const headerHeightRef = (0,
|
|
221
|
-
const tabBarHeightRef = (0,
|
|
222
|
-
const [layout, setLayout] = (0,
|
|
289
|
+
const headerHeightRef = (0, import_react5.useRef)(0);
|
|
290
|
+
const tabBarHeightRef = (0, import_react5.useRef)(0);
|
|
291
|
+
const [layout, setLayout] = (0, import_react5.useState)({
|
|
223
292
|
headerHeight: estimatedHeaderHeight,
|
|
224
293
|
tabBarHeight: estimatedTabBarHeight,
|
|
225
294
|
ready: hasEstimate
|
|
226
295
|
});
|
|
227
296
|
const { headerHeight, tabBarHeight } = layout;
|
|
228
297
|
const visible = layout.ready;
|
|
229
|
-
const adjustY = (0,
|
|
230
|
-
const tryCommitLayout = (0,
|
|
298
|
+
const adjustY = (0, import_react5.useRef)(new import_react_native4.Animated.Value(0)).current;
|
|
299
|
+
const tryCommitLayout = (0, import_react5.useCallback)(() => {
|
|
231
300
|
const h = headerHeightRef.current;
|
|
232
301
|
const t = tabBarHeightRef.current;
|
|
233
302
|
if (h > 0 && t > 0) {
|
|
@@ -238,7 +307,7 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
238
307
|
const diff = h + t - (prev.headerHeight + prev.tabBarHeight);
|
|
239
308
|
if (prev.ready && Math.abs(diff) > 1) {
|
|
240
309
|
adjustY.setValue(-diff);
|
|
241
|
-
|
|
310
|
+
import_react_native4.Animated.timing(adjustY, {
|
|
242
311
|
toValue: 0,
|
|
243
312
|
duration: 200,
|
|
244
313
|
useNativeDriver: true
|
|
@@ -247,36 +316,36 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
247
316
|
return { headerHeight: h, tabBarHeight: t, ready: true };
|
|
248
317
|
});
|
|
249
318
|
}
|
|
250
|
-
}, []);
|
|
251
|
-
const handleHeaderLayout = (0,
|
|
319
|
+
}, [adjustY]);
|
|
320
|
+
const handleHeaderLayout = (0, import_react5.useCallback)(
|
|
252
321
|
(e) => {
|
|
253
322
|
headerHeightRef.current = e.nativeEvent.layout.height;
|
|
254
323
|
tryCommitLayout();
|
|
255
324
|
},
|
|
256
325
|
[tryCommitLayout]
|
|
257
326
|
);
|
|
258
|
-
const handleTabBarLayout = (0,
|
|
327
|
+
const handleTabBarLayout = (0, import_react5.useCallback)(
|
|
259
328
|
(e) => {
|
|
260
329
|
tabBarHeightRef.current = e.nativeEvent.layout.height;
|
|
261
330
|
tryCommitLayout();
|
|
262
331
|
},
|
|
263
332
|
[tryCommitLayout]
|
|
264
333
|
);
|
|
265
|
-
const scrollY = (0,
|
|
266
|
-
const tabScrollYMap = (0,
|
|
267
|
-
const tabRefs = (0,
|
|
334
|
+
const scrollY = (0, import_react5.useRef)(new import_react_native4.Animated.Value(0)).current;
|
|
335
|
+
const tabScrollYMap = (0, import_react5.useRef)(/* @__PURE__ */ new Map());
|
|
336
|
+
const tabRefs = (0, import_react5.useRef)(
|
|
268
337
|
/* @__PURE__ */ new Map()
|
|
269
338
|
);
|
|
270
339
|
const collapseRange = stickyEnabled ? Math.max(headerHeight - stickyTop, 0) : 0;
|
|
271
|
-
const headerTranslateY = (0,
|
|
340
|
+
const headerTranslateY = (0, import_react5.useMemo)(
|
|
272
341
|
() => collapseRange > 0 ? scrollY.interpolate({
|
|
273
342
|
inputRange: [0, collapseRange],
|
|
274
343
|
outputRange: [0, -collapseRange],
|
|
275
344
|
extrapolate: "clamp"
|
|
276
|
-
}) : new
|
|
345
|
+
}) : new import_react_native4.Animated.Value(0),
|
|
277
346
|
[scrollY, collapseRange]
|
|
278
347
|
);
|
|
279
|
-
const registerRef = (0,
|
|
348
|
+
const registerRef = (0, import_react5.useCallback)(
|
|
280
349
|
(index, ref2) => {
|
|
281
350
|
if (ref2) {
|
|
282
351
|
tabRefs.current.set(index, ref2);
|
|
@@ -286,14 +355,14 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
286
355
|
},
|
|
287
356
|
[]
|
|
288
357
|
);
|
|
289
|
-
const syncScrollY = (0,
|
|
358
|
+
const syncScrollY = (0, import_react5.useCallback)(
|
|
290
359
|
(index, y) => {
|
|
291
360
|
tabScrollYMap.current.set(index, y);
|
|
292
361
|
onScrollProp?.(y);
|
|
293
362
|
},
|
|
294
363
|
[onScrollProp]
|
|
295
364
|
);
|
|
296
|
-
const scrollTabTo = (0,
|
|
365
|
+
const scrollTabTo = (0, import_react5.useCallback)((index, offset) => {
|
|
297
366
|
const ref2 = tabRefs.current.get(index);
|
|
298
367
|
if (!ref2) return;
|
|
299
368
|
if (ref2.scrollToOffset) {
|
|
@@ -309,26 +378,35 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
309
378
|
}
|
|
310
379
|
}
|
|
311
380
|
}, []);
|
|
312
|
-
const syncTabOnSwitch = (0,
|
|
313
|
-
(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
381
|
+
const syncTabOnSwitch = (0, import_react5.useCallback)((newIndex) => {
|
|
382
|
+
const currentY = tabScrollYMap.current.get(activeIndex) ?? 0;
|
|
383
|
+
const newTabSavedY = tabScrollYMap.current.get(newIndex) ?? 0;
|
|
384
|
+
const isCollapsed = currentY >= collapseRange - 1;
|
|
385
|
+
const targetY = isCollapsed ? Math.max(newTabSavedY, collapseRange) : Math.min(currentY, collapseRange);
|
|
386
|
+
scrollTabTo(newIndex, targetY);
|
|
387
|
+
tabScrollYMap.current.set(newIndex, targetY);
|
|
388
|
+
scrollY.setValue(Math.min(targetY, collapseRange));
|
|
389
|
+
}, []);
|
|
390
|
+
const preSyncAdjacentTabs = (0, import_react5.useCallback)(() => {
|
|
391
|
+
const currentY = tabScrollYMap.current.get(activeIndex) ?? 0;
|
|
392
|
+
const isCollapsed = currentY >= collapseRange - 1;
|
|
393
|
+
for (const i of [activeIndex - 1, activeIndex + 1]) {
|
|
394
|
+
if (i < 0 || i >= pages.length) continue;
|
|
395
|
+
const savedY = tabScrollYMap.current.get(i) ?? 0;
|
|
396
|
+
const targetY = isCollapsed ? Math.max(savedY, collapseRange) : Math.min(currentY, collapseRange);
|
|
397
|
+
scrollTabTo(i, targetY);
|
|
398
|
+
tabScrollYMap.current.set(i, targetY);
|
|
399
|
+
}
|
|
400
|
+
}, [activeIndex, collapseRange, pages.length, scrollTabTo]);
|
|
401
|
+
const handlePageScrollStateChanged = (0, import_react5.useCallback)(
|
|
402
|
+
(e) => {
|
|
403
|
+
if (e.nativeEvent.pageScrollState === "dragging") {
|
|
404
|
+
preSyncAdjacentTabs();
|
|
322
405
|
}
|
|
323
|
-
import_react_native3.InteractionManager.runAfterInteractions(() => {
|
|
324
|
-
scrollTabTo(newIndex, targetY);
|
|
325
|
-
tabScrollYMap.current.set(newIndex, targetY);
|
|
326
|
-
scrollY.setValue(Math.min(targetY, collapseRange));
|
|
327
|
-
});
|
|
328
406
|
},
|
|
329
|
-
[
|
|
407
|
+
[preSyncAdjacentTabs]
|
|
330
408
|
);
|
|
331
|
-
const handleTabPress = (0,
|
|
409
|
+
const handleTabPress = (0, import_react5.useCallback)(
|
|
332
410
|
(index) => {
|
|
333
411
|
if (index === activeIndex) return;
|
|
334
412
|
syncTabOnSwitch(index);
|
|
@@ -336,30 +414,31 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
336
414
|
pagerRef.current?.setPageWithoutAnimation(index);
|
|
337
415
|
onTabChange?.(index);
|
|
338
416
|
},
|
|
339
|
-
[activeIndex,
|
|
417
|
+
[activeIndex, syncTabOnSwitch, onTabChange]
|
|
340
418
|
);
|
|
341
|
-
const handlePageSelected = (0,
|
|
419
|
+
const handlePageSelected = (0, import_react5.useCallback)(
|
|
342
420
|
(e) => {
|
|
343
421
|
const newIndex = e.nativeEvent.position;
|
|
344
422
|
if (newIndex === activeIndex) return;
|
|
345
|
-
|
|
423
|
+
const savedY = tabScrollYMap.current.get(newIndex) ?? 0;
|
|
424
|
+
scrollY.setValue(Math.min(savedY, collapseRange));
|
|
346
425
|
setActiveIndex(newIndex);
|
|
347
426
|
onTabChange?.(newIndex);
|
|
348
427
|
},
|
|
349
|
-
[activeIndex,
|
|
428
|
+
[activeIndex, collapseRange, scrollY, onTabChange]
|
|
350
429
|
);
|
|
351
|
-
const tabBarProps = (0,
|
|
430
|
+
const tabBarProps = (0, import_react5.useMemo)(
|
|
352
431
|
() => ({
|
|
353
432
|
activeIndex,
|
|
354
433
|
onTabPress: handleTabPress
|
|
355
434
|
}),
|
|
356
435
|
[activeIndex, handleTabPress]
|
|
357
436
|
);
|
|
358
|
-
const renderTabBarNode = (0,
|
|
437
|
+
const renderTabBarNode = (0, import_react5.useCallback)(
|
|
359
438
|
() => renderTabBar(tabBarProps),
|
|
360
439
|
[renderTabBar, tabBarProps]
|
|
361
440
|
);
|
|
362
|
-
const contextValue = (0,
|
|
441
|
+
const contextValue = (0, import_react5.useMemo)(
|
|
363
442
|
() => ({
|
|
364
443
|
scrollY,
|
|
365
444
|
activeIndex,
|
|
@@ -383,8 +462,8 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
383
462
|
syncScrollY
|
|
384
463
|
]
|
|
385
464
|
);
|
|
386
|
-
return /* @__PURE__ */
|
|
387
|
-
|
|
465
|
+
return /* @__PURE__ */ import_react5.default.createElement(CollapsibleContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react5.default.createElement(import_react_native4.View, { style: [styles.container, style] }, /* @__PURE__ */ import_react5.default.createElement(
|
|
466
|
+
import_react_native4.Animated.View,
|
|
388
467
|
{
|
|
389
468
|
style: [
|
|
390
469
|
styles.pager,
|
|
@@ -392,19 +471,20 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
392
471
|
{ transform: [{ translateY: adjustY }] }
|
|
393
472
|
]
|
|
394
473
|
},
|
|
395
|
-
/* @__PURE__ */
|
|
474
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
396
475
|
import_react_native_pager_view.default,
|
|
397
476
|
{
|
|
398
477
|
ref: pagerRef,
|
|
399
478
|
style: styles.pager,
|
|
400
479
|
initialPage: initialTabIndex,
|
|
401
480
|
onPageSelected: handlePageSelected,
|
|
481
|
+
onPageScrollStateChanged: handlePageScrollStateChanged,
|
|
402
482
|
scrollEnabled: swipeEnabled
|
|
403
483
|
},
|
|
404
|
-
pages.map((page, i) => /* @__PURE__ */
|
|
484
|
+
pages.map((page, i) => /* @__PURE__ */ import_react5.default.createElement(import_react_native4.View, { key: page?.key ?? i, style: styles.page }, /* @__PURE__ */ import_react5.default.createElement(TabIndexContext.Provider, { value: i }, page)))
|
|
405
485
|
)
|
|
406
|
-
), stickyEnabled && /* @__PURE__ */
|
|
407
|
-
|
|
486
|
+
), stickyEnabled && /* @__PURE__ */ import_react5.default.createElement(
|
|
487
|
+
import_react_native4.Animated.View,
|
|
408
488
|
{
|
|
409
489
|
style: [
|
|
410
490
|
styles.overlay,
|
|
@@ -412,12 +492,12 @@ var CollapsibleTabView = (0, import_react4.forwardRef)(
|
|
|
412
492
|
],
|
|
413
493
|
pointerEvents: "box-none"
|
|
414
494
|
},
|
|
415
|
-
/* @__PURE__ */
|
|
416
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ import_react5.default.createElement(import_react_native4.View, { pointerEvents: "box-none", onLayout: handleHeaderLayout }, renderHeader()),
|
|
496
|
+
/* @__PURE__ */ import_react5.default.createElement(import_react_native4.View, { onLayout: handleTabBarLayout }, renderTabBarNode())
|
|
417
497
|
)));
|
|
418
498
|
}
|
|
419
499
|
);
|
|
420
|
-
var styles =
|
|
500
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
421
501
|
container: {
|
|
422
502
|
flex: 1
|
|
423
503
|
},
|
|
@@ -442,5 +522,6 @@ var index_default = CollapsibleTabView;
|
|
|
442
522
|
// Annotate the CommonJS export names for ESM import in node:
|
|
443
523
|
0 && (module.exports = {
|
|
444
524
|
TabFlatList,
|
|
445
|
-
TabScrollView
|
|
525
|
+
TabScrollView,
|
|
526
|
+
TabSectionList
|
|
446
527
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
// src/index.tsx
|
|
2
|
-
import
|
|
3
|
-
forwardRef as
|
|
4
|
-
useCallback as
|
|
5
|
-
useImperativeHandle as
|
|
6
|
-
useMemo as
|
|
7
|
-
useRef as
|
|
8
|
-
useState as
|
|
2
|
+
import React4, {
|
|
3
|
+
forwardRef as forwardRef4,
|
|
4
|
+
useCallback as useCallback4,
|
|
5
|
+
useImperativeHandle as useImperativeHandle4,
|
|
6
|
+
useMemo as useMemo3,
|
|
7
|
+
useRef as useRef4,
|
|
8
|
+
useState as useState4
|
|
9
9
|
} from "react";
|
|
10
10
|
import {
|
|
11
|
-
Animated as
|
|
12
|
-
InteractionManager,
|
|
11
|
+
Animated as Animated4,
|
|
13
12
|
StyleSheet,
|
|
14
|
-
View as
|
|
13
|
+
View as View3
|
|
15
14
|
} from "react-native";
|
|
16
15
|
import PagerView from "react-native-pager-view";
|
|
17
16
|
|
|
@@ -177,8 +176,88 @@ var TabScrollView = forwardRef2(
|
|
|
177
176
|
}
|
|
178
177
|
);
|
|
179
178
|
|
|
179
|
+
// src/TabSectionList.tsx
|
|
180
|
+
import React3, {
|
|
181
|
+
forwardRef as forwardRef3,
|
|
182
|
+
useCallback as useCallback3,
|
|
183
|
+
useEffect as useEffect3,
|
|
184
|
+
useImperativeHandle as useImperativeHandle3,
|
|
185
|
+
useMemo as useMemo2,
|
|
186
|
+
useRef as useRef3,
|
|
187
|
+
useState as useState3
|
|
188
|
+
} from "react";
|
|
189
|
+
import {
|
|
190
|
+
Animated as Animated3,
|
|
191
|
+
SectionList,
|
|
192
|
+
View as View2
|
|
193
|
+
} from "react-native";
|
|
194
|
+
var AnimatedSectionListComponent = Animated3.createAnimatedComponent(SectionList);
|
|
195
|
+
var AnimatedSectionList = AnimatedSectionListComponent;
|
|
196
|
+
var TabSectionListInner = ({ contentContainerStyle, onScroll, ListHeaderComponent, ...props }, ref) => {
|
|
197
|
+
const index = useTabIndex();
|
|
198
|
+
const {
|
|
199
|
+
scrollY,
|
|
200
|
+
activeIndex,
|
|
201
|
+
stickyEnabled,
|
|
202
|
+
headerHeight,
|
|
203
|
+
tabBarHeight,
|
|
204
|
+
renderHeader,
|
|
205
|
+
renderTabBar,
|
|
206
|
+
registerRef,
|
|
207
|
+
syncScrollY
|
|
208
|
+
} = useCollapsible();
|
|
209
|
+
const innerRef = useRef3(null);
|
|
210
|
+
const isActive = activeIndex === index;
|
|
211
|
+
useEffect3(() => {
|
|
212
|
+
registerRef(index, innerRef.current);
|
|
213
|
+
return () => registerRef(index, null);
|
|
214
|
+
}, [index]);
|
|
215
|
+
useImperativeHandle3(ref, () => innerRef.current, []);
|
|
216
|
+
const handleScroll = useCallback3(
|
|
217
|
+
(e) => {
|
|
218
|
+
const y = e.nativeEvent.contentOffset.y;
|
|
219
|
+
syncScrollY(index, y);
|
|
220
|
+
onScroll?.(e);
|
|
221
|
+
},
|
|
222
|
+
[index, onScroll, syncScrollY]
|
|
223
|
+
);
|
|
224
|
+
const mergedHeader = useMemo2(() => {
|
|
225
|
+
if (stickyEnabled) return ListHeaderComponent;
|
|
226
|
+
const OriginalHeader = typeof ListHeaderComponent === "function" ? /* @__PURE__ */ React3.createElement(ListHeaderComponent, null) : ListHeaderComponent ?? null;
|
|
227
|
+
return /* @__PURE__ */ React3.createElement(View2, null, renderHeader?.(), renderTabBar?.(), OriginalHeader);
|
|
228
|
+
}, [stickyEnabled, ListHeaderComponent, renderHeader, renderTabBar]);
|
|
229
|
+
const paddingTop = stickyEnabled ? headerHeight + tabBarHeight : 0;
|
|
230
|
+
const collapseRange = stickyEnabled ? headerHeight : 0;
|
|
231
|
+
const [containerHeight, setContainerHeight] = useState3(0);
|
|
232
|
+
const handleLayout = useCallback3((e) => {
|
|
233
|
+
setContainerHeight(e.nativeEvent.layout.height);
|
|
234
|
+
}, []);
|
|
235
|
+
const minHeight = containerHeight > 0 ? containerHeight + collapseRange : 0;
|
|
236
|
+
return /* @__PURE__ */ React3.createElement(
|
|
237
|
+
AnimatedSectionList,
|
|
238
|
+
{
|
|
239
|
+
...props,
|
|
240
|
+
ref: innerRef,
|
|
241
|
+
onLayout: handleLayout,
|
|
242
|
+
ListHeaderComponent: mergedHeader,
|
|
243
|
+
contentContainerStyle: [
|
|
244
|
+
paddingTop > 0 && { paddingTop },
|
|
245
|
+
minHeight > 0 && { minHeight },
|
|
246
|
+
contentContainerStyle
|
|
247
|
+
],
|
|
248
|
+
onScroll: isActive && stickyEnabled ? Animated3.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], {
|
|
249
|
+
useNativeDriver: true,
|
|
250
|
+
listener: handleScroll
|
|
251
|
+
}) : handleScroll,
|
|
252
|
+
scrollEventThrottle: 16,
|
|
253
|
+
showsVerticalScrollIndicator: false
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
var TabSectionList = forwardRef3(TabSectionListInner);
|
|
258
|
+
|
|
180
259
|
// src/index.tsx
|
|
181
|
-
var CollapsibleTabView =
|
|
260
|
+
var CollapsibleTabView = forwardRef4(
|
|
182
261
|
({
|
|
183
262
|
children,
|
|
184
263
|
renderHeader,
|
|
@@ -193,13 +272,13 @@ var CollapsibleTabView = forwardRef3(
|
|
|
193
272
|
swipeEnabled = true,
|
|
194
273
|
style
|
|
195
274
|
}, ref) => {
|
|
196
|
-
const [activeIndex, setActiveIndex] =
|
|
197
|
-
const pagerRef =
|
|
198
|
-
const pages =
|
|
199
|
-
() =>
|
|
275
|
+
const [activeIndex, setActiveIndex] = useState4(initialTabIndex);
|
|
276
|
+
const pagerRef = useRef4(null);
|
|
277
|
+
const pages = useMemo3(
|
|
278
|
+
() => React4.Children.toArray(children).filter(React4.isValidElement),
|
|
200
279
|
[children]
|
|
201
280
|
);
|
|
202
|
-
|
|
281
|
+
useImperativeHandle4(ref, () => ({
|
|
203
282
|
scrollToTab: (index, animated = true) => {
|
|
204
283
|
if (index === activeIndex || index < 0 || index >= pages.length) return;
|
|
205
284
|
syncTabOnSwitch(index);
|
|
@@ -214,17 +293,17 @@ var CollapsibleTabView = forwardRef3(
|
|
|
214
293
|
getActiveIndex: () => activeIndex
|
|
215
294
|
}));
|
|
216
295
|
const hasEstimate = estimatedHeaderHeight > 0;
|
|
217
|
-
const headerHeightRef =
|
|
218
|
-
const tabBarHeightRef =
|
|
219
|
-
const [layout, setLayout] =
|
|
296
|
+
const headerHeightRef = useRef4(0);
|
|
297
|
+
const tabBarHeightRef = useRef4(0);
|
|
298
|
+
const [layout, setLayout] = useState4({
|
|
220
299
|
headerHeight: estimatedHeaderHeight,
|
|
221
300
|
tabBarHeight: estimatedTabBarHeight,
|
|
222
301
|
ready: hasEstimate
|
|
223
302
|
});
|
|
224
303
|
const { headerHeight, tabBarHeight } = layout;
|
|
225
304
|
const visible = layout.ready;
|
|
226
|
-
const adjustY =
|
|
227
|
-
const tryCommitLayout =
|
|
305
|
+
const adjustY = useRef4(new Animated4.Value(0)).current;
|
|
306
|
+
const tryCommitLayout = useCallback4(() => {
|
|
228
307
|
const h = headerHeightRef.current;
|
|
229
308
|
const t = tabBarHeightRef.current;
|
|
230
309
|
if (h > 0 && t > 0) {
|
|
@@ -235,7 +314,7 @@ var CollapsibleTabView = forwardRef3(
|
|
|
235
314
|
const diff = h + t - (prev.headerHeight + prev.tabBarHeight);
|
|
236
315
|
if (prev.ready && Math.abs(diff) > 1) {
|
|
237
316
|
adjustY.setValue(-diff);
|
|
238
|
-
|
|
317
|
+
Animated4.timing(adjustY, {
|
|
239
318
|
toValue: 0,
|
|
240
319
|
duration: 200,
|
|
241
320
|
useNativeDriver: true
|
|
@@ -244,36 +323,36 @@ var CollapsibleTabView = forwardRef3(
|
|
|
244
323
|
return { headerHeight: h, tabBarHeight: t, ready: true };
|
|
245
324
|
});
|
|
246
325
|
}
|
|
247
|
-
}, []);
|
|
248
|
-
const handleHeaderLayout =
|
|
326
|
+
}, [adjustY]);
|
|
327
|
+
const handleHeaderLayout = useCallback4(
|
|
249
328
|
(e) => {
|
|
250
329
|
headerHeightRef.current = e.nativeEvent.layout.height;
|
|
251
330
|
tryCommitLayout();
|
|
252
331
|
},
|
|
253
332
|
[tryCommitLayout]
|
|
254
333
|
);
|
|
255
|
-
const handleTabBarLayout =
|
|
334
|
+
const handleTabBarLayout = useCallback4(
|
|
256
335
|
(e) => {
|
|
257
336
|
tabBarHeightRef.current = e.nativeEvent.layout.height;
|
|
258
337
|
tryCommitLayout();
|
|
259
338
|
},
|
|
260
339
|
[tryCommitLayout]
|
|
261
340
|
);
|
|
262
|
-
const scrollY =
|
|
263
|
-
const tabScrollYMap =
|
|
264
|
-
const tabRefs =
|
|
341
|
+
const scrollY = useRef4(new Animated4.Value(0)).current;
|
|
342
|
+
const tabScrollYMap = useRef4(/* @__PURE__ */ new Map());
|
|
343
|
+
const tabRefs = useRef4(
|
|
265
344
|
/* @__PURE__ */ new Map()
|
|
266
345
|
);
|
|
267
346
|
const collapseRange = stickyEnabled ? Math.max(headerHeight - stickyTop, 0) : 0;
|
|
268
|
-
const headerTranslateY =
|
|
347
|
+
const headerTranslateY = useMemo3(
|
|
269
348
|
() => collapseRange > 0 ? scrollY.interpolate({
|
|
270
349
|
inputRange: [0, collapseRange],
|
|
271
350
|
outputRange: [0, -collapseRange],
|
|
272
351
|
extrapolate: "clamp"
|
|
273
|
-
}) : new
|
|
352
|
+
}) : new Animated4.Value(0),
|
|
274
353
|
[scrollY, collapseRange]
|
|
275
354
|
);
|
|
276
|
-
const registerRef =
|
|
355
|
+
const registerRef = useCallback4(
|
|
277
356
|
(index, ref2) => {
|
|
278
357
|
if (ref2) {
|
|
279
358
|
tabRefs.current.set(index, ref2);
|
|
@@ -283,14 +362,14 @@ var CollapsibleTabView = forwardRef3(
|
|
|
283
362
|
},
|
|
284
363
|
[]
|
|
285
364
|
);
|
|
286
|
-
const syncScrollY =
|
|
365
|
+
const syncScrollY = useCallback4(
|
|
287
366
|
(index, y) => {
|
|
288
367
|
tabScrollYMap.current.set(index, y);
|
|
289
368
|
onScrollProp?.(y);
|
|
290
369
|
},
|
|
291
370
|
[onScrollProp]
|
|
292
371
|
);
|
|
293
|
-
const scrollTabTo =
|
|
372
|
+
const scrollTabTo = useCallback4((index, offset) => {
|
|
294
373
|
const ref2 = tabRefs.current.get(index);
|
|
295
374
|
if (!ref2) return;
|
|
296
375
|
if (ref2.scrollToOffset) {
|
|
@@ -306,26 +385,35 @@ var CollapsibleTabView = forwardRef3(
|
|
|
306
385
|
}
|
|
307
386
|
}
|
|
308
387
|
}, []);
|
|
309
|
-
const syncTabOnSwitch =
|
|
310
|
-
(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
388
|
+
const syncTabOnSwitch = useCallback4((newIndex) => {
|
|
389
|
+
const currentY = tabScrollYMap.current.get(activeIndex) ?? 0;
|
|
390
|
+
const newTabSavedY = tabScrollYMap.current.get(newIndex) ?? 0;
|
|
391
|
+
const isCollapsed = currentY >= collapseRange - 1;
|
|
392
|
+
const targetY = isCollapsed ? Math.max(newTabSavedY, collapseRange) : Math.min(currentY, collapseRange);
|
|
393
|
+
scrollTabTo(newIndex, targetY);
|
|
394
|
+
tabScrollYMap.current.set(newIndex, targetY);
|
|
395
|
+
scrollY.setValue(Math.min(targetY, collapseRange));
|
|
396
|
+
}, []);
|
|
397
|
+
const preSyncAdjacentTabs = useCallback4(() => {
|
|
398
|
+
const currentY = tabScrollYMap.current.get(activeIndex) ?? 0;
|
|
399
|
+
const isCollapsed = currentY >= collapseRange - 1;
|
|
400
|
+
for (const i of [activeIndex - 1, activeIndex + 1]) {
|
|
401
|
+
if (i < 0 || i >= pages.length) continue;
|
|
402
|
+
const savedY = tabScrollYMap.current.get(i) ?? 0;
|
|
403
|
+
const targetY = isCollapsed ? Math.max(savedY, collapseRange) : Math.min(currentY, collapseRange);
|
|
404
|
+
scrollTabTo(i, targetY);
|
|
405
|
+
tabScrollYMap.current.set(i, targetY);
|
|
406
|
+
}
|
|
407
|
+
}, [activeIndex, collapseRange, pages.length, scrollTabTo]);
|
|
408
|
+
const handlePageScrollStateChanged = useCallback4(
|
|
409
|
+
(e) => {
|
|
410
|
+
if (e.nativeEvent.pageScrollState === "dragging") {
|
|
411
|
+
preSyncAdjacentTabs();
|
|
319
412
|
}
|
|
320
|
-
InteractionManager.runAfterInteractions(() => {
|
|
321
|
-
scrollTabTo(newIndex, targetY);
|
|
322
|
-
tabScrollYMap.current.set(newIndex, targetY);
|
|
323
|
-
scrollY.setValue(Math.min(targetY, collapseRange));
|
|
324
|
-
});
|
|
325
413
|
},
|
|
326
|
-
[
|
|
414
|
+
[preSyncAdjacentTabs]
|
|
327
415
|
);
|
|
328
|
-
const handleTabPress =
|
|
416
|
+
const handleTabPress = useCallback4(
|
|
329
417
|
(index) => {
|
|
330
418
|
if (index === activeIndex) return;
|
|
331
419
|
syncTabOnSwitch(index);
|
|
@@ -333,30 +421,31 @@ var CollapsibleTabView = forwardRef3(
|
|
|
333
421
|
pagerRef.current?.setPageWithoutAnimation(index);
|
|
334
422
|
onTabChange?.(index);
|
|
335
423
|
},
|
|
336
|
-
[activeIndex,
|
|
424
|
+
[activeIndex, syncTabOnSwitch, onTabChange]
|
|
337
425
|
);
|
|
338
|
-
const handlePageSelected =
|
|
426
|
+
const handlePageSelected = useCallback4(
|
|
339
427
|
(e) => {
|
|
340
428
|
const newIndex = e.nativeEvent.position;
|
|
341
429
|
if (newIndex === activeIndex) return;
|
|
342
|
-
|
|
430
|
+
const savedY = tabScrollYMap.current.get(newIndex) ?? 0;
|
|
431
|
+
scrollY.setValue(Math.min(savedY, collapseRange));
|
|
343
432
|
setActiveIndex(newIndex);
|
|
344
433
|
onTabChange?.(newIndex);
|
|
345
434
|
},
|
|
346
|
-
[activeIndex,
|
|
435
|
+
[activeIndex, collapseRange, scrollY, onTabChange]
|
|
347
436
|
);
|
|
348
|
-
const tabBarProps =
|
|
437
|
+
const tabBarProps = useMemo3(
|
|
349
438
|
() => ({
|
|
350
439
|
activeIndex,
|
|
351
440
|
onTabPress: handleTabPress
|
|
352
441
|
}),
|
|
353
442
|
[activeIndex, handleTabPress]
|
|
354
443
|
);
|
|
355
|
-
const renderTabBarNode =
|
|
444
|
+
const renderTabBarNode = useCallback4(
|
|
356
445
|
() => renderTabBar(tabBarProps),
|
|
357
446
|
[renderTabBar, tabBarProps]
|
|
358
447
|
);
|
|
359
|
-
const contextValue =
|
|
448
|
+
const contextValue = useMemo3(
|
|
360
449
|
() => ({
|
|
361
450
|
scrollY,
|
|
362
451
|
activeIndex,
|
|
@@ -380,8 +469,8 @@ var CollapsibleTabView = forwardRef3(
|
|
|
380
469
|
syncScrollY
|
|
381
470
|
]
|
|
382
471
|
);
|
|
383
|
-
return /* @__PURE__ */
|
|
384
|
-
|
|
472
|
+
return /* @__PURE__ */ React4.createElement(CollapsibleContext.Provider, { value: contextValue }, /* @__PURE__ */ React4.createElement(View3, { style: [styles.container, style] }, /* @__PURE__ */ React4.createElement(
|
|
473
|
+
Animated4.View,
|
|
385
474
|
{
|
|
386
475
|
style: [
|
|
387
476
|
styles.pager,
|
|
@@ -389,19 +478,20 @@ var CollapsibleTabView = forwardRef3(
|
|
|
389
478
|
{ transform: [{ translateY: adjustY }] }
|
|
390
479
|
]
|
|
391
480
|
},
|
|
392
|
-
/* @__PURE__ */
|
|
481
|
+
/* @__PURE__ */ React4.createElement(
|
|
393
482
|
PagerView,
|
|
394
483
|
{
|
|
395
484
|
ref: pagerRef,
|
|
396
485
|
style: styles.pager,
|
|
397
486
|
initialPage: initialTabIndex,
|
|
398
487
|
onPageSelected: handlePageSelected,
|
|
488
|
+
onPageScrollStateChanged: handlePageScrollStateChanged,
|
|
399
489
|
scrollEnabled: swipeEnabled
|
|
400
490
|
},
|
|
401
|
-
pages.map((page, i) => /* @__PURE__ */
|
|
491
|
+
pages.map((page, i) => /* @__PURE__ */ React4.createElement(View3, { key: page?.key ?? i, style: styles.page }, /* @__PURE__ */ React4.createElement(TabIndexContext.Provider, { value: i }, page)))
|
|
402
492
|
)
|
|
403
|
-
), stickyEnabled && /* @__PURE__ */
|
|
404
|
-
|
|
493
|
+
), stickyEnabled && /* @__PURE__ */ React4.createElement(
|
|
494
|
+
Animated4.View,
|
|
405
495
|
{
|
|
406
496
|
style: [
|
|
407
497
|
styles.overlay,
|
|
@@ -409,8 +499,8 @@ var CollapsibleTabView = forwardRef3(
|
|
|
409
499
|
],
|
|
410
500
|
pointerEvents: "box-none"
|
|
411
501
|
},
|
|
412
|
-
/* @__PURE__ */
|
|
413
|
-
/* @__PURE__ */
|
|
502
|
+
/* @__PURE__ */ React4.createElement(View3, { pointerEvents: "box-none", onLayout: handleHeaderLayout }, renderHeader()),
|
|
503
|
+
/* @__PURE__ */ React4.createElement(View3, { onLayout: handleTabBarLayout }, renderTabBarNode())
|
|
414
504
|
)));
|
|
415
505
|
}
|
|
416
506
|
);
|
|
@@ -439,5 +529,6 @@ var index_default = CollapsibleTabView;
|
|
|
439
529
|
export {
|
|
440
530
|
TabFlatList,
|
|
441
531
|
TabScrollView,
|
|
532
|
+
TabSectionList,
|
|
442
533
|
index_default as default
|
|
443
534
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NativeScrollEvent, NativeSyntheticEvent, SectionList, SectionListProps } from "react-native";
|
|
3
|
+
export type TabSectionListProps<T = any> = Omit<SectionListProps<T>, "onScroll"> & {
|
|
4
|
+
onScroll?: (e: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const TabSectionList: <T>(props: TabSectionListProps<T> & {
|
|
7
|
+
ref?: React.Ref<SectionList<T>>;
|
|
8
|
+
}) => React.ReactElement;
|
|
9
|
+
//# sourceMappingURL=TabSectionList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabSectionList.d.ts","sourceRoot":"","sources":["../../src/TabSectionList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAA;AACd,OAAO,EAGL,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAEjB,MAAM,cAAc,CAAA;AAUrB,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG;IACjF,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;CAChE,CAAA;AA0FD,eAAO,MAAM,cAAc,EAAsC,CAAC,CAAC,EACjE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,YAAY,CAAA"}
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { CollapsibleTabViewProps, CollapsibleTabViewRef } from "./types";
|
|
3
3
|
export { TabFlatList } from "./TabFlatList";
|
|
4
4
|
export { TabScrollView } from "./TabScrollView";
|
|
5
|
+
export { TabSectionList } from "./TabSectionList";
|
|
5
6
|
export type { CollapsibleTabViewProps, CollapsibleTabViewRef, TabBarProps, } from "./types";
|
|
6
7
|
declare const CollapsibleTabView: React.ForwardRefExoticComponent<CollapsibleTabViewProps & React.RefAttributes<CollapsibleTabViewRef>>;
|
|
7
8
|
export default CollapsibleTabView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAaf,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACrB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAaf,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACrB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,kBAAkB,uGA0TvB,CAAC;AAwBF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Animated, FlatList, ScrollView, StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { Animated, FlatList, ScrollView, SectionList, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
export interface TabBarProps {
|
|
4
4
|
activeIndex: number;
|
|
5
5
|
onTabPress: (index: number) => void;
|
|
@@ -30,7 +30,7 @@ export interface CollapsibleContextValue {
|
|
|
30
30
|
tabBarHeight: number;
|
|
31
31
|
renderHeader?: () => React.ReactNode;
|
|
32
32
|
renderTabBar?: () => React.ReactNode;
|
|
33
|
-
registerRef: (index: number, ref: FlatList<any> | ScrollView | null) => void;
|
|
33
|
+
registerRef: (index: number, ref: FlatList<any> | SectionList<any> | ScrollView | null) => void;
|
|
34
34
|
syncScrollY: (index: number, y: number) => void;
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEhG,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAA;IACrD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACxD,cAAc,EAAE,MAAM,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACpC,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/F,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAChD"}
|
package/package.json
CHANGED
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEnF,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAA;IACrD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACxD,cAAc,EAAE,MAAM,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACpC,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAA;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,UAAU,GAAG,IAAI,KAAK,IAAI,CAAA;IAC5E,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAChD"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|