@react-navigation/drawer 6.4.2 → 6.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,6 +29,8 @@ const LinkPressable = _ref => {
|
|
|
29
29
|
style,
|
|
30
30
|
onPress,
|
|
31
31
|
onLongPress,
|
|
32
|
+
onPressIn,
|
|
33
|
+
onPressOut,
|
|
32
34
|
to,
|
|
33
35
|
accessibilityRole,
|
|
34
36
|
...rest
|
|
@@ -47,8 +49,12 @@ const LinkPressable = _ref => {
|
|
|
47
49
|
e.preventDefault();
|
|
48
50
|
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
49
51
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
+
} // types for PressableProps and TextProps are incompatible with each other by `null` so we
|
|
53
|
+
// can't use {...rest} for these 3 props
|
|
54
|
+
,
|
|
55
|
+
onLongPress: onLongPress !== null && onLongPress !== void 0 ? onLongPress : undefined,
|
|
56
|
+
onPressIn: onPressIn !== null && onPressIn !== void 0 ? onPressIn : undefined,
|
|
57
|
+
onPressOut: onPressOut !== null && onPressOut !== void 0 ? onPressOut : undefined
|
|
52
58
|
}), children);
|
|
53
59
|
} else {
|
|
54
60
|
return /*#__PURE__*/React.createElement(_elements.PlatformPressable, _extends({}, rest, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerItem.tsx"],"names":["LinkPressable","children","style","onPress","onLongPress","to","accessibilityRole","rest","Platform","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","allowFontScaling","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","StyleSheet","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;;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E;AACLkC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B/C,EAAAA,MAAM,EAAE;AACNgD,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Whether label font should scale to respect Text Size accessibility settings.\n */\n allowFontScaling?: boolean;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n onLongPress={onLongPress ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n allowFontScaling,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n allowFontScaling={allowFontScaling}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["DrawerItem.tsx"],"names":["LinkPressable","children","style","onPress","onLongPress","onPressIn","onPressOut","to","accessibilityRole","rest","Platform","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","allowFontScaling","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","StyleSheet","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAiFA,MAAMA,aAAa,GAAG,QAgBhB;AAAA,MAhBiB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,OAHqB;AAIrBC,IAAAA,WAJqB;AAKrBC,IAAAA,SALqB;AAMrBC,IAAAA,UANqB;AAOrBC,IAAAA,EAPqB;AAQrBC,IAAAA,iBARqB;AASrB,OAAGC;AATkB,GAgBjB;;AACJ,MAAIC,sBAASC,EAAT,KAAgB,KAAhB,IAAyBJ,EAA7B,EAAiC;AAC/B;AACA;AACA,wBACE,oBAAC,YAAD,eACME,IADN;AAEE,MAAA,EAAE,EAAEF,EAFN;AAGE,MAAA,KAAK,EAAE,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,UAAU,EAAEW,UALd;AAME,IAAA,YAAY,EAAEC,YANhB;AAOE,IAAA,EAAE,EAAEhC;AAPN,kBASE,oBAAC,KAAD,CAAO,QAAP,QACGsC,QADH,eAEE,oBAAC,iBAAD;AACE,IAAA,KAAK,EAAE,CACLjC,MAAM,CAACa,KADF,EAEL;AAAEyB,MAAAA,UAAU,EAAEL,QAAQ,GAAG,EAAH,GAAQ,CAA9B;AAAiCM,MAAAA,cAAc,EAAE;AAAjD,KAFK;AADT,KAMG,OAAO1B,KAAP,KAAiB,QAAjB,gBACC,oBAAC,iBAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,gBAAgB,EAAEG,gBAFpB;AAGE,IAAA,KAAK,EAAE,CACL;AACEe,MAAAA,KADF;AAEES,MAAAA,UAAU,EAAE;AAFd,KADK,EAKL1B,UALK;AAHT,KAWGD,KAXH,CADD,GAeCA,KAAK,CAAC;AAAEkB,IAAAA,KAAF;AAAShB,IAAAA;AAAT,GAAD,CArBT,CAFF,CATF,CALF,CADF;AA6CD;;AAED,MAAMf,MAAM,GAAG6B,wBAAWY,MAAX,CAAkB;AAC/BN,EAAAA,SAAS,EAAE;AACTO,IAAAA,gBAAgB,EAAE,EADT;AAETH,IAAAA,cAAc,EAAE,CAFP;AAGTI,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,OAAO,EAAE;AACPQ,IAAAA,aAAa,EAAE,KADR;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,OAAO,EAAE;AAHF,GANsB;AAW/BjC,EAAAA,KAAK,EAAE;AACLkC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B/C,EAAAA,MAAM,EAAE;AACNgD,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Whether label font should scale to respect Text Size accessibility settings.\n */\n allowFontScaling?: boolean;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n onPressIn,\n onPressOut,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n // types for PressableProps and TextProps are incompatible with each other by `null` so we\n // can't use {...rest} for these 3 props\n onLongPress={onLongPress ?? undefined}\n onPressIn={onPressIn ?? undefined}\n onPressOut={onPressOut ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n allowFontScaling,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n allowFontScaling={allowFontScaling}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
|
@@ -12,6 +12,8 @@ const LinkPressable = _ref => {
|
|
|
12
12
|
style,
|
|
13
13
|
onPress,
|
|
14
14
|
onLongPress,
|
|
15
|
+
onPressIn,
|
|
16
|
+
onPressOut,
|
|
15
17
|
to,
|
|
16
18
|
accessibilityRole,
|
|
17
19
|
...rest
|
|
@@ -30,8 +32,12 @@ const LinkPressable = _ref => {
|
|
|
30
32
|
e.preventDefault();
|
|
31
33
|
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
32
34
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
+
} // types for PressableProps and TextProps are incompatible with each other by `null` so we
|
|
36
|
+
// can't use {...rest} for these 3 props
|
|
37
|
+
,
|
|
38
|
+
onLongPress: onLongPress !== null && onLongPress !== void 0 ? onLongPress : undefined,
|
|
39
|
+
onPressIn: onPressIn !== null && onPressIn !== void 0 ? onPressIn : undefined,
|
|
40
|
+
onPressOut: onPressOut !== null && onPressOut !== void 0 ? onPressOut : undefined
|
|
35
41
|
}), children);
|
|
36
42
|
} else {
|
|
37
43
|
return /*#__PURE__*/React.createElement(PlatformPressable, _extends({}, rest, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerItem.tsx"],"names":["PlatformPressable","Link","useTheme","Color","React","Platform","StyleSheet","Text","View","LinkPressable","children","style","onPress","onLongPress","to","accessibilityRole","rest","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","allowFontScaling","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SAASC,IAAT,EAAeC,QAAf,QAA+B,0BAA/B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAGEC,UAHF,EAIEC,IAJF,EAMEC,IANF,QAQO,cARP;;AAiFA,MAAMC,aAAa,GAAG,QAchB;AAAA,MAdiB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,OAHqB;AAIrBC,IAAAA,WAJqB;AAKrBC,IAAAA,EALqB;AAMrBC,IAAAA,iBANqB;AAOrB,OAAGC;AAPkB,GAcjB;;AACJ,MAAIX,QAAQ,CAACY,EAAT,KAAgB,KAAhB,IAAyBH,EAA7B,EAAiC;AAC/B;AACA;AACA,wBACE,oBAAC,IAAD,eACME,IADN;AAEE,MAAA,EAAE,EAAEF,EAFN;AAGE,MAAA,KAAK,EAAE,CAACI,MAAM,CAACC,MAAR,EAAgBR,KAAhB,CAHT;AAIE,MAAA,OAAO,EAAGS,CAAD,IAAY;AACnB,YACE,EAAEA,CAAC,CAACC,OAAF,IAAaD,CAAC,CAACE,MAAf,IAAyBF,CAAC,CAACG,OAA3B,IAAsCH,CAAC,CAACI,QAA1C,OAAuD;AACtDJ,QAAAA,CAAC,CAACD,MAAF,IAAY,IAAZ,IAAoBC,CAAC,CAACD,MAAF,KAAa,CADlC,CADF,CAEuC;AAFvC,UAGE;AACAC,UAAAA,CAAC,CAACK,cAAF;AACAb,UAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAGQ,CAAH,CAAP;AACD;AACF,OAZH;AAaE,MAAA,WAAW,EAAEP,WAAF,aAAEA,W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D,CArBT,CAFF,CATF,CALF,CADF;AA6CD;AAED,MAAMf,MAAM,GAAGZ,UAAU,CAACoD,MAAX,CAAkB;AAC/BN,EAAAA,SAAS,EAAE;AACTO,IAAAA,gBAAgB,EAAE,EADT;AAETH,IAAAA,cAAc,EAAE,CAFP;AAGTI,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,OAAO,EAAE;AACPQ,IAAAA,aAAa,EAAE,KADR;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,OAAO,EAAE;AAHF,GANsB;AAW/BhC,EAAAA,KAAK,EAAE;AACLiC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B9C,EAAAA,MAAM,EAAE;AACN+C,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Whether label font should scale to respect Text Size accessibility settings.\n */\n allowFontScaling?: boolean;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n onLongPress={onLongPress ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n allowFontScaling,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n allowFontScaling={allowFontScaling}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["DrawerItem.tsx"],"names":["PlatformPressable","Link","useTheme","Color","React","Platform","StyleSheet","Text","View","LinkPressable","children","style","onPress","onLongPress","onPressIn","onPressOut","to","accessibilityRole","rest","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","allowFontScaling","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SAASC,IAAT,EAAeC,Q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,GAAD,CArBT,CAFF,CATF,CALF,CADF;AA6CD;AAED,MAAMf,MAAM,GAAGd,UAAU,CAACsD,MAAX,CAAkB;AAC/BN,EAAAA,SAAS,EAAE;AACTO,IAAAA,gBAAgB,EAAE,EADT;AAETH,IAAAA,cAAc,EAAE,CAFP;AAGTI,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,OAAO,EAAE;AACPQ,IAAAA,aAAa,EAAE,KADR;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,OAAO,EAAE;AAHF,GANsB;AAW/BhC,EAAAA,KAAK,EAAE;AACLiC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B9C,EAAAA,MAAM,EAAE;AACN+C,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Whether label font should scale to respect Text Size accessibility settings.\n */\n allowFontScaling?: boolean;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n onPressIn,\n onPressOut,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n // types for PressableProps and TextProps are incompatible with each other by `null` so we\n // can't use {...rest} for these 3 props\n onLongPress={onLongPress ?? undefined}\n onPressIn={onPressIn ?? undefined}\n onPressOut={onPressOut ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n allowFontScaling,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n allowFontScaling={allowFontScaling}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/drawer",
|
|
3
3
|
"description": "Drawer navigator component with animated transitions and gesturess",
|
|
4
|
-
"version": "6.4.
|
|
4
|
+
"version": "6.4.3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
"clean": "del lib"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@react-navigation/elements": "^1.3.
|
|
45
|
-
"color": "^
|
|
44
|
+
"@react-navigation/elements": "^1.3.4",
|
|
45
|
+
"color": "^4.2.3",
|
|
46
46
|
"warn-once": "^0.1.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@react-navigation/native": "^6.0.
|
|
49
|
+
"@react-navigation/native": "^6.0.11",
|
|
50
50
|
"@testing-library/react-native": "^7.2.0",
|
|
51
|
-
"@types/react": "^17.0.
|
|
52
|
-
"@types/react-native": "~0.
|
|
51
|
+
"@types/react": "^17.0.47",
|
|
52
|
+
"@types/react-native": "~0.68.1",
|
|
53
53
|
"del-cli": "^3.0.1",
|
|
54
|
-
"react": "17.0.
|
|
55
|
-
"react-native": "~0.
|
|
54
|
+
"react": "17.0.2",
|
|
55
|
+
"react-native": "~0.68.2",
|
|
56
56
|
"react-native-builder-bob": "^0.18.1",
|
|
57
|
-
"react-native-gesture-handler": "~2.2.
|
|
58
|
-
"react-native-reanimated": "~2.
|
|
59
|
-
"react-native-safe-area-context": "
|
|
60
|
-
"react-native-screens": "~3.
|
|
61
|
-
"typescript": "^4.
|
|
57
|
+
"react-native-gesture-handler": "~2.2.1",
|
|
58
|
+
"react-native-reanimated": "~2.8.0",
|
|
59
|
+
"react-native-safe-area-context": "4.2.4",
|
|
60
|
+
"react-native-screens": "~3.11.1",
|
|
61
|
+
"typescript": "^4.7.4"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@react-navigation/native": "^6.0.0",
|
|
@@ -82,6 +82,5 @@
|
|
|
82
82
|
}
|
|
83
83
|
]
|
|
84
84
|
]
|
|
85
|
-
}
|
|
86
|
-
"gitHead": "9ddd79156ee844c7a6ebd83adf561cb0917b2aa6"
|
|
85
|
+
}
|
|
87
86
|
}
|
package/src/views/DrawerItem.tsx
CHANGED
|
@@ -88,6 +88,8 @@ const LinkPressable = ({
|
|
|
88
88
|
style,
|
|
89
89
|
onPress,
|
|
90
90
|
onLongPress,
|
|
91
|
+
onPressIn,
|
|
92
|
+
onPressOut,
|
|
91
93
|
to,
|
|
92
94
|
accessibilityRole,
|
|
93
95
|
...rest
|
|
@@ -115,7 +117,11 @@ const LinkPressable = ({
|
|
|
115
117
|
onPress?.(e);
|
|
116
118
|
}
|
|
117
119
|
}}
|
|
120
|
+
// types for PressableProps and TextProps are incompatible with each other by `null` so we
|
|
121
|
+
// can't use {...rest} for these 3 props
|
|
118
122
|
onLongPress={onLongPress ?? undefined}
|
|
123
|
+
onPressIn={onPressIn ?? undefined}
|
|
124
|
+
onPressOut={onPressOut ?? undefined}
|
|
119
125
|
>
|
|
120
126
|
{children}
|
|
121
127
|
</Link>
|