UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 12.9 kB
{"ast":null,"code":"import _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/objectWithoutPropertiesLoose\";\nconst _excluded = [\"style\", \"variant\", \"theme\"];\nfunction _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nimport * as React from 'react';\nimport I18nManager from \"react-native-web/dist/exports/I18nManager\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport NativeText from \"react-native-web/dist/exports/Text\";\nimport AnimatedText from \"./AnimatedText\";\nimport StyledText from \"./v2/StyledText\";\nimport { useInternalTheme } from \"../../core/theming\";\nimport { forwardRef } from \"../../utils/forwardRef\";\nconst Text = (_ref, ref) => {\n let {\n style,\n variant,\n theme: initialTheme\n } = _ref,\n rest = _objectWithoutPropertiesLoose(_ref, _excluded);\n const root = React.useRef(null);\n const theme = useInternalTheme(initialTheme);\n const writingDirection = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';\n React.useImperativeHandle(ref, () => ({\n setNativeProps: args => {\n var _root$current;\n return (_root$current = root.current) === null || _root$current === void 0 ? void 0 : _root$current.setNativeProps(args);\n }\n }));\n if (theme.isV3 && variant) {\n let font = theme.fonts[variant];\n let textStyle = [font, style];\n if (React.isValidElement(rest.children) && (rest.children.type === Component || rest.children.type === AnimatedText || rest.children.type === StyledText)) {\n const {\n props\n } = rest.children;\n if (props.variant) {\n font = theme.fonts[props.variant];\n textStyle = [style, font];\n }\n if (!props.variant) {\n textStyle = [style, props.style];\n }\n }\n if (typeof font !== 'object') {\n throw new Error(`Variant ${variant} was not provided properly. Valid variants are ${Object.keys(theme.fonts).join(', ')}.`);\n }\n return React.createElement(NativeText, _extends({\n ref: root,\n style: [styles.text, {\n writingDirection,\n color: theme.colors.onSurface\n }, textStyle]\n }, rest));\n } else {\n var _theme$fonts, _theme$colors;\n const font = theme.isV3 ? theme.fonts.default : (_theme$fonts = theme.fonts) === null || _theme$fonts === void 0 ? void 0 : _theme$fonts.regular;\n const textStyle = Object.assign({}, font, {\n color: theme.isV3 ? (_theme$colors = theme.colors) === null || _theme$colors === void 0 ? void 0 : _theme$colors.onSurface : theme.colors.text\n });\n return React.createElement(NativeText, _extends({}, rest, {\n ref: root,\n style: [styles.text, textStyle, {\n writingDirection\n }, style]\n }));\n }\n};\nconst styles = StyleSheet.create({\n text: {\n textAlign: 'left'\n }\n});\nconst Component = forwardRef(Text);\nexport const customText = () => Component;\nexport default Component;","map":{"version":3,"names":["React","I18nManager","StyleSheet","NativeText","AnimatedText","StyledText","useInternalTheme","forwardRef","Text","_ref","ref","style","variant","theme","initialTheme","rest","_objectWithoutPropertiesLoose","_excluded","root","useRef","writingDirection","getConstants","isRTL","useImperativeHandle","setNativeProps","args","_root$current","current","isV3","font","fonts","textStyle","isValidElement","children","type","Component","props","Error","Object","keys","join","createElement","_extends","styles","text","color","colors","onSurface","_theme$fonts","_theme$colors","default","regular","assign","create","textAlign","customText"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/Typography/Text.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n I18nManager,\n StyleProp,\n StyleSheet,\n Text as NativeText,\n TextStyle,\n} from 'react-native';\n\nimport AnimatedText from './AnimatedText';\nimport type { VariantProp } from './types';\nimport StyledText from './v2/StyledText';\nimport { useInternalTheme } from '../../core/theming';\nimport type { ThemeProp } from '../../types';\nimport { forwardRef } from '../../utils/forwardRef';\n\nexport type Props<T> = React.ComponentProps<typeof NativeText> & {\n /**\n * @supported Available in v5.x with theme version 3\n *\n * Variant defines appropriate text styles for type role and its size.\n * Available variants:\n *\n * Display: `displayLarge`, `displayMedium`, `displaySmall`\n *\n * Headline: `headlineLarge`, `headlineMedium`, `headlineSmall`\n *\n * Title: `titleLarge`, `titleMedium`, `titleSmall`\n *\n * Label: `labelLarge`, `labelMedium`, `labelSmall`\n *\n * Body: `bodyLarge`, `bodyMedium`, `bodySmall`\n */\n variant?: VariantProp<T>;\n children: React.ReactNode;\n theme?: ThemeProp;\n style?: StyleProp<TextStyle>;\n};\n\nexport type TextRef = React.ForwardedRef<{\n setNativeProps(args: Object): void;\n}>;\n\n// @component-group Typography\n\n/**\n * Typography component showing styles complied with passed `variant` prop and supported by the type system.\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Text } from 'react-native-paper';\n *\n * const MyComponent = () => (\n * <>\n * <Text variant=\"displayLarge\">Display Large</Text>\n * <Text variant=\"displayMedium\">Display Medium</Text>\n * <Text variant=\"displaySmall\">Display small</Text>\n *\n * <Text variant=\"headlineLarge\">Headline Large</Text>\n * <Text variant=\"headlineMedium\">Headline Medium</Text>\n * <Text variant=\"headlineSmall\">Headline Small</Text>\n *\n * <Text variant=\"titleLarge\">Title Large</Text>\n * <Text variant=\"titleMedium\">Title Medium</Text>\n * <Text variant=\"titleSmall\">Title Small</Text>\n *\n * <Text variant=\"bodyLarge\">Body Large</Text>\n * <Text variant=\"bodyMedium\">Body Medium</Text>\n * <Text variant=\"bodySmall\">Body Small</Text>\n *\n * <Text variant=\"labelLarge\">Label Large</Text>\n * <Text variant=\"labelMedium\">Label Medium</Text>\n * <Text variant=\"labelSmall\">Label Small</Text>\n * </>\n * );\n *\n * export default MyComponent;\n * ```\n *\n * @extends Text props https://reactnative.dev/docs/text#props\n */\nconst Text = (\n { style, variant, theme: initialTheme, ...rest }: Props<string>,\n ref: TextRef\n) => {\n const root = React.useRef<NativeText | null>(null);\n // FIXME: destructure it in TS 4.6+\n const theme = useInternalTheme(initialTheme);\n const writingDirection = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';\n\n React.useImperativeHandle(ref, () => ({\n setNativeProps: (args: Object) => root.current?.setNativeProps(args),\n }));\n\n if (theme.isV3 && variant) {\n let font = theme.fonts[variant];\n let textStyle = [font, style];\n\n if (\n React.isValidElement(rest.children) &&\n (rest.children.type === Component ||\n rest.children.type === AnimatedText ||\n rest.children.type === StyledText)\n ) {\n const { props } = rest.children as {\n props: { variant?: string; style?: StyleProp<TextStyle> };\n };\n\n // Context: Some components have the built-in `Text` component with a predefined variant,\n // that also accepts `children` as a `React.Node`. This can result in a situation,\n // where another `Text` component is rendered within the built-in `Text` component.\n // By doing that, we assume that user doesn't want to consume pre-defined font properties.\n // Case one: Nested `Text` has different `variant` that specified in parent. For example:\n // <Chip>\n // <Text variant=\"displayMedium\">Nested</Text>\n // </Chip>\n // Solution: To address the following scenario, the code below overrides the `variant`\n // specified in a parent in favor of children's variant:\n if (props.variant) {\n font = theme.fonts[props.variant as VariantProp<typeof props.variant>];\n textStyle = [style, font];\n }\n\n // Case two: Nested `Text` has specified `styles` which intefere\n // with font properties, from the parent's `variant`. For example:\n // <Chip>\n // <Text style={{fontSize: 30}}>Nested</Text>\n // </Chip>\n // Solution: To address the following scenario, the code below overrides the\n // parent's style with children's style:\n if (!props.variant) {\n textStyle = [style, props.style];\n }\n }\n\n if (typeof font !== 'object') {\n throw new Error(\n `Variant ${variant} was not provided properly. Valid variants are ${Object.keys(\n theme.fonts\n ).join(', ')}.`\n );\n }\n\n return (\n <NativeText\n ref={root}\n style={[\n styles.text,\n { writingDirection, color: theme.colors.onSurface },\n textStyle,\n ]}\n {...rest}\n />\n );\n } else {\n const font = theme.isV3 ? theme.fonts.default : theme.fonts?.regular;\n const textStyle = {\n ...font,\n color: theme.isV3 ? theme.colors?.onSurface : theme.colors.text,\n };\n return (\n <NativeText\n {...rest}\n ref={root}\n style={[styles.text, textStyle, { writingDirection }, style]}\n />\n );\n }\n};\n\nconst styles = StyleSheet.create({\n text: {\n textAlign: 'left',\n },\n});\n\ntype TextComponent<T> = (\n props: Props<T> & { ref?: React.RefObject<TextRef> }\n) => JSX.Element;\n\nconst Component = forwardRef(Text) as TextComponent<never>;\n\nexport const customText = <T,>() => Component as unknown as TextComponent<T>;\n\nexport default Component;\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAA,OAAAC,WAAA;AAAA,OAAAC,UAAA;AAAA,OAAAC,UAAA;AAS9B,OAAOC,YAAY;AAEnB,OAAOC,UAAU;AACjB,SAASC,gBAAgB;AAEzB,SAASC,UAAU;AAoEnB,MAAMC,IAAI,GAAGA,CAAAC,IAAA,EAEXC,GAAY,KACT;EAAA,IAFH;MAAEC,KAAK;MAAEC,OAAO;MAAEC,KAAK,EAAEC;IAAqC,CAAC,GAAAL,IAAA;IAArBM,IAAA,GAAAC,6BAAA,CAAAP,IAAA,EAAAQ,SAAA;EAG1C,MAAMC,IAAI,GAAGlB,KAAK,CAACmB,MAAM,CAAoB,IAAI,CAAC;EAElD,MAAMN,KAAK,GAAGP,gBAAgB,CAACQ,YAAY,CAAC;EAC5C,MAAMM,gBAAgB,GAAGnB,WAAW,CAACoB,YAAY,CAAC,CAAC,CAACC,KAAK,GAAG,KAAK,GAAG,KAAK;EAEzEtB,KAAK,CAACuB,mBAAmB,CAACb,GAAG,EAAE,OAAO;IACpCc,cAAc,EAAGC,IAAY;MAAA,IAAAC,aAAA;MAAA,QAAAA,aAAA,GAAKR,IAAI,CAACS,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcF,cAAc,CAACC,IAAI,CAAC;IAAA;EACtE,CAAC,CAAC,CAAC;EAEH,IAAIZ,KAAK,CAACe,IAAI,IAAIhB,OAAO,EAAE;IACzB,IAAIiB,IAAI,GAAGhB,KAAK,CAACiB,KAAK,CAAClB,OAAO,CAAC;IAC/B,IAAImB,SAAS,GAAG,CAACF,IAAI,EAAElB,KAAK,CAAC;IAE7B,IACEX,KAAK,CAACgC,cAAc,CAACjB,IAAI,CAACkB,QAAQ,CAAC,KAClClB,IAAI,CAACkB,QAAQ,CAACC,IAAI,KAAKC,SAAS,IAC/BpB,IAAI,CA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