react-native-tab-view 3.1.0 → 3.2.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.
- package/README.md +9 -1
- package/lib/commonjs/Pager.android.js.map +1 -1
- package/lib/commonjs/Pager.ios.js.map +1 -1
- package/lib/commonjs/Pager.js.map +1 -1
- package/lib/commonjs/PagerViewAdapter.js +17 -15
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +20 -16
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/PlatformPressable.js +19 -15
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/SceneMap.js +14 -11
- package/lib/commonjs/SceneMap.js.map +1 -1
- package/lib/commonjs/SceneView.js +2 -2
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +124 -81
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +7 -6
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +7 -6
- package/lib/commonjs/TabBarItem.js.map +1 -1
- package/lib/commonjs/TabView.js +40 -33
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/commonjs/index.js +6 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useAnimatedValue.js.map +1 -1
- package/lib/module/Pager.android.js.map +1 -1
- package/lib/module/Pager.ios.js.map +1 -1
- package/lib/module/Pager.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +17 -15
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +20 -16
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/PlatformPressable.js +19 -15
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SceneMap.js +14 -11
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +2 -2
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +125 -81
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +7 -6
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +7 -6
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabView.js +39 -32
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useAnimatedValue.js.map +1 -1
- package/lib/typescript/TabBar.d.ts +3 -1
- package/lib/typescript/TabBarIndicator.d.ts +1 -0
- package/lib/typescript/TabView.d.ts +2 -1
- package/package.json +20 -19
- package/src/TabBar.tsx +75 -31
- package/src/TabBarIndicator.tsx +14 -5
- package/src/TabView.tsx +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","View","StyleSheet","SceneView","Component","loading","Math","abs","props","navigationState","index","lazyPreloadDistance","value","setState","prevState","getDerivedStateFromProps","state","componentDidMount","lazy","unsubscribe","addEnterListener","handleEnter","timerHandler","setTimeout","componentDidUpdate","prevProps","componentWillUnmount","clearTimeout","undefined","render","layout","style","focused","styles","route","width","absoluteFill","children","create","flex","overflow"],"sources":["SceneView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport type {\n SceneRendererProps,\n EventEmitterProps,\n NavigationState,\n Route,\n} from './types';\n\ntype Props<T extends Route> = SceneRendererProps &\n EventEmitterProps & {\n navigationState: NavigationState<T>;\n lazy: boolean;\n lazyPreloadDistance: number;\n index: number;\n children: (props: { loading: boolean }) => React.ReactNode;\n style?: StyleProp<ViewStyle>;\n };\n\ntype State = {\n loading: boolean;\n};\n\nexport default class SceneView<T extends Route> extends React.Component<\n Props<T>,\n State\n> {\n static getDerivedStateFromProps(props: Props<Route>, state: State) {\n if (\n state.loading &&\n Math.abs(props.navigationState.index - props.index) <=\n props.lazyPreloadDistance\n ) {\n // Always render the route when it becomes focused\n return { loading: false };\n }\n\n return null;\n }\n\n state = {\n loading:\n Math.abs(this.props.navigationState.index - this.props.index) >\n this.props.lazyPreloadDistance,\n };\n\n componentDidMount() {\n if (this.props.lazy) {\n // If lazy mode is enabled, listen to when we enter screens\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else if (this.state.loading) {\n // If lazy mode is not enabled, render the scene with a delay if not loaded already\n // This improves the initial startup time as the scene is no longer blocking\n this.timerHandler = setTimeout(\n () => this.setState({ loading: false }),\n 0\n );\n }\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (\n this.props.lazy !== prevProps.lazy ||\n this.state.loading !== prevState.loading\n ) {\n // We only need the listener if the tab hasn't loaded yet and lazy is enabled\n if (this.props.lazy && this.state.loading) {\n this.unsubscribe?.();\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else {\n this.unsubscribe?.();\n }\n }\n }\n\n componentWillUnmount() {\n this.unsubscribe?.();\n\n if (this.timerHandler) {\n clearTimeout(this.timerHandler);\n this.timerHandler = undefined;\n }\n }\n\n private timerHandler: NodeJS.Timeout | undefined;\n\n private unsubscribe: (() => void) | null = null;\n\n private handleEnter = (value: number) => {\n const { index } = this.props;\n\n // If we're entering the current route, we need to load it\n if (value === index) {\n this.setState((prevState) => {\n if (prevState.loading) {\n return { loading: false };\n }\n\n return null;\n });\n }\n };\n\n render() {\n const { navigationState, index, layout, style } = this.props;\n const { loading } = this.state;\n\n const focused = navigationState.index === index;\n\n return (\n <View\n accessibilityElementsHidden={!focused}\n importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}\n style={[\n styles.route,\n // If we don't have the layout yet, make the focused screen fill the container\n // This avoids delay before we are able to render pages side by side\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null,\n style,\n ]}\n >\n {\n // Only render the route only if it's either focused or layout is available\n // When layout is not available, we must not render unfocused routes\n // so that the focused route can fill the screen\n focused || layout.width ? this.props.children({ loading }) : null\n }\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n route: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAuD,cAAvD;AAsBA,eAAe,MAAMC,SAAN,SAAyCH,KAAK,CAACI,SAA/C,CAGb;EAAA;IAAA;;IAAA,+BAcQ;MACNC,OAAO,EACLC,IAAI,CAACC,GAAL,CAAS,KAAKC,KAAL,CAAWC,eAAX,CAA2BC,KAA3B,GAAmC,KAAKF,KAAL,CAAWE,KAAvD,IACA,KAAKF,KAAL,CAAWG;IAHP,CAdR;;IAAA;;IAAA,qCA4D2C,IA5D3C;;IAAA,qCA8DuBC,KAAD,IAAmB;MACvC,MAAM;QAAEF;MAAF,IAAY,KAAKF,KAAvB,CADuC,CAGvC;;MACA,IAAII,KAAK,KAAKF,KAAd,EAAqB;QACnB,KAAKG,QAAL,CAAeC,SAAD,IAAe;UAC3B,IAAIA,SAAS,CAACT,OAAd,EAAuB;YACrB,OAAO;cAAEA,OAAO,EAAE;YAAX,CAAP;UACD;;UAED,OAAO,IAAP;QACD,CAND;MAOD;IACF,CA3ED;EAAA;;EAC+B,OAAxBU,wBAAwB,CAACP,KAAD,EAAsBQ,KAAtB,EAAoC;IACjE,IACEA,KAAK,CAACX,OAAN,IACAC,IAAI,CAACC,GAAL,CAASC,KAAK,CAACC,eAAN,CAAsBC,KAAtB,GAA8BF,KAAK,CAACE,KAA7C,KACEF,KAAK,CAACG,mBAHV,EAIE;MACA;MACA,OAAO;QAAEN,OAAO,EAAE;MAAX,CAAP;IACD;;IAED,OAAO,IAAP;EACD;;EAQDY,iBAAiB,GAAG;IAClB,IAAI,KAAKT,KAAL,CAAWU,IAAf,EAAqB;MACnB;MACA,KAAKC,WAAL,GAAmB,K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KADF,EAEL;MACA;MACAJ,MAAM,CAACK,KAAP,GACI;QAAEA,KAAK,EAAEL,MAAM,CAACK;MAAhB,CADJ,GAEIH,OAAO,GACP9B,UAAU,CAACkC,YADJ,GAEP,IARC,EASLL,KATK;IAHT,GAgBI;IACA;IACA;IACAC,OAAO,IAAIF,MAAM,CAACK,KAAlB,GAA0B,KAAK3B,KAAL,CAAW6B,QAAX,CAAoB;MAAEhC;IAAF,CAApB,CAA1B,GAA6D,IAnBjE,CADF;EAwBD;;AA3GD;AA8GF,MAAM4B,MAAM,GAAG/B,UAAU,CAACoC,MAAX,CAAkB;EAC/BJ,KAAK,EAAE;IACLK,IAAI,EAAE,CADD;IAELC,QAAQ,EAAE;EAFL;AADwB,CAAlB,CAAf"}
|
package/lib/module/TabBar.js
CHANGED
|
@@ -4,9 +4,21 @@ import * as React from 'react';
|
|
|
4
4
|
import { Animated, StyleSheet, View, I18nManager, Platform } from 'react-native';
|
|
5
5
|
import TabBarItem from './TabBarItem';
|
|
6
6
|
import TabBarIndicator from './TabBarIndicator';
|
|
7
|
+
|
|
8
|
+
const Separator = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
width
|
|
11
|
+
} = _ref;
|
|
12
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
13
|
+
style: {
|
|
14
|
+
width
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
7
19
|
export default class TabBar extends React.Component {
|
|
8
|
-
constructor(
|
|
9
|
-
super(...
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
10
22
|
|
|
11
23
|
_defineProperty(this, "state", {
|
|
12
24
|
layout: {
|
|
@@ -20,7 +32,7 @@ export default class TabBar extends React.Component {
|
|
|
20
32
|
|
|
21
33
|
_defineProperty(this, "scrollAmount", new Animated.Value(0));
|
|
22
34
|
|
|
23
|
-
_defineProperty(this, "
|
|
35
|
+
_defineProperty(this, "flatListRef", /*#__PURE__*/React.createRef());
|
|
24
36
|
|
|
25
37
|
_defineProperty(this, "getFlattenedTabWidth", style => {
|
|
26
38
|
const tabStyle = StyleSheet.flatten(style);
|
|
@@ -68,7 +80,7 @@ export default class TabBar extends React.Component {
|
|
|
68
80
|
const {
|
|
69
81
|
routes
|
|
70
82
|
} = props.navigationState;
|
|
71
|
-
return routes.reduce((acc, _, i) => acc + this.getComputedTabWidth(i, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle)), 0);
|
|
83
|
+
return routes.reduce((acc, _, i) => acc + (i > 0 ? props.gap ?? 0 : 0) + this.getComputedTabWidth(i, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle)), 0);
|
|
72
84
|
});
|
|
73
85
|
|
|
74
86
|
_defineProperty(this, "normalizeScrollValue", (props, state, value) => {
|
|
@@ -106,7 +118,7 @@ export default class TabBar extends React.Component {
|
|
|
106
118
|
const tabWidth = this.getComputedTabWidth(i, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle)); // To get the current index centered we adjust scroll amount by width of indexes
|
|
107
119
|
// 0 through (i - 1) and add half the width of current index i
|
|
108
120
|
|
|
109
|
-
return total + (index === i ? tabWidth / 2 : tabWidth);
|
|
121
|
+
return total + (index === i ? (tabWidth + (props.gap ?? 0)) / 2 : tabWidth + (props.gap ?? 0));
|
|
110
122
|
}, 0);
|
|
111
123
|
const scrollAmount = centerDistance - layout.width / 2;
|
|
112
124
|
return this.normalizeScrollValue(props, state, scrollAmount);
|
|
@@ -114,10 +126,10 @@ export default class TabBar extends React.Component {
|
|
|
114
126
|
|
|
115
127
|
_defineProperty(this, "resetScroll", index => {
|
|
116
128
|
if (this.props.scrollEnabled) {
|
|
117
|
-
var _this$
|
|
129
|
+
var _this$flatListRef$cur;
|
|
118
130
|
|
|
119
|
-
(_this$
|
|
120
|
-
|
|
131
|
+
(_this$flatListRef$cur = this.flatListRef.current) === null || _this$flatListRef$cur === void 0 ? void 0 : _this$flatListRef$cur.scrollToOffset({
|
|
132
|
+
offset: this.getScrollAmount(this.props, this.state, index),
|
|
121
133
|
animated: true
|
|
122
134
|
});
|
|
123
135
|
}
|
|
@@ -191,7 +203,8 @@ export default class TabBar extends React.Component {
|
|
|
191
203
|
indicatorStyle,
|
|
192
204
|
contentContainerStyle,
|
|
193
205
|
style,
|
|
194
|
-
indicatorContainerStyle
|
|
206
|
+
indicatorContainerStyle,
|
|
207
|
+
gap = 0
|
|
195
208
|
} = this.props;
|
|
196
209
|
const {
|
|
197
210
|
layout,
|
|
@@ -202,6 +215,8 @@ export default class TabBar extends React.Component {
|
|
|
202
215
|
} = navigationState;
|
|
203
216
|
const isWidthDynamic = this.getFlattenedTabWidth(tabStyle) === 'auto';
|
|
204
217
|
const tabBarWidth = this.getTabBarWidth(this.props, this.state);
|
|
218
|
+
const separatorsWidth = Math.max(0, routes.length - 1) * gap;
|
|
219
|
+
const separatorPercent = separatorsWidth / tabBarWidth * 100;
|
|
205
220
|
const tabBarWidthPercent = `${routes.length * 40}%`;
|
|
206
221
|
const translateX = this.getTranslateX(this.scrollAmount, this.getMaxScrollDistance(tabBarWidth, layout.width));
|
|
207
222
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
@@ -213,8 +228,8 @@ export default class TabBar extends React.Component {
|
|
|
213
228
|
transform: [{
|
|
214
229
|
translateX
|
|
215
230
|
}]
|
|
216
|
-
} : null, tabBarWidth ? {
|
|
217
|
-
width: tabBarWidth
|
|
231
|
+
} : null, tabBarWidth > separatorsWidth ? {
|
|
232
|
+
width: tabBarWidth - separatorsWidth
|
|
218
233
|
} : scrollEnabled ? {
|
|
219
234
|
width: tabBarWidthPercent
|
|
220
235
|
} : null, indicatorContainerStyle]
|
|
@@ -223,12 +238,15 @@ export default class TabBar extends React.Component {
|
|
|
223
238
|
layout,
|
|
224
239
|
navigationState,
|
|
225
240
|
jumpTo,
|
|
226
|
-
width: isWidthDynamic ? 'auto' : `${100 / routes.length}%`,
|
|
241
|
+
width: isWidthDynamic ? 'auto' : `${(100 - separatorPercent) / routes.length}%`,
|
|
227
242
|
style: indicatorStyle,
|
|
228
|
-
getTabWidth: i => this.getComputedTabWidth(i, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle))
|
|
243
|
+
getTabWidth: i => this.getComputedTabWidth(i, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle)),
|
|
244
|
+
gap
|
|
229
245
|
})), /*#__PURE__*/React.createElement(View, {
|
|
230
246
|
style: styles.scroll
|
|
231
|
-
}, /*#__PURE__*/React.createElement(Animated.
|
|
247
|
+
}, /*#__PURE__*/React.createElement(Animated.FlatList, {
|
|
248
|
+
data: routes,
|
|
249
|
+
keyExtractor: item => item.key,
|
|
232
250
|
horizontal: true,
|
|
233
251
|
accessibilityRole: "tablist",
|
|
234
252
|
keyboardShouldPersistTaps: "handled",
|
|
@@ -237,12 +255,76 @@ export default class TabBar extends React.Component {
|
|
|
237
255
|
alwaysBounceHorizontal: false,
|
|
238
256
|
scrollsToTop: false,
|
|
239
257
|
showsHorizontalScrollIndicator: false,
|
|
258
|
+
showsVerticalScrollIndicator: false,
|
|
240
259
|
automaticallyAdjustContentInsets: false,
|
|
241
260
|
overScrollMode: "never",
|
|
242
261
|
contentContainerStyle: [styles.tabContent, scrollEnabled ? {
|
|
243
|
-
width: tabBarWidth
|
|
262
|
+
width: tabBarWidth > separatorsWidth ? tabBarWidth : tabBarWidthPercent
|
|
244
263
|
} : styles.container, contentContainerStyle],
|
|
245
264
|
scrollEventThrottle: 16,
|
|
265
|
+
renderItem: _ref2 => {
|
|
266
|
+
let {
|
|
267
|
+
item: route,
|
|
268
|
+
index
|
|
269
|
+
} = _ref2;
|
|
270
|
+
const props = {
|
|
271
|
+
key: route.key,
|
|
272
|
+
position: position,
|
|
273
|
+
route: route,
|
|
274
|
+
navigationState: navigationState,
|
|
275
|
+
getAccessibilityLabel: getAccessibilityLabel,
|
|
276
|
+
getAccessible: getAccessible,
|
|
277
|
+
getLabelText: getLabelText,
|
|
278
|
+
getTestID: getTestID,
|
|
279
|
+
renderBadge: renderBadge,
|
|
280
|
+
renderIcon: renderIcon,
|
|
281
|
+
renderLabel: renderLabel,
|
|
282
|
+
activeColor: activeColor,
|
|
283
|
+
inactiveColor: inactiveColor,
|
|
284
|
+
pressColor: pressColor,
|
|
285
|
+
pressOpacity: pressOpacity,
|
|
286
|
+
onLayout: isWidthDynamic ? e => {
|
|
287
|
+
this.measuredTabWidths[route.key] = e.nativeEvent.layout.width; // When we have measured widths for all of the tabs, we should updates the state
|
|
288
|
+
// We avoid doing separate setState for each layout since it triggers multiple renders and slows down app
|
|
289
|
+
|
|
290
|
+
if (routes.every(r => typeof this.measuredTabWidths[r.key] === 'number')) {
|
|
291
|
+
this.setState({
|
|
292
|
+
tabWidths: { ...this.measuredTabWidths
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
} : undefined,
|
|
297
|
+
onPress: () => {
|
|
298
|
+
const event = {
|
|
299
|
+
route,
|
|
300
|
+
defaultPrevented: false,
|
|
301
|
+
preventDefault: () => {
|
|
302
|
+
event.defaultPrevented = true;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
onTabPress === null || onTabPress === void 0 ? void 0 : onTabPress(event);
|
|
306
|
+
|
|
307
|
+
if (event.defaultPrevented) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.props.jumpTo(route.key);
|
|
312
|
+
},
|
|
313
|
+
onLongPress: () => onTabLongPress === null || onTabLongPress === void 0 ? void 0 : onTabLongPress({
|
|
314
|
+
route
|
|
315
|
+
}),
|
|
316
|
+
labelStyle: labelStyle,
|
|
317
|
+
style: [tabStyle, // Calculate the deafult width for tab for FlatList to work.
|
|
318
|
+
this.getFlattenedTabWidth(tabStyle) === undefined && {
|
|
319
|
+
width: this.getComputedTabWidth(index, layout, routes, scrollEnabled, tabWidths, this.getFlattenedTabWidth(tabStyle))
|
|
320
|
+
}]
|
|
321
|
+
};
|
|
322
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
323
|
+
key: route.key
|
|
324
|
+
}, gap > 0 && index > 0 ? /*#__PURE__*/React.createElement(Separator, {
|
|
325
|
+
width: gap
|
|
326
|
+
}) : null, renderTabBarItem ? renderTabBarItem(props) : /*#__PURE__*/React.createElement(TabBarItem, props));
|
|
327
|
+
},
|
|
246
328
|
onScroll: Animated.event([{
|
|
247
329
|
nativeEvent: {
|
|
248
330
|
contentOffset: {
|
|
@@ -252,77 +334,39 @@ export default class TabBar extends React.Component {
|
|
|
252
334
|
}], {
|
|
253
335
|
useNativeDriver: true
|
|
254
336
|
}),
|
|
255
|
-
ref: this.
|
|
256
|
-
}
|
|
257
|
-
const props = {
|
|
258
|
-
key: route.key,
|
|
259
|
-
position: position,
|
|
260
|
-
route: route,
|
|
261
|
-
navigationState: navigationState,
|
|
262
|
-
getAccessibilityLabel: getAccessibilityLabel,
|
|
263
|
-
getAccessible: getAccessible,
|
|
264
|
-
getLabelText: getLabelText,
|
|
265
|
-
getTestID: getTestID,
|
|
266
|
-
renderBadge: renderBadge,
|
|
267
|
-
renderIcon: renderIcon,
|
|
268
|
-
renderLabel: renderLabel,
|
|
269
|
-
activeColor: activeColor,
|
|
270
|
-
inactiveColor: inactiveColor,
|
|
271
|
-
pressColor: pressColor,
|
|
272
|
-
pressOpacity: pressOpacity,
|
|
273
|
-
onLayout: isWidthDynamic ? e => {
|
|
274
|
-
this.measuredTabWidths[route.key] = e.nativeEvent.layout.width; // When we have measured widths for all of the tabs, we should updates the state
|
|
275
|
-
// We avoid doing separate setState for each layout since it triggers multiple renders and slows down app
|
|
276
|
-
|
|
277
|
-
if (routes.every(r => typeof this.measuredTabWidths[r.key] === 'number')) {
|
|
278
|
-
this.setState({
|
|
279
|
-
tabWidths: { ...this.measuredTabWidths
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
} : undefined,
|
|
284
|
-
onPress: () => {
|
|
285
|
-
const event = {
|
|
286
|
-
route,
|
|
287
|
-
defaultPrevented: false,
|
|
288
|
-
preventDefault: () => {
|
|
289
|
-
event.defaultPrevented = true;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
onTabPress === null || onTabPress === void 0 ? void 0 : onTabPress(event);
|
|
293
|
-
|
|
294
|
-
if (event.defaultPrevented) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.props.jumpTo(route.key);
|
|
299
|
-
},
|
|
300
|
-
onLongPress: () => onTabLongPress === null || onTabLongPress === void 0 ? void 0 : onTabLongPress({
|
|
301
|
-
route
|
|
302
|
-
}),
|
|
303
|
-
labelStyle: labelStyle,
|
|
304
|
-
style: tabStyle
|
|
305
|
-
};
|
|
306
|
-
return renderTabBarItem ? renderTabBarItem(props) : /*#__PURE__*/React.createElement(TabBarItem, props);
|
|
307
|
-
}))));
|
|
337
|
+
ref: this.flatListRef
|
|
338
|
+
})));
|
|
308
339
|
}
|
|
309
340
|
|
|
310
341
|
}
|
|
311
342
|
|
|
312
343
|
_defineProperty(TabBar, "defaultProps", {
|
|
313
|
-
getLabelText:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
route
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
route
|
|
324
|
-
}
|
|
325
|
-
|
|
344
|
+
getLabelText: _ref3 => {
|
|
345
|
+
let {
|
|
346
|
+
route
|
|
347
|
+
} = _ref3;
|
|
348
|
+
return route.title;
|
|
349
|
+
},
|
|
350
|
+
getAccessible: _ref4 => {
|
|
351
|
+
let {
|
|
352
|
+
route
|
|
353
|
+
} = _ref4;
|
|
354
|
+
return typeof route.accessible !== 'undefined' ? route.accessible : true;
|
|
355
|
+
},
|
|
356
|
+
getAccessibilityLabel: _ref5 => {
|
|
357
|
+
let {
|
|
358
|
+
route
|
|
359
|
+
} = _ref5;
|
|
360
|
+
return typeof route.accessibilityLabel === 'string' ? route.accessibilityLabel : typeof route.title === 'string' ? route.title : undefined;
|
|
361
|
+
},
|
|
362
|
+
getTestID: _ref6 => {
|
|
363
|
+
let {
|
|
364
|
+
route
|
|
365
|
+
} = _ref6;
|
|
366
|
+
return route.testID;
|
|
367
|
+
},
|
|
368
|
+
renderIndicator: props => /*#__PURE__*/React.createElement(TabBarIndicator, props),
|
|
369
|
+
gap: 0
|
|
326
370
|
});
|
|
327
371
|
|
|
328
372
|
const styles = StyleSheet.create({
|
package/lib/module/TabBar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TabBar.tsx"],"names":["React","Animated","StyleSheet","View","I18nManager","Platform","TabBarItem","TabBarIndicator","TabBar","Component","layout","width","height","tabWidths","Value","createRef","style","tabStyle","flatten","undefined","index","routes","scrollEnabled","flattenedWidth","key","endsWith","parseFloat","Number","isFinite","length","tabBarWidth","layoutWidth","props","state","navigationState","reduce","acc","_","i","getComputedTabWidth","getFlattenedTabWidth","value","getTabBarWidth","maxDistance","getMaxScrollDistance","scrollValue","Math","max","min","OS","isRTL","centerDistance","Array","from","total","tabWidth","scrollAmount","normalizeScrollValue","scrollViewRef","current","scrollTo","x","getScrollAmount","animated","e","nativeEvent","setState","maxScrollDistance","multiply","add","componentDidUpdate","prevProps","prevState","every","r","resetScroll","render","position","jumpTo","bounces","getAccessibilityLabel","getAccessible","getLabelText","getTestID","renderBadge","renderIcon","renderLabel","renderTabBarItem","activeColor","inactiveColor","pressColor","pressOpacity","onTabPress","onTabLongPress","labelStyle","indicatorStyle","contentContainerStyle","indicatorContainerStyle","isWidthDynamic","tabBarWidthPercent","translateX","getTranslateX","handleLayout","styles","tabBar","indicatorContainer","transform","renderIndicator","getTabWidth","scroll","tabContent","container","event","contentOffset","useNativeDriver","map","route","onLayout","measuredTabWidths","onPress","defaultPrevented","preventDefault","onLongPress","title","accessible","accessibilityLabel","testID","create","flex","overflow","select","default","web","backgroundColor","elevation","shadowColor","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AAAA,IAAI,EAAE;AADG,GADoB;AAI/BnB,EAAAA,MAAM,EAAE;AACNoB,IAAAA,QAAQ,EAAE5H,QAAQ,CAAC6H,MAAT,CAAgB;AAAEC,MAAAA,OAAO,EAAE,QAAX;AAAqBC,MAAAA,GAAG,EAAEjH;AAA1B,KAAhB;AADJ,GAJuB;AAO/BqF,EAAAA,MAAM,EAAE;AACN6B,IAAAA,eAAe,EAAE,SADX;AAENC,IAAAA,SAAS,EAAE,CAFL;AAGNC,IAAAA,WAAW,EAAE,OAHP;AAINC,IAAAA,aAAa,EAAE,GAJT;AAKNC,IAAAA,YAAY,EAAEvI,UAAU,CAACwI,aALnB;AAMNC,IAAAA,YAAY,EAAE;AACZ/H,MAAAA,MAAM,EAAEV,UAAU,CAACwI,aADP;AAEZ/H,MAAAA,KAAK,EAAE;AAFK,KANR;AAUNiI,IAAAA,MAAM,EAAE;AAVF,GAPuB;AAmB/B9B,EAAAA,UAAU,EAAE;AACV+B,IAAAA,aAAa,EAAE,KADL;AAEVC,IAAAA,QAAQ,EAAE;AAFA,GAnBmB;AAuB/BrC,EAAAA,kBAAkB,EAAE;AAClB5B,IAAAA,QAAQ,EAAE,UADQ;AAElBkE,IAAAA,GAAG,EAAE,CAFa;AAGlBC,IAAAA,IAAI,EAAE,CAHY;AAIlBC,IAAAA,KAAK,EAAE,CAJW;AAKlBC,IAAAA,MAAM,EAAE;AALU;AAvBW,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n ScrollView,\n StyleProp,\n ViewStyle,\n TextStyle,\n LayoutChangeEvent,\n I18nManager,\n Platform,\n} from 'react-native';\nimport TabBarItem, { Props as TabBarItemProps } from './TabBarItem';\nimport TabBarIndicator, { Props as IndicatorProps } from './TabBarIndicator';\nimport type {\n Route,\n Scene,\n SceneRendererProps,\n NavigationState,\n Layout,\n Event,\n} from './types';\n\nexport type Props<T extends Route> = SceneRendererProps & {\n navigationState: NavigationState<T>;\n scrollEnabled?: boolean;\n bounces?: boolean;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (\n scene: Scene<T> & {\n focused: boolean;\n color: string;\n }\n ) => React.ReactNode;\n renderIcon?: (\n scene: Scene<T> & {\n focused: boolean;\n color: string;\n }\n ) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n renderIndicator: (props: IndicatorProps<T>) => React.ReactNode;\n renderTabBarItem?: (\n props: TabBarItemProps<T> & { key: string }\n ) => React.ReactElement;\n onTabPress?: (scene: Scene<T> & Event) => void;\n onTabLongPress?: (scene: Scene<T>) => void;\n tabStyle?: StyleProp<ViewStyle>;\n indicatorStyle?: StyleProp<ViewStyle>;\n indicatorContainerStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n contentContainerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\ntype State = {\n layout: Layout;\n tabWidths: { [key: string]: number };\n};\n\nexport default class TabBar<T extends Route> extends React.Component<\n Props<T>,\n State\n> {\n static defaultProps = {\n getLabelText: ({ route }: Scene<Route>) => route.title,\n getAccessible: ({ route }: Scene<Route>) =>\n typeof route.accessible !== 'undefined' ? route.accessible : true,\n getAccessibilityLabel: ({ route }: Scene<Route>) =>\n typeof route.accessibilityLabel === 'string'\n ? route.accessibilityLabel\n : typeof route.title === 'string'\n ? route.title\n : undefined,\n getTestID: ({ route }: Scene<Route>) => route.testID,\n renderIndicator: (props: IndicatorProps<Route>) => (\n <TabBarIndicator {...props} />\n ),\n };\n\n state: State = {\n layout: { width: 0, height: 0 },\n tabWidths: {},\n };\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n const { navigationState } = this.props;\n const { layout, tabWidths } = this.state;\n\n if (\n prevProps.navigationState.routes.length !==\n navigationState.routes.length ||\n prevProps.navigationState.index !== navigationState.index ||\n prevState.layout.width !== layout.width ||\n prevState.tabWidths !== tabWidths\n ) {\n if (\n this.getFlattenedTabWidth(this.props.tabStyle) === 'auto' &&\n !(\n layout.width &&\n navigationState.routes.every(\n (r) => typeof tabWidths[r.key] === 'number'\n )\n )\n ) {\n // When tab width is dynamic, only adjust the scroll once we have all tab widths and layout\n return;\n }\n\n this.resetScroll(navigationState.index);\n }\n }\n\n // to store the layout.width of each tab\n // when all onLayout's are fired, this would be set in state\n private measuredTabWidths: { [key: string]: number } = {};\n\n private scrollAmount = new Animated.Value(0);\n\n private scrollViewRef = React.createRef<ScrollView>();\n\n private getFlattenedTabWidth = (style: StyleProp<ViewStyle>) => {\n const tabStyle = StyleSheet.flatten(style);\n\n return tabStyle ? tabStyle.width : undefined;\n };\n\n private getComputedTabWidth = (\n index: number,\n layout: Layout,\n routes: Route[],\n scrollEnabled: boolean | undefined,\n tabWidths: { [key: string]: number },\n flattenedWidth: string | number | undefined\n ) => {\n if (flattenedWidth === 'auto') {\n return tabWidths[routes[index].key] || 0;\n }\n\n switch (typeof flattenedWidth) {\n case 'number':\n return flattenedWidth;\n case 'string':\n if (flattenedWidth.endsWith('%')) {\n const width = parseFloat(flattenedWidth);\n if (Number.isFinite(width)) {\n return layout.width * (width / 100);\n }\n }\n }\n\n if (scrollEnabled) {\n return (layout.width / 5) * 2;\n }\n\n return layout.width / routes.length;\n };\n\n private getMaxScrollDistance = (tabBarWidth: number, layoutWidth: number) =>\n tabBarWidth - layoutWidth;\n\n private getTabBarWidth = (props: Props<T>, state: State) => {\n const { layout, tabWidths } = state;\n const { scrollEnabled, tabStyle } = props;\n const { routes } = props.navigationState;\n\n return routes.reduce<number>(\n (acc, _, i) =>\n acc +\n this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n ),\n 0\n );\n };\n\n private normalizeScrollValue = (\n props: Props<T>,\n state: State,\n value: number\n ) => {\n const { layout } = state;\n const tabBarWidth = this.getTabBarWidth(props, state);\n const maxDistance = this.getMaxScrollDistance(tabBarWidth, layout.width);\n const scrollValue = Math.max(Math.min(value, maxDistance), 0);\n\n if (Platform.OS === 'android' && I18nManager.isRTL) {\n // On Android, scroll value is not applied in reverse in RTL\n // so we need to manually adjust it to apply correct value\n return maxDistance - scrollValue;\n }\n\n return scrollValue;\n };\n\n private getScrollAmount = (props: Props<T>, state: State, index: number) => {\n const { layout, tabWidths } = state;\n const { scrollEnabled, tabStyle } = props;\n const { routes } = props.navigationState;\n\n const centerDistance = Array.from({ length: index + 1 }).reduce<number>(\n (total, _, i) => {\n const tabWidth = this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n );\n\n // To get the current index centered we adjust scroll amount by width of indexes\n // 0 through (i - 1) and add half the width of current index i\n return total + (index === i ? tabWidth / 2 : tabWidth);\n },\n 0\n );\n\n const scrollAmount = centerDistance - layout.width / 2;\n\n return this.normalizeScrollValue(props, state, scrollAmount);\n };\n\n private resetScroll = (index: number) => {\n if (this.props.scrollEnabled) {\n this.scrollViewRef.current?.scrollTo({\n x: this.getScrollAmount(this.props, this.state, index),\n animated: true,\n });\n }\n };\n\n private handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n if (\n this.state.layout.width === width &&\n this.state.layout.height === height\n ) {\n return;\n }\n\n this.setState({\n layout: {\n height,\n width,\n },\n });\n };\n\n private getTranslateX = (\n scrollAmount: Animated.Value,\n maxScrollDistance: number\n ) =>\n Animated.multiply(\n Platform.OS === 'android' && I18nManager.isRTL\n ? Animated.add(maxScrollDistance, Animated.multiply(scrollAmount, -1))\n : scrollAmount,\n I18nManager.isRTL ? 1 : -1\n );\n\n render() {\n const {\n position,\n navigationState,\n jumpTo,\n scrollEnabled,\n bounces,\n getAccessibilityLabel,\n getAccessible,\n getLabelText,\n getTestID,\n renderBadge,\n renderIcon,\n renderLabel,\n renderTabBarItem,\n activeColor,\n inactiveColor,\n pressColor,\n pressOpacity,\n onTabPress,\n onTabLongPress,\n tabStyle,\n labelStyle,\n indicatorStyle,\n contentContainerStyle,\n style,\n indicatorContainerStyle,\n } = this.props;\n const { layout, tabWidths } = this.state;\n const { routes } = navigationState;\n\n const isWidthDynamic = this.getFlattenedTabWidth(tabStyle) === 'auto';\n const tabBarWidth = this.getTabBarWidth(this.props, this.state);\n const tabBarWidthPercent = `${routes.length * 40}%`;\n const translateX = this.getTranslateX(\n this.scrollAmount,\n this.getMaxScrollDistance(tabBarWidth, layout.width)\n );\n\n return (\n <Animated.View\n onLayout={this.handleLayout}\n style={[styles.tabBar, style]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.indicatorContainer,\n scrollEnabled ? { transform: [{ translateX }] as any } : null,\n tabBarWidth\n ? { width: tabBarWidth }\n : scrollEnabled\n ? { width: tabBarWidthPercent }\n : null,\n indicatorContainerStyle,\n ]}\n >\n {this.props.renderIndicator({\n position,\n layout,\n navigationState,\n jumpTo,\n width: isWidthDynamic ? 'auto' : `${100 / routes.length}%`,\n style: indicatorStyle,\n getTabWidth: (i: number) =>\n this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n ),\n })}\n </Animated.View>\n <View style={styles.scroll}>\n <Animated.ScrollView\n horizontal\n accessibilityRole=\"tablist\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEnabled={scrollEnabled}\n bounces={bounces}\n alwaysBounceHorizontal={false}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n automaticallyAdjustContentInsets={false}\n overScrollMode=\"never\"\n contentContainerStyle={[\n styles.tabContent,\n scrollEnabled\n ? { width: tabBarWidth || tabBarWidthPercent }\n : styles.container,\n contentContainerStyle,\n ]}\n scrollEventThrottle={16}\n onScroll={Animated.event(\n [\n {\n nativeEvent: {\n contentOffset: { x: this.scrollAmount },\n },\n },\n ],\n { useNativeDriver: true }\n )}\n ref={this.scrollViewRef}\n >\n {routes.map((route: T) => {\n const props: TabBarItemProps<T> & { key: string } = {\n key: route.key,\n position: position,\n route: route,\n navigationState: navigationState,\n getAccessibilityLabel: getAccessibilityLabel,\n getAccessible: getAccessible,\n getLabelText: getLabelText,\n getTestID: getTestID,\n renderBadge: renderBadge,\n renderIcon: renderIcon,\n renderLabel: renderLabel,\n activeColor: activeColor,\n inactiveColor: inactiveColor,\n pressColor: pressColor,\n pressOpacity: pressOpacity,\n onLayout: isWidthDynamic\n ? (e) => {\n this.measuredTabWidths[route.key] =\n e.nativeEvent.layout.width;\n\n // When we have measured widths for all of the tabs, we should updates the state\n // We avoid doing separate setState for each layout since it triggers multiple renders and slows down app\n if (\n routes.every(\n (r) =>\n typeof this.measuredTabWidths[r.key] === 'number'\n )\n ) {\n this.setState({\n tabWidths: { ...this.measuredTabWidths },\n });\n }\n }\n : undefined,\n onPress: () => {\n const event: Scene<T> & Event = {\n route,\n defaultPrevented: false,\n preventDefault: () => {\n event.defaultPrevented = true;\n },\n };\n\n onTabPress?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n this.props.jumpTo(route.key);\n },\n onLongPress: () => onTabLongPress?.({ route }),\n labelStyle: labelStyle,\n style: tabStyle,\n };\n\n return renderTabBarItem ? (\n renderTabBarItem(props)\n ) : (\n <TabBarItem {...props} />\n );\n })}\n </Animated.ScrollView>\n </View>\n </Animated.View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n scroll: {\n overflow: Platform.select({ default: 'scroll', web: undefined }),\n },\n tabBar: {\n backgroundColor: '#2196f3',\n elevation: 4,\n shadowColor: 'black',\n shadowOpacity: 0.1,\n shadowRadius: StyleSheet.hairlineWidth,\n shadowOffset: {\n height: StyleSheet.hairlineWidth,\n width: 0,\n },\n zIndex: 1,\n },\n tabContent: {\n flexDirection: 'row',\n flexWrap: 'nowrap',\n },\n indicatorContainer: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"names":["React","Animated","StyleSheet","View","I18nManager","Platform","TabBarItem","TabBarIndicator","Separator","width","TabBar","Component","layout","height","tabWidths","Value","createRef","style","tabStyle","flatten","undefined","index","routes","scrollEnabled","flattenedWidth","key","endsWith","parseFloat","Number","isFinite","length","tabBarWidth","layoutWidth","props","state","navigationState","reduce","acc","_","i","gap","getComputedTabWidth","getFlattenedTabWidth","value","getTabBarWidth","maxDistance","getMaxScrollDistance","scrollValue","Math","max","min","OS","isRTL","centerDistance","Array","from","total","tabWidth","scrollAmount","normalizeScrollValue","flatListRef","current","scrollToOffset","offset","getScrollAmount","animated","e","nativeEvent","setState","maxScrollDistance","multiply","add","componentDidUpdate","prevProps","prevState","every","r","resetScroll","render","position","jumpTo","bounces","getAccessibilityLabel","getAccessible","getLabelText","getTestID","renderBadge","renderIcon","renderLabel","renderTabBarItem","activeColor","inactiveColor","pressColor","pressOpacity","onTabPress","onTabLongPress","labelStyle","indicatorStyle","contentContainerStyle","indicatorContainerStyle","isWidthDynamic","separatorsWidth","separatorPercent","tabBarWidthPercent","translateX","getTranslateX","handleLayout","styles","tabBar","indicatorContainer","transform","renderIndicator","getTabWidth","scroll","item","tabContent","container","route","onLayout","measuredTabWidths","onPress","event","defaultPrevented","preventDefault","onLongPress","contentOffset","x","useNativeDriver","title","accessible","accessibilityLabel","testID","create","flex","overflow","select","default","web","backgroundColor","elevation","shadowColor","shadowOpacity","shadowRadius","hairlineWidth","shadowOffset","zIndex","flexDirection","flexWrap","top","left","right","bottom"],"sources":["TabBar.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n TextStyle,\n LayoutChangeEvent,\n I18nManager,\n Platform,\n FlatList,\n ListRenderItemInfo,\n} from 'react-native';\nimport TabBarItem, { Props as TabBarItemProps } from './TabBarItem';\nimport TabBarIndicator, { Props as IndicatorProps } from './TabBarIndicator';\nimport type {\n Route,\n Scene,\n SceneRendererProps,\n NavigationState,\n Layout,\n Event,\n} from './types';\n\nexport type Props<T extends Route> = SceneRendererProps & {\n navigationState: NavigationState<T>;\n scrollEnabled?: boolean;\n bounces?: boolean;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (\n scene: Scene<T> & {\n focused: boolean;\n color: string;\n }\n ) => React.ReactNode;\n renderIcon?: (\n scene: Scene<T> & {\n focused: boolean;\n color: string;\n }\n ) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n renderIndicator: (props: IndicatorProps<T>) => React.ReactNode;\n renderTabBarItem?: (\n props: TabBarItemProps<T> & { key: string }\n ) => React.ReactElement;\n onTabPress?: (scene: Scene<T> & Event) => void;\n onTabLongPress?: (scene: Scene<T>) => void;\n tabStyle?: StyleProp<ViewStyle>;\n indicatorStyle?: StyleProp<ViewStyle>;\n indicatorContainerStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n contentContainerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n gap?: number;\n};\n\ntype State = {\n layout: Layout;\n tabWidths: { [key: string]: number };\n};\n\nconst Separator = ({ width }: { width: number }) => {\n return <View style={{ width }} />;\n};\n\nexport default class TabBar<T extends Route> extends React.Component<\n Props<T>,\n State\n> {\n static defaultProps = {\n getLabelText: ({ route }: Scene<Route>) => route.title,\n getAccessible: ({ route }: Scene<Route>) =>\n typeof route.accessible !== 'undefined' ? route.accessible : true,\n getAccessibilityLabel: ({ route }: Scene<Route>) =>\n typeof route.accessibilityLabel === 'string'\n ? route.accessibilityLabel\n : typeof route.title === 'string'\n ? route.title\n : undefined,\n getTestID: ({ route }: Scene<Route>) => route.testID,\n renderIndicator: (props: IndicatorProps<Route>) => (\n <TabBarIndicator {...props} />\n ),\n gap: 0,\n };\n\n state: State = {\n layout: { width: 0, height: 0 },\n tabWidths: {},\n };\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n const { navigationState } = this.props;\n const { layout, tabWidths } = this.state;\n\n if (\n prevProps.navigationState.routes.length !==\n navigationState.routes.length ||\n prevProps.navigationState.index !== navigationState.index ||\n prevState.layout.width !== layout.width ||\n prevState.tabWidths !== tabWidths\n ) {\n if (\n this.getFlattenedTabWidth(this.props.tabStyle) === 'auto' &&\n !(\n layout.width &&\n navigationState.routes.every(\n (r) => typeof tabWidths[r.key] === 'number'\n )\n )\n ) {\n // When tab width is dynamic, only adjust the scroll once we have all tab widths and layout\n return;\n }\n\n this.resetScroll(navigationState.index);\n }\n }\n\n // to store the layout.width of each tab\n // when all onLayout's are fired, this would be set in state\n private measuredTabWidths: { [key: string]: number } = {};\n\n private scrollAmount = new Animated.Value(0);\n\n private flatListRef = React.createRef<FlatList>();\n\n private getFlattenedTabWidth = (style: StyleProp<ViewStyle>) => {\n const tabStyle = StyleSheet.flatten(style);\n\n return tabStyle ? tabStyle.width : undefined;\n };\n\n private getComputedTabWidth = (\n index: number,\n layout: Layout,\n routes: Route[],\n scrollEnabled: boolean | undefined,\n tabWidths: { [key: string]: number },\n flattenedWidth: string | number | undefined\n ) => {\n if (flattenedWidth === 'auto') {\n return tabWidths[routes[index].key] || 0;\n }\n\n switch (typeof flattenedWidth) {\n case 'number':\n return flattenedWidth;\n case 'string':\n if (flattenedWidth.endsWith('%')) {\n const width = parseFloat(flattenedWidth);\n if (Number.isFinite(width)) {\n return layout.width * (width / 100);\n }\n }\n }\n\n if (scrollEnabled) {\n return (layout.width / 5) * 2;\n }\n return layout.width / routes.length;\n };\n\n private getMaxScrollDistance = (tabBarWidth: number, layoutWidth: number) =>\n tabBarWidth - layoutWidth;\n\n private getTabBarWidth = (props: Props<T>, state: State) => {\n const { layout, tabWidths } = state;\n const { scrollEnabled, tabStyle } = props;\n const { routes } = props.navigationState;\n\n return routes.reduce<number>(\n (acc, _, i) =>\n acc +\n (i > 0 ? props.gap ?? 0 : 0) +\n this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n ),\n 0\n );\n };\n\n private normalizeScrollValue = (\n props: Props<T>,\n state: State,\n value: number\n ) => {\n const { layout } = state;\n const tabBarWidth = this.getTabBarWidth(props, state);\n const maxDistance = this.getMaxScrollDistance(tabBarWidth, layout.width);\n const scrollValue = Math.max(Math.min(value, maxDistance), 0);\n\n if (Platform.OS === 'android' && I18nManager.isRTL) {\n // On Android, scroll value is not applied in reverse in RTL\n // so we need to manually adjust it to apply correct value\n return maxDistance - scrollValue;\n }\n\n return scrollValue;\n };\n\n private getScrollAmount = (props: Props<T>, state: State, index: number) => {\n const { layout, tabWidths } = state;\n const { scrollEnabled, tabStyle } = props;\n const { routes } = props.navigationState;\n\n const centerDistance = Array.from({ length: index + 1 }).reduce<number>(\n (total, _, i) => {\n const tabWidth = this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n );\n\n // To get the current index centered we adjust scroll amount by width of indexes\n // 0 through (i - 1) and add half the width of current index i\n return (\n total +\n (index === i\n ? (tabWidth + (props.gap ?? 0)) / 2\n : tabWidth + (props.gap ?? 0))\n );\n },\n 0\n );\n\n const scrollAmount = centerDistance - layout.width / 2;\n\n return this.normalizeScrollValue(props, state, scrollAmount);\n };\n\n private resetScroll = (index: number) => {\n if (this.props.scrollEnabled) {\n this.flatListRef.current?.scrollToOffset({\n offset: this.getScrollAmount(this.props, this.state, index),\n animated: true,\n });\n }\n };\n\n private handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n if (\n this.state.layout.width === width &&\n this.state.layout.height === height\n ) {\n return;\n }\n\n this.setState({\n layout: {\n height,\n width,\n },\n });\n };\n\n private getTranslateX = (\n scrollAmount: Animated.Value,\n maxScrollDistance: number\n ) =>\n Animated.multiply(\n Platform.OS === 'android' && I18nManager.isRTL\n ? Animated.add(maxScrollDistance, Animated.multiply(scrollAmount, -1))\n : scrollAmount,\n I18nManager.isRTL ? 1 : -1\n );\n\n render() {\n const {\n position,\n navigationState,\n jumpTo,\n scrollEnabled,\n bounces,\n getAccessibilityLabel,\n getAccessible,\n getLabelText,\n getTestID,\n renderBadge,\n renderIcon,\n renderLabel,\n renderTabBarItem,\n activeColor,\n inactiveColor,\n pressColor,\n pressOpacity,\n onTabPress,\n onTabLongPress,\n tabStyle,\n labelStyle,\n indicatorStyle,\n contentContainerStyle,\n style,\n indicatorContainerStyle,\n gap = 0,\n } = this.props;\n const { layout, tabWidths } = this.state;\n const { routes } = navigationState;\n\n const isWidthDynamic = this.getFlattenedTabWidth(tabStyle) === 'auto';\n const tabBarWidth = this.getTabBarWidth(this.props, this.state);\n const separatorsWidth = Math.max(0, routes.length - 1) * gap;\n const separatorPercent = (separatorsWidth / tabBarWidth) * 100;\n\n const tabBarWidthPercent = `${routes.length * 40}%`;\n const translateX = this.getTranslateX(\n this.scrollAmount,\n this.getMaxScrollDistance(tabBarWidth, layout.width)\n );\n\n return (\n <Animated.View\n onLayout={this.handleLayout}\n style={[styles.tabBar, style]}\n >\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.indicatorContainer,\n scrollEnabled ? { transform: [{ translateX }] as any } : null,\n tabBarWidth > separatorsWidth\n ? { width: tabBarWidth - separatorsWidth }\n : scrollEnabled\n ? { width: tabBarWidthPercent }\n : null,\n indicatorContainerStyle,\n ]}\n >\n {this.props.renderIndicator({\n position,\n layout,\n navigationState,\n jumpTo,\n width: isWidthDynamic\n ? 'auto'\n : `${(100 - separatorPercent) / routes.length}%`,\n style: indicatorStyle,\n getTabWidth: (i: number) =>\n this.getComputedTabWidth(\n i,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n ),\n gap,\n })}\n </Animated.View>\n <View style={styles.scroll}>\n <Animated.FlatList\n data={routes as Animated.WithAnimatedValue<T>[]}\n keyExtractor={(item) => item.key}\n horizontal\n accessibilityRole=\"tablist\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEnabled={scrollEnabled}\n bounces={bounces}\n alwaysBounceHorizontal={false}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n automaticallyAdjustContentInsets={false}\n overScrollMode=\"never\"\n contentContainerStyle={[\n styles.tabContent,\n scrollEnabled\n ? {\n width:\n tabBarWidth > separatorsWidth\n ? tabBarWidth\n : tabBarWidthPercent,\n }\n : styles.container,\n contentContainerStyle,\n ]}\n scrollEventThrottle={16}\n renderItem={({ item: route, index }: ListRenderItemInfo<T>) => {\n const props: TabBarItemProps<T> & { key: string } = {\n key: route.key,\n position: position,\n route: route,\n navigationState: navigationState,\n getAccessibilityLabel: getAccessibilityLabel,\n getAccessible: getAccessible,\n getLabelText: getLabelText,\n getTestID: getTestID,\n renderBadge: renderBadge,\n renderIcon: renderIcon,\n renderLabel: renderLabel,\n activeColor: activeColor,\n inactiveColor: inactiveColor,\n pressColor: pressColor,\n pressOpacity: pressOpacity,\n onLayout: isWidthDynamic\n ? (e) => {\n this.measuredTabWidths[route.key] =\n e.nativeEvent.layout.width;\n\n // When we have measured widths for all of the tabs, we should updates the state\n // We avoid doing separate setState for each layout since it triggers multiple renders and slows down app\n if (\n routes.every(\n (r) =>\n typeof this.measuredTabWidths[r.key] === 'number'\n )\n ) {\n this.setState({\n tabWidths: { ...this.measuredTabWidths },\n });\n }\n }\n : undefined,\n onPress: () => {\n const event: Scene<T> & Event = {\n route,\n defaultPrevented: false,\n preventDefault: () => {\n event.defaultPrevented = true;\n },\n };\n\n onTabPress?.(event);\n\n if (event.defaultPrevented) {\n return;\n }\n\n this.props.jumpTo(route.key);\n },\n onLongPress: () => onTabLongPress?.({ route }),\n labelStyle: labelStyle,\n style: [\n tabStyle,\n // Calculate the deafult width for tab for FlatList to work.\n this.getFlattenedTabWidth(tabStyle) === undefined && {\n width: this.getComputedTabWidth(\n index,\n layout,\n routes,\n scrollEnabled,\n tabWidths,\n this.getFlattenedTabWidth(tabStyle)\n ),\n },\n ],\n };\n\n return (\n <React.Fragment key={route.key}>\n {gap > 0 && index > 0 ? <Separator width={gap} /> : null}\n {renderTabBarItem ? (\n renderTabBarItem(props)\n ) : (\n <TabBarItem {...props} />\n )}\n </React.Fragment>\n );\n }}\n onScroll={Animated.event(\n [\n {\n nativeEvent: {\n contentOffset: { x: this.scrollAmount },\n },\n },\n ],\n { useNativeDriver: true }\n )}\n ref={this.flatListRef}\n />\n </View>\n </Animated.View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n scroll: {\n overflow: Platform.select({ default: 'scroll', web: undefined }),\n },\n tabBar: {\n backgroundColor: '#2196f3',\n elevation: 4,\n shadowColor: 'black',\n shadowOpacity: 0.1,\n shadowRadius: StyleSheet.hairlineWidth,\n shadowOffset: {\n height: StyleSheet.hairlineWidth,\n width: 0,\n },\n zIndex: 1,\n },\n tabContent: {\n flexDirection: 'row',\n flexWrap: 'nowrap',\n },\n indicatorContainer: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,EAQEC,WARF,EASEC,QATF,QAYO,cAZP;AAaA,OAAOC,UAAP,MAAqD,cAArD;AACA,OAAOC,eAAP,MAAyD,mBAAzD;;AAuDA,MAAMC,SAAS,GAAG,QAAkC;EAAA,IAAjC;IAAEC;EAAF,CAAiC;EAClD,oBAAO,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,EAAP;AACD,CA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;IACTiB,IAAI,EAAE;EADG,CADoB;EAI/BpB,MAAM,EAAE;IACNqB,QAAQ,EAAEjI,QAAQ,CAACkI,MAAT,CAAgB;MAAEC,OAAO,EAAE,QAAX;MAAqBC,GAAG,EAAErH;IAA1B,CAAhB;EADJ,CAJuB;EAO/BwF,MAAM,EAAE;IACN8B,eAAe,EAAE,SADX;IAENC,SAAS,EAAE,CAFL;IAGNC,WAAW,EAAE,OAHP;IAINC,aAAa,EAAE,GAJT;IAKNC,YAAY,EAAE5I,UAAU,CAAC6I,aALnB;IAMNC,YAAY,EAAE;MACZnI,MAAM,EAAEX,UAAU,CAAC6I,aADP;MAEZtI,KAAK,EAAE;IAFK,CANR;IAUNwI,MAAM,EAAE;EAVF,CAPuB;EAmB/B9B,UAAU,EAAE;IACV+B,aAAa,EAAE,KADL;IAEVC,QAAQ,EAAE;EAFA,CAnBmB;EAuB/BtC,kBAAkB,EAAE;IAClB9B,QAAQ,EAAE,UADQ;IAElBqE,GAAG,EAAE,CAFa;IAGlBC,IAAI,EAAE,CAHY;IAIlBC,KAAK,EAAE,CAJW;IAKlBC,MAAM,EAAE;EALU;AAvBW,CAAlB,CAAf"}
|
|
@@ -3,8 +3,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Animated, Easing, StyleSheet, I18nManager, Platform } from 'react-native';
|
|
5
5
|
export default class TabBarIndicator extends React.Component {
|
|
6
|
-
constructor(
|
|
7
|
-
super(...
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
8
|
|
|
9
9
|
_defineProperty(this, "fadeInIndicator", () => {
|
|
10
10
|
const {
|
|
@@ -30,12 +30,12 @@ export default class TabBarIndicator extends React.Component {
|
|
|
30
30
|
|
|
31
31
|
_defineProperty(this, "opacity", new Animated.Value(this.props.width === 'auto' ? 0 : 1));
|
|
32
32
|
|
|
33
|
-
_defineProperty(this, "getTranslateX", (position, routes, getTabWidth) => {
|
|
33
|
+
_defineProperty(this, "getTranslateX", (position, routes, getTabWidth, gap) => {
|
|
34
34
|
const inputRange = routes.map((_, i) => i); // every index contains widths at all previous indices
|
|
35
35
|
|
|
36
36
|
const outputRange = routes.reduce((acc, _, i) => {
|
|
37
37
|
if (i === 0) return [0];
|
|
38
|
-
return [...acc, acc[i - 1] + getTabWidth(i - 1)];
|
|
38
|
+
return [...acc, acc[i - 1] + getTabWidth(i - 1) + (gap ?? 0)];
|
|
39
39
|
}, []);
|
|
40
40
|
const translateX = position.interpolate({
|
|
41
41
|
inputRange,
|
|
@@ -61,7 +61,8 @@ export default class TabBarIndicator extends React.Component {
|
|
|
61
61
|
getTabWidth,
|
|
62
62
|
width,
|
|
63
63
|
style,
|
|
64
|
-
layout
|
|
64
|
+
layout,
|
|
65
|
+
gap
|
|
65
66
|
} = this.props;
|
|
66
67
|
const {
|
|
67
68
|
routes
|
|
@@ -69,7 +70,7 @@ export default class TabBarIndicator extends React.Component {
|
|
|
69
70
|
const transform = [];
|
|
70
71
|
|
|
71
72
|
if (layout.width) {
|
|
72
|
-
const translateX = routes.length > 1 ? this.getTranslateX(position, routes, getTabWidth) : 0;
|
|
73
|
+
const translateX = routes.length > 1 ? this.getTranslateX(position, routes, getTabWidth, gap) : 0;
|
|
73
74
|
transform.push({
|
|
74
75
|
translateX
|
|
75
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","Animated","Easing","StyleSheet","I18nManager","Platform","TabBarIndicator","Component","navigationState","layout","width","getTabWidth","props","isIndicatorShown","routes","every","_","i","timing","opacity","toValue","duration","easing","in","linear","useNativeDriver","start","Value","position","gap","inputRange","map","outputRange","reduce","acc","translateX","interpolate","extrapolate","multiply","isRTL","componentDidMount","fadeInIndicator","componentDidUpdate","render","style","transform","length","getTranslateX","push","scaleX","styles","indicator","OS","left","index","create","backgroundColor","bottom","right","height"],"sources":["TabBarIndicator.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n Easing,\n StyleSheet,\n I18nManager,\n StyleProp,\n ViewStyle,\n Platform,\n} from 'react-native';\n\nimport type { Route, SceneRendererProps, NavigationState } from './types';\n\nexport type GetTabWidth = (index: number) => number;\n\nexport type Props<T extends Route> = SceneRendererProps & {\n navigationState: NavigationState<T>;\n width: string | number;\n style?: StyleProp<ViewStyle>;\n getTabWidth: GetTabWidth;\n gap?: number;\n};\n\nexport default class TabBarIndicator<T extends Route> extends React.Component<\n Props<T>\n> {\n componentDidMount() {\n this.fadeInIndicator();\n }\n\n componentDidUpdate() {\n this.fadeInIndicator();\n }\n\n private fadeInIndicator = () => {\n const { navigationState, layout, width, getTabWidth } = this.props;\n\n if (\n !this.isIndicatorShown &&\n width === 'auto' &&\n layout.width &&\n // We should fade-in the indicator when we have widths for all the tab items\n navigationState.routes.every((_, i) => getTabWidth(i))\n ) {\n this.isIndicatorShown = true;\n\n Animated.timing(this.opacity, {\n toValue: 1,\n duration: 150,\n easing: Easing.in(Easing.linear),\n useNativeDriver: true,\n }).start();\n }\n };\n\n private isIndicatorShown = false;\n\n private opacity = new Animated.Value(this.props.width === 'auto' ? 0 : 1);\n\n private getTranslateX = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n getTabWidth: GetTabWidth,\n gap?: number\n ) => {\n const inputRange = routes.map((_, i) => i);\n\n // every index contains widths at all previous indices\n const outputRange = routes.reduce<number[]>((acc, _, i) => {\n if (i === 0) return [0];\n return [...acc, acc[i - 1] + getTabWidth(i - 1) + (gap ?? 0)];\n }, []);\n\n const translateX = position.interpolate({\n inputRange,\n outputRange,\n extrapolate: 'clamp',\n });\n\n return Animated.multiply(translateX, I18nManager.isRTL ? -1 : 1);\n };\n\n render() {\n const {\n position,\n navigationState,\n getTabWidth,\n width,\n style,\n layout,\n gap,\n } = this.props;\n const { routes } = navigationState;\n\n const transform = [];\n\n if (layout.width) {\n const translateX =\n routes.length > 1\n ? this.getTranslateX(position, routes, getTabWidth, gap)\n : 0;\n\n transform.push({ translateX });\n }\n\n if (width === 'auto') {\n const inputRange = routes.map((_, i) => i);\n const outputRange = inputRange.map(getTabWidth);\n\n transform.push(\n {\n scaleX:\n routes.length > 1\n ? position.interpolate({\n inputRange,\n outputRange,\n extrapolate: 'clamp',\n })\n : outputRange[0],\n },\n { translateX: 0.5 }\n );\n }\n\n return (\n <Animated.View\n style={[\n styles.indicator,\n { width: width === 'auto' ? 1 : width },\n // If layout is not available, use `left` property for positioning the indicator\n // This avoids rendering delay until we are able to calculate translateX\n // If platform is macos use `left` property as `transform` is broken at the moment.\n // See: https://github.com/microsoft/react-native-macos/issues/280\n layout.width && Platform.OS !== 'macos'\n ? { left: 0 }\n : { left: `${(100 / routes.length) * navigationState.index}%` },\n { transform },\n width === 'auto' ? { opacity: this.opacity } : null,\n style,\n ]}\n />\n );\n }\n}\n\nconst styles = StyleSheet.create({\n indicator: {\n backgroundColor: '#ffeb3b',\n position: 'absolute',\n left: 0,\n bottom: 0,\n right: 0,\n height: 2,\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,MAFF,EAGEC,UAHF,EAIEC,WAJF,EAOEC,QAPF,QAQO,cARP;AAsBA,eAAe,MAAMC,eAAN,SAA+CN,KAAK,CAACO,SAArD,CAEb;EAAA;IAAA;;IAAA,yCAS0B,MAAM;MAC9B,MAAM;QAAEC,eAAF;QAAmBC,MAAnB;QAA2BC,KAA3B;QAAkCC;MAAlC,IAAkD,KAAKC,KAA7D;;MAEA,IACE,CAAC,KAAKC,gBAAN,IACAH,KAAK,KAAK,MADV,IAEAD,MAAM,CAACC,KAFP,IAGA;MACAF,eAAe,CAACM,MAAhB,CAAuBC,KAAvB,CAA6B,CAACC,CAAD,EAAIC,CAAJ,KAAUN,WAAW,CAACM,CAAD,CAAlD,CALF,EAME;QACA,KAAKJ,gBAAL,GAAwB,IAAxB;QAEAZ,QAAQ,CAACiB,MAAT,CAAgB,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C,GACI;QAAEC,IAAI,EAAE;MAAR,CADJ,GAEI;QAAEA,IAAI,EAAG,GAAG,MAAMvC,MAAM,CAACgC,MAAd,GAAwBtC,eAAe,CAAC8C,KAAM;MAAzD,CATC,EAUL;QAAET;MAAF,CAVK,EAWLnC,KAAK,KAAK,MAAV,GAAmB;QAAES,OAAO,EAAE,KAAKA;MAAhB,CAAnB,GAA+C,IAX1C,EAYLyB,KAZK;IADT,EADF;EAkBD;;AArHD;AAwHF,MAAMM,MAAM,GAAG/C,UAAU,CAACoD,MAAX,CAAkB;EAC/BJ,SAAS,EAAE;IACTK,eAAe,EAAE,SADR;IAET5B,QAAQ,EAAE,UAFD;IAGTyB,IAAI,EAAE,CAHG;IAITI,MAAM,EAAE,CAJC;IAKTC,KAAK,EAAE,CALE;IAMTC,MAAM,EAAE;EANC;AADoB,CAAlB,CAAf"}
|
package/lib/module/TabBarItem.js
CHANGED
|
@@ -6,8 +6,8 @@ import PlatformPressable from './PlatformPressable';
|
|
|
6
6
|
const DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';
|
|
7
7
|
const DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';
|
|
8
8
|
export default class TabBarItem extends React.Component {
|
|
9
|
-
constructor(
|
|
10
|
-
super(...
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
11
|
|
|
12
12
|
_defineProperty(this, "getActiveOpacity", (position, routes, tabIndex) => {
|
|
13
13
|
if (routes.length > 1) {
|
|
@@ -93,10 +93,11 @@ export default class TabBarItem extends React.Component {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const renderLabel = renderLabelCustom !== undefined ? renderLabelCustom :
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
const renderLabel = renderLabelCustom !== undefined ? renderLabelCustom : _ref => {
|
|
97
|
+
let {
|
|
98
|
+
route,
|
|
99
|
+
color
|
|
100
|
+
} = _ref;
|
|
100
101
|
const labelText = getLabelText({
|
|
101
102
|
route
|
|
102
103
|
});
|