repoweaver
Version:
A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies
1 lines • 13 kB
JSON
{"ast":null,"code":"import React from 'react';\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport overlay from \"../../styles/overlay\";\nimport { black, white } from \"../../styles/themes/v2/colors\";\nconst borderStyleProperties = ['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius'];\nexport const getAppbarBackgroundColor = (theme, elevation, customBackground, elevated) => {\n const {\n isV3,\n dark: isDarkTheme,\n mode,\n colors\n } = theme;\n const isAdaptiveMode = mode === 'adaptive';\n if (customBackground) {\n return customBackground;\n }\n if (!isV3) {\n if (isDarkTheme && isAdaptiveMode) {\n return overlay(elevation, colors === null || colors === void 0 ? void 0 : colors.surface);\n }\n return colors.primary;\n }\n if (elevated) {\n return theme.colors.elevation.level2;\n }\n return colors.surface;\n};\nexport const getAppbarColor = ({\n color,\n isDark,\n isV3\n}) => {\n if (typeof color !== 'undefined') {\n return color;\n }\n if (isDark) {\n return white;\n }\n if (isV3) {\n return undefined;\n }\n return black;\n};\nexport const getAppbarBorders = style => {\n const borders = {};\n for (const property of borderStyleProperties) {\n const value = style[property];\n if (value) {\n borders[property] = value;\n }\n }\n return borders;\n};\nexport const DEFAULT_APPBAR_HEIGHT = 56;\nconst MD3_DEFAULT_APPBAR_HEIGHT = 64;\nexport const modeAppbarHeight = {\n small: MD3_DEFAULT_APPBAR_HEIGHT,\n medium: 112,\n large: 152,\n 'center-aligned': MD3_DEFAULT_APPBAR_HEIGHT\n};\nexport const modeTextVariant = {\n small: 'titleLarge',\n medium: 'headlineSmall',\n large: 'headlineMedium',\n 'center-aligned': 'titleLarge'\n};\nexport const filterAppbarActions = (children, isLeading = false) => {\n return React.Children.toArray(children).filter(child => {\n if (!React.isValidElement(child)) return false;\n return isLeading ? child.props.isLeading : !child.props.isLeading;\n });\n};\nexport const renderAppbarContent = ({\n children,\n isDark,\n shouldCenterContent = false,\n isV3,\n renderOnly,\n renderExcept,\n mode = 'small',\n theme\n}) => {\n return React.Children.toArray(children).filter(child => child != null && typeof child !== 'boolean').filter(child => renderExcept ? !renderExcept.includes(child.type.displayName) : child).filter(child => renderOnly ? renderOnly.includes(child.type.displayName) : child).map((child, i) => {\n if (!React.isValidElement(child) || !['Appbar.Content', 'Appbar.Action', 'Appbar.BackAction', 'Tooltip'].includes(child.type.displayName)) {\n return child;\n }\n const props = {\n theme,\n color: getAppbarColor({\n color: child.props.color,\n isDark,\n isV3\n })\n };\n if (child.type.displayName === 'Appbar.Content') {\n props.mode = mode;\n props.style = [isV3 ? i === 0 && !shouldCenterContent && styles.v3Spacing : i !== 0 && styles.v2Spacing, shouldCenterContent && styles.centerAlignedContent, child.props.style];\n props.color;\n }\n return React.cloneElement(child, props);\n });\n};\nconst styles = StyleSheet.create({\n centerAlignedContent: {\n alignItems: 'center'\n },\n v2Spacing: {\n marginLeft: 8\n },\n v3Spacing: {\n marginLeft: 12\n }\n});","map":{"version":3,"names":["React","StyleSheet","overlay","black","white","borderStyleProperties","getAppbarBackgroundColor","theme","elevation","customBackground","elevated","isV3","dark","isDarkTheme","mode","colors","isAdaptiveMode","surface","primary","level2","getAppbarColor","color","isDark","undefined","getAppbarBorders","style","borders","property","value","DEFAULT_APPBAR_HEIGHT","MD3_DEFAULT_APPBAR_HEIGHT","modeAppbarHeight","small","medium","large","modeTextVariant","filterAppbarActions","children","isLeading","Children","toArray","filter","child","isValidElement","props","renderAppbarContent","shouldCenterContent","renderOnly","renderExcept","includes","type","displayName","map","i","styles","v3Spacing","v2Spacing","centerAlignedContent","cloneElement","create","alignItems","marginLeft"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/Appbar/utils.ts"],"sourcesContent":["import React from 'react';\nimport type { ColorValue, StyleProp, ViewStyle } from 'react-native';\nimport { StyleSheet, Animated } from 'react-native';\n\nimport overlay from '../../styles/overlay';\nimport { black, white } from '../../styles/themes/v2/colors';\nimport type { InternalTheme, ThemeProp } from '../../types';\n\nexport type AppbarModes = 'small' | 'medium' | 'large' | 'center-aligned';\n\nexport type AppbarChildProps = {\n isLeading?: boolean;\n color: string;\n style?: StyleProp<ViewStyle>;\n};\n\nconst borderStyleProperties = [\n 'borderRadius',\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n];\n\nexport const getAppbarBackgroundColor = (\n theme: InternalTheme,\n elevation: number,\n customBackground?: ColorValue,\n elevated?: boolean\n) => {\n const { isV3, dark: isDarkTheme, mode, colors } = theme;\n const isAdaptiveMode = mode === 'adaptive';\n if (customBackground) {\n return customBackground;\n }\n\n if (!isV3) {\n if (isDarkTheme && isAdaptiveMode) {\n return overlay(elevation, colors?.surface);\n }\n\n return colors.primary;\n }\n\n if (elevated) {\n return theme.colors.elevation.level2;\n }\n\n return colors.surface;\n};\n\nexport const getAppbarColor = ({\n color,\n isDark,\n isV3,\n}: BaseProps & { color: string }) => {\n if (typeof color !== 'undefined') {\n return color;\n }\n\n if (isDark) {\n return white;\n }\n\n if (isV3) {\n return undefined;\n }\n\n return black;\n};\n\nexport const getAppbarBorders = (\n style:\n | Animated.Value\n | Animated.AnimatedInterpolation<string | number>\n | Animated.WithAnimatedObject<ViewStyle>\n) => {\n const borders: Record<string, number> = {};\n\n for (const property of borderStyleProperties) {\n const value = style[property as keyof typeof style];\n if (value) {\n borders[property] = value;\n }\n }\n\n return borders;\n};\n\ntype BaseProps = {\n isDark: boolean;\n isV3: boolean;\n};\n\ntype RenderAppbarContentProps = BaseProps & {\n children: React.ReactNode;\n shouldCenterContent?: boolean;\n isV3: boolean;\n renderOnly?: (string | boolean)[];\n renderExcept?: string[];\n mode?: AppbarModes;\n theme?: ThemeProp;\n};\n\nexport const DEFAULT_APPBAR_HEIGHT = 56;\nconst MD3_DEFAULT_APPBAR_HEIGHT = 64;\n\nexport const modeAppbarHeight = {\n small: MD3_DEFAULT_APPBAR_HEIGHT,\n medium: 112,\n large: 152,\n 'center-aligned': MD3_DEFAULT_APPBAR_HEIGHT,\n};\n\nexport const modeTextVariant = {\n small: 'titleLarge',\n medium: 'headlineSmall',\n large: 'headlineMedium',\n 'center-aligned': 'titleLarge',\n} as const;\n\nexport const filterAppbarActions = (\n children: React.ReactNode,\n isLeading = false\n) => {\n return React.Children.toArray(children).filter((child) => {\n if (!React.isValidElement<AppbarChildProps>(child)) return false;\n return isLeading ? child.props.isLeading : !child.props.isLeading;\n });\n};\n\nexport const renderAppbarContent = ({\n children,\n isDark,\n shouldCenterContent = false,\n isV3,\n renderOnly,\n renderExcept,\n mode = 'small',\n theme,\n}: RenderAppbarContentProps) => {\n return React.Children.toArray(children as React.ReactNode | React.ReactNode[])\n .filter((child) => child != null && typeof child !== 'boolean')\n .filter((child) =>\n // @ts-expect-error: TypeScript complains about the type of type but it doesn't matter\n renderExcept ? !renderExcept.includes(child.type.displayName) : child\n )\n .filter((child) =>\n // @ts-expect-error: TypeScript complains about the type of type but it doesn't matter\n renderOnly ? renderOnly.includes(child.type.displayName) : child\n )\n .map((child, i) => {\n if (\n !React.isValidElement<AppbarChildProps>(child) ||\n ![\n 'Appbar.Content',\n 'Appbar.Action',\n 'Appbar.BackAction',\n 'Tooltip',\n ].includes(\n // @ts-expect-error: TypeScript complains about the type of type but it doesn't matter\n child.type.displayName\n )\n ) {\n return child;\n }\n\n const props: {\n color?: string;\n style?: StyleProp<ViewStyle>;\n mode?: AppbarModes;\n theme?: ThemeProp;\n } = {\n theme,\n color: getAppbarColor({ color: child.props.color, isDark, isV3 }),\n };\n\n // @ts-expect-error: TypeScript complains about the type of type but it doesn't matter\n if (child.type.displayName === 'Appbar.Content') {\n props.mode = mode;\n props.style = [\n isV3\n ? i === 0 && !shouldCenterContent && styles.v3Spacing\n : i !== 0 && styles.v2Spacing,\n shouldCenterContent && styles.centerAlignedContent,\n child.props.style,\n ];\n props.color;\n }\n return React.cloneElement(child, props);\n });\n};\n\nconst styles = StyleSheet.create({\n centerAlignedContent: {\n alignItems: 'center',\n },\n v2Spacing: {\n marginLeft: 8,\n },\n v3Spacing: {\n marginLeft: 12,\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAAA,OAAAC,UAAA;AAIzB,OAAOC,OAAO;AACd,SAASC,KAAK,EAAEC,KAAK;AAWrB,MAAMC,qBAAqB,GAAG,CAC5B,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,CACzB;AAED,OAAO,MAAMC,wBAAwB,GAAGA,CACtCC,KAAoB,EACpBC,SAAiB,EACjBC,gBAA6B,EAC7BC,QAAkB,KACf;EACH,MAAM;IAAEC,IAAI;IAAEC,IAAI,EAAEC,WAAW;IAAEC,IAAI;IAAEC;EAAO,CAAC,GAAGR,KAAK;EACvD,MAAMS,cAAc,GAAGF,IAAI,KAAK,UAAU;EAC1C,IAAIL,gBAAgB,EAAE;IACpB,OAAOA,gBAAgB;EACzB;EAEA,IAAI,CAACE,IAAI,EAAE;IACT,IAAIE,WAAW,IAAIG,cAAc,EAAE;MACjC,OAAOd,OAAO,CAACM,SAAS,EAAEO,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,OAAO,CAAC;IAC5C;IAEA,OAAOF,MAAM,CAACG,OAAO;EACvB;EAEA,IAAIR,QAAQ,EAAE;IACZ,OAAOH,KAAK,CAACQ,MAAM,CAACP,SAAS,CAACW,MAAM;EACtC;EAEA,OAAOJ,MAAM,CAACE,OAAO;AACvB,CAAC;AAED,OAAO,MAAMG,cAAc,GAAGA,CAAC;EAC7BC,KAAK;EACLC,MAAM;EACNX;AAC6B,CAAC,KAAK;EACnC,IAAI,OAAOU,KAAK,KAAK,WAAW,EAAE;IAChC,OAAOA,KAAK;EACd;EAEA,IAAIC,MAAM,EAAE;IACV,OAAOlB,KAAK;EACd;EAEA,IAAIO,IAAI,EAAE;IACR,OAAOY,SAAS;EAClB;EAEA,OAA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CAClB;MACDmB,KAAK,CAACvB,KAAK;IACb;IACA,OAAOrB,KAAK,CAAC0D,YAAY,CAAChB,KAAK,EAAEE,KAAK,CAAC;EACzC,CAAC,CAAC;AACN,CAAC;AAED,MAAMU,MAAM,GAAGrD,UAAU,CAAC0D,MAAM,CAAC;EAC/BF,oBAAoB,EAAE;IACpBG,UAAU,EAAE;EACd,CAAC;EACDJ,SAAS,EAAE;IACTK,UAAU,EAAE;EACd,CAAC;EACDN,SAAS,EAAE;IACTM,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]},"metadata":{"hasCjsExports":false},"sourceType":"module","externalDependencies":[]}