UNPKG

4.39 kBSource Map (JSON)View Raw
1{"version":3,"sources":["DrawerSection.tsx"],"names":["color","React","View","StyleSheet","Text","Divider","withTheme","DrawerSection","children","title","theme","style","rest","colors","fonts","titleColor","text","alpha","rgb","string","font","medium","styles","container","titleContainer","divider","displayName","create","marginBottom","height","justifyContent","marginLeft","marginTop"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAA0BC,UAA1B,QAAuD,cAAvD;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,SAASC,SAAT,QAA0B,oBAA1B;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,QAAuD;AAAA,MAAtD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,KAAnB;AAA0BC,IAAAA,KAA1B;AAAiC,OAAGC;AAApC,GAAsD;AAC3E,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBJ,KAA1B;AACA,QAAMK,UAAU,GAAGf,KAAK,CAACa,MAAM,CAACG,IAAR,CAAL,CAAmBC,KAAnB,CAAyB,IAAzB,EAA+BC,GAA/B,GAAqCC,MAArC,EAAnB;AACA,QAAMC,IAAI,GAAGN,KAAK,CAACO,MAAnB;AAEA,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBZ,KAAnB;AAAb,KAA4CC,IAA5C,GACGH,KAAK,iBACJ,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEa,MAAM,CAACE;AAApB,kBACE,oBAAC,IAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,KAAK,EAAE,CAAC;AAAExB,MAAAA,KAAK,EAAEe,UAAT;AAAqB,SAAGK;AAAxB,KAAD,EAAiCE,MAAM,CAACb,KAAxC;AAFT,KAIGA,KAJH,CADF,CAFJ,EAWGD,QAXH,eAYE,oBAAC,OAAD;AAAS,IAAA,KAAK,EAAEc,MAAM,CAACG;AAAvB,IAZF,CADF;AAgBD,CArBD;;AAuBAlB,aAAa,CAACmB,WAAd,GAA4B,gBAA5B;AAEA,MAAMJ,MAAM,GAAGnB,UAAU,CAACwB,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,YAAY,EAAE;AADL,GADoB;AAI/BJ,EAAAA,cAAc,EAAE;AACdK,IAAAA,MAAM,EAAE,EADM;AAEdC,IAAAA,cAAc,EAAE;AAFF,GAJe;AAQ/BrB,EAAAA,KAAK,EAAE;AACLsB,IAAAA,UAAU,EAAE;AADP,GARwB;AAW/BN,EAAAA,OAAO,EAAE;AACPO,IAAAA,SAAS,EAAE;AADJ;AAXsB,CAAlB,CAAf;AAgBA,eAAe1B,SAAS,CAACC,aAAD,CAAxB","sourcesContent":["import color from 'color';\nimport * as React from 'react';\nimport { View, ViewStyle, StyleSheet, StyleProp } from 'react-native';\nimport Text from '../Typography/Text';\nimport Divider from '../Divider';\nimport { withTheme } from '../../core/theming';\n\ntype Props = React.ComponentPropsWithRef<typeof View> & {\n /**\n * Title to show as the header for the section.\n */\n title?: string;\n /**\n * Content of the `Drawer.Section`.\n */\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n /**\n * @optional\n */\n theme: ReactNativePaper.Theme;\n};\n\n/**\n * A component to group content inside a navigation drawer.\n *\n * <div class=\"screenshots\">\n * <figure>\n * <img class=\"medium\" src=\"screenshots/drawer-section.png\" />\n * </figure>\n * </div>\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Drawer } from 'react-native-paper';\n *\n * const MyComponent = () => {\n * const [active, setActive] = React.useState('');\n *\n *\n * return (\n * <Drawer.Section title=\"Some title\">\n * <Drawer.Item\n * label=\"First Item\"\n * active={active === 'first'}\n * onPress={() => setActive('first')}\n * />\n * <Drawer.Item\n * label=\"Second Item\"\n * active={active === 'second'}\n * onPress={() => setActive('second')}\n * />\n * </Drawer.Section>\n * );\n * };\n *\n * export default MyComponent;\n * ```\n */\nconst DrawerSection = ({ children, title, theme, style, ...rest }: Props) => {\n const { colors, fonts } = theme;\n const titleColor = color(colors.text).alpha(0.54).rgb().string();\n const font = fonts.medium;\n\n return (\n <View style={[styles.container, style]} {...rest}>\n {title && (\n <View style={styles.titleContainer}>\n <Text\n numberOfLines={1}\n style={[{ color: titleColor, ...font }, styles.title]}\n >\n {title}\n </Text>\n </View>\n )}\n {children}\n <Divider style={styles.divider} />\n </View>\n );\n};\n\nDrawerSection.displayName = 'Drawer.Section';\n\nconst styles = StyleSheet.create({\n container: {\n marginBottom: 4,\n },\n titleContainer: {\n height: 40,\n justifyContent: 'center',\n },\n title: {\n marginLeft: 16,\n },\n divider: {\n marginTop: 4,\n },\n});\n\nexport default withTheme(DrawerSection);\n"]}
\No newline at end of file