UNPKG

4.63 kBSource Map (JSON)View Raw
1{"version":3,"sources":["MaterialCommunityIcon.tsx"],"names":["MaterialCommunityIcons","require","default","e","isErrorLogged","name","color","size","rest","test","message","console","error","warn","styles","icon","fontSize","accessibilityProps","Platform","OS","role","focusable","accessibilityElementsHidden","importantForAccessibility","defaultIcon","direction","allowFontScaling","transform","scaleX","lineHeight","StyleSheet","create","backgroundColor"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;AAUA,IAAIA,sBAAJ;;AASA,IAAI;AACF;AACAA,EAAAA,sBAAsB,GAAGC,OAAO,CAAC,kDAAD,CAAP,CACtBC,OADH;AAED,CAJD,CAIE,OAAOC,CAAP,EAAU;AACV,MAAIC,aAAa,GAAG,KAApB,CADU,CAGV;;AACAJ,EAAAA,sBAAsB,GAAG,CAAC;AAAEK,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,IAAf;AAAqB,OAAGC;AAAxB,GAAD,KAAoC;AAC3D;AACA,QAAI,CAACJ,aAAL,EAAoB;AAClB,UACE,CAAC,8DAA8DK,IAA9D,CACCN,CAAC,CAACO,OADH,CADH,EAIE;AACAC,QAAAA,OAAO,CAACC,KAAR,CAAcT,CAAd;AACD;;AAEDQ,MAAAA,OAAO,CAACE,IAAR,kCAC4BR,IAD5B;AAKAD,MAAAA,aAAa,GAAG,IAAhB;AACD;;AAED,wBACE,oBAAC,iBAAD,eACMI,IADN;AAEE,MAAA,KAAK,EAAE,CAACM,MAAM,CAACC,IAAR,EAAc;AAAET,QAAAA,KAAF;AAASU,QAAAA,QAAQ,EAAET;AAAnB,OAAd,CAFT,CAGE;AAHF;AAIE,MAAA,aAAa,EAAC,MAJhB;AAKE,MAAA,UAAU,EAAE;AALd,iBADF;AAWD,GA9BD;AA+BD;;AAEM,MAAMU,kBAAkB,GAC7BC,sBAASC,EAAT,KAAgB,KAAhB,GACI;AACEC,EAAAA,IAAI,EAAE,KADR;AAEEC,EAAAA,SAAS,EAAE;AAFb,CADJ,GAKI;AACEC,EAAAA,2BAA2B,EAAE,IAD/B;AAEEC,EAAAA,yBAAyB,EAAE;AAF7B,CANC;;;AAWP,MAAMC,WAAW,GAAG,CAAC;AACnBnB,EAAAA,IADmB;AAEnBC,EAAAA,KAFmB;AAGnBC,EAAAA,IAHmB;AAInBkB,EAAAA,SAJmB;AAKnBC,EAAAA;AALmB,CAAD,kBAOlB,oBAAC,sBAAD;AACE,EAAA,gBAAgB,EAAEA,gBADpB;AAEE,EAAA,IAAI,EAAErB,IAFR;AAGE,EAAA,KAAK,EAAEC,KAHT;AAIE,EAAA,IAAI,EAAEC,IAJR;AAKE,EAAA,KAAK,EAAE,CACL;AACEoB,IAAAA,SAAS,EAAE,CAAC;AAAEC,MAAAA,MAAM,EAAEH,SAAS,KAAK,KAAd,GAAsB,CAAC,CAAvB,GAA2B;AAArC,KAAD,CADb;AAEEI,IAAAA,UAAU,EAAEtB;AAFd,GADK,EAKLO,MAAM,CAACC,IALF,CALT;AAYE,EAAA,aAAa,EAAC,MAZhB;AAaE,EAAA,UAAU,EAAE;AAbd,GAcME,kBAdN,EAPF;;AAyBA,MAAMH,MAAM,GAAGgB,wBAAWC,MAAX,CAAkB;AAC/BhB,EAAAA,IAAI,EAAE;AACJiB,IAAAA,eAAe,EAAE;AADb;AADyB,CAAlB,CAAf;;eAMeR,W","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, Text, Platform, TextProps, ViewProps } from 'react-native';\n\nexport type IconProps = {\n name: string;\n color: string;\n size: number;\n direction: 'rtl' | 'ltr';\n allowFontScaling?: boolean;\n};\n\nlet MaterialCommunityIcons: React.ComponentType<\n TextProps & {\n name: string;\n color: string;\n size: number;\n pointerEvents?: ViewProps['pointerEvents'];\n }\n>;\n\ntry {\n // Optionally require vector-icons\n MaterialCommunityIcons = require('react-native-vector-icons/MaterialCommunityIcons')\n .default;\n} catch (e) {\n let isErrorLogged = false;\n\n // Fallback component for icons\n MaterialCommunityIcons = ({ name, color, size, ...rest }) => {\n /* eslint-disable no-console */\n if (!isErrorLogged) {\n if (\n !/(Cannot find module|Module not found|Cannot resolve module)/.test(\n e.message\n )\n ) {\n console.error(e);\n }\n\n console.warn(\n `Tried to use the icon '${name}' in a component from 'react-native-paper', but 'react-native-vector-icons/MaterialCommunityIcons' could not be loaded.`,\n `To remove this warning, try installing 'react-native-vector-icons' or use another method to specify icon: https://callstack.github.io/react-native-paper/icons.html.`\n );\n\n isErrorLogged = true;\n }\n\n return (\n <Text\n {...rest}\n style={[styles.icon, { color, fontSize: size }]}\n // @ts-expect-error: Text doesn't support this, but it seems to affect TouchableNativeFeedback\n pointerEvents=\"none\"\n selectable={false}\n >\n □\n </Text>\n );\n };\n}\n\nexport const accessibilityProps =\n Platform.OS === 'web'\n ? {\n role: 'img',\n focusable: false,\n }\n : {\n accessibilityElementsHidden: true,\n importantForAccessibility: 'no-hide-descendants' as 'no-hide-descendants',\n };\n\nconst defaultIcon = ({\n name,\n color,\n size,\n direction,\n allowFontScaling,\n}: IconProps) => (\n <MaterialCommunityIcons\n allowFontScaling={allowFontScaling}\n name={name}\n color={color}\n size={size}\n style={[\n {\n transform: [{ scaleX: direction === 'rtl' ? -1 : 1 }],\n lineHeight: size,\n },\n styles.icon,\n ]}\n pointerEvents=\"none\"\n selectable={false}\n {...accessibilityProps}\n />\n);\n\nconst styles = StyleSheet.create({\n icon: {\n backgroundColor: 'transparent',\n },\n});\n\nexport default defaultIcon;\n"]}
\No newline at end of file