UNPKG

repoweaver

Version:

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

1 lines 16.6 kB
{"ast":null,"code":"import * as React from 'react';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport Easing from \"react-native-web/dist/exports/Easing\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport Pressable from \"react-native-web/dist/exports/Pressable\";\nimport View from \"react-native-web/dist/exports/View\";\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useLatestCallback from 'use-latest-callback';\nimport Surface from \"./Surface\";\nimport { useInternalTheme } from \"../core/theming\";\nimport { addEventListener } from \"../utils/addEventListener\";\nimport { BackHandler } from \"../utils/BackHandler/BackHandler\";\nimport useAnimatedValue from \"../utils/useAnimatedValue\";\nconst DEFAULT_DURATION = 220;\nconst AnimatedPressable = Animated.createAnimatedComponent(Pressable);\nfunction Modal({\n dismissable = true,\n dismissableBackButton = dismissable,\n visible = false,\n overlayAccessibilityLabel = 'Close modal',\n onDismiss = () => {},\n children,\n contentContainerStyle,\n style,\n theme: themeOverrides,\n testID = 'modal'\n}) {\n var _theme$colors;\n const theme = useInternalTheme(themeOverrides);\n const onDismissCallback = useLatestCallback(onDismiss);\n const {\n scale\n } = theme.animation;\n const {\n top,\n bottom\n } = useSafeAreaInsets();\n const opacity = useAnimatedValue(visible ? 1 : 0);\n const [visibleInternal, setVisibleInternal] = React.useState(visible);\n const showModalAnimation = React.useCallback(() => {\n Animated.timing(opacity, {\n toValue: 1,\n duration: scale * DEFAULT_DURATION,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true\n }).start();\n }, [opacity, scale]);\n const hideModalAnimation = React.useCallback(() => {\n Animated.timing(opacity, {\n toValue: 0,\n duration: scale * DEFAULT_DURATION,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true\n }).start(({\n finished\n }) => {\n if (!finished) {\n return;\n }\n setVisibleInternal(false);\n });\n }, [opacity, scale]);\n React.useEffect(() => {\n if (visibleInternal === visible) {\n return;\n }\n if (!visibleInternal && visible) {\n setVisibleInternal(true);\n return showModalAnimation();\n }\n if (visibleInternal && !visible) {\n return hideModalAnimation();\n }\n }, [visible, showModalAnimation, hideModalAnimation, visibleInternal]);\n React.useEffect(() => {\n if (!visible) {\n return undefined;\n }\n const onHardwareBackPress = () => {\n if (dismissable || dismissableBackButton) {\n onDismissCallback();\n }\n return true;\n };\n const subscription = addEventListener(BackHandler, 'hardwareBackPress', onHardwareBackPress);\n return () => subscription.remove();\n }, [dismissable, dismissableBackButton, onDismissCallback, visible]);\n if (!visibleInternal) {\n return null;\n }\n return React.createElement(Animated.View, {\n pointerEvents: visible ? 'auto' : 'none',\n accessibilityViewIsModal: true,\n accessibilityLiveRegion: \"polite\",\n style: StyleSheet.absoluteFill,\n onAccessibilityEscape: onDismissCallback,\n testID: testID\n }, React.createElement(AnimatedPressable, {\n accessibilityLabel: overlayAccessibilityLabel,\n accessibilityRole: \"button\",\n disabled: !dismissable,\n onPress: dismissable ? onDismissCallback : undefined,\n importantForAccessibility: \"no\",\n style: [styles.backdrop, {\n backgroundColor: (_theme$colors = theme.colors) === null || _theme$colors === void 0 ? void 0 : _theme$colors.backdrop,\n opacity\n }],\n testID: `${testID}-backdrop`\n }), React.createElement(View, {\n style: [styles.wrapper, {\n marginTop: top,\n marginBottom: bottom\n }, style],\n pointerEvents: \"box-none\",\n testID: `${testID}-wrapper`\n }, React.createElement(Surface, {\n testID: `${testID}-surface`,\n theme: theme,\n style: [{\n opacity\n }, styles.content, contentContainerStyle],\n container: true\n }, children)));\n}\nexport default Modal;\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1\n },\n wrapper: Object.assign({}, StyleSheet.absoluteFillObject, {\n justifyContent: 'center'\n }),\n content: {\n backgroundColor: 'transparent',\n justifyContent: 'center'\n }\n});","map":{"version":3,"names":["React","Animated","Easing","StyleSheet","Pressable","View","useSafeAreaInsets","useLatestCallback","Surface","useInternalTheme","addEventListener","BackHandler","useAnimatedValue","DEFAULT_DURATION","AnimatedPressable","createAnimatedComponent","Modal","dismissable","dismissableBackButton","visible","overlayAccessibilityLabel","onDismiss","children","contentContainerStyle","style","theme","themeOverrides","testID","_theme$colors","onDismissCallback","scale","animation","top","bottom","opacity","visibleInternal","setVisibleInternal","useState","showModalAnimation","useCallback","timing","toValue","duration","easing","out","cubic","useNativeDriver","start","hideModalAnimation","finished","useEffect","undefined","onHardwareBackPress","subscription","remove","createElement","pointerEvents","accessibilityViewIsModal","accessibilityLiveRegion","absoluteFill","onAccessibilityEscape","accessibilityLabel","accessibilityRole","disabled","onPress","importantForAccessibility","styles","backdrop","backgroundColor","colors","wrapper","marginTop","marginBottom","content","container","create","flex","Object","assign","absoluteFillObject","justifyContent"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/Modal.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n Easing,\n StyleProp,\n StyleSheet,\n Pressable,\n View,\n ViewStyle,\n} from 'react-native';\n\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useLatestCallback from 'use-latest-callback';\n\nimport Surface from './Surface';\nimport { useInternalTheme } from '../core/theming';\nimport type { ThemeProp } from '../types';\nimport { addEventListener } from '../utils/addEventListener';\nimport { BackHandler } from '../utils/BackHandler/BackHandler';\nimport useAnimatedValue from '../utils/useAnimatedValue';\n\nexport type Props = {\n /**\n * Determines whether clicking outside the modal dismisses it.\n */\n dismissable?: boolean;\n /**\n * Determines whether clicking Android hardware back button dismisses the dialog.\n */\n dismissableBackButton?: boolean;\n /**\n * Callback that is called when the user dismisses the modal.\n */\n onDismiss?: () => void;\n /**\n * Accessibility label for the overlay. This is read by the screen reader when the user taps outside the modal.\n */\n overlayAccessibilityLabel?: string;\n /**\n * Determines Whether the modal is visible.\n */\n visible: boolean;\n /**\n * Content of the `Modal`.\n */\n children: React.ReactNode;\n /**\n * Style for the content of the modal\n */\n contentContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;\n /**\n * Style for the wrapper of the modal.\n * Use this prop to change the default wrapper style or to override safe area insets with marginTop and marginBottom.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * @optional\n */\n theme?: ThemeProp;\n /**\n * testID to be used on tests.\n */\n testID?: string;\n};\n\nconst DEFAULT_DURATION = 220;\nconst AnimatedPressable = Animated.createAnimatedComponent(Pressable);\n\n/**\n * The Modal component is a simple way to present content above an enclosing view.\n * To render the `Modal` above other components, you'll need to wrap it with the [`Portal`](./Portal) component.\n * Note that this modal is NOT accessible by default; if you need an accessible modal, please use the React Native Modal.\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Modal, Portal, Text, Button, PaperProvider } from 'react-native-paper';\n *\n * const MyComponent = () => {\n * const [visible, setVisible] = React.useState(false);\n *\n * const showModal = () => setVisible(true);\n * const hideModal = () => setVisible(false);\n * const containerStyle = {backgroundColor: 'white', padding: 20};\n *\n * return (\n * <PaperProvider>\n * <Portal>\n * <Modal visible={visible} onDismiss={hideModal} contentContainerStyle={containerStyle}>\n * <Text>Example Modal. Click outside this area to dismiss.</Text>\n * </Modal>\n * </Portal>\n * <Button style={{marginTop: 30}} onPress={showModal}>\n * Show\n * </Button>\n * </PaperProvider>\n * );\n * };\n *\n * export default MyComponent;\n * ```\n */\nfunction Modal({\n dismissable = true,\n dismissableBackButton = dismissable,\n visible = false,\n overlayAccessibilityLabel = 'Close modal',\n onDismiss = () => {},\n children,\n contentContainerStyle,\n style,\n theme: themeOverrides,\n testID = 'modal',\n}: Props) {\n const theme = useInternalTheme(themeOverrides);\n const onDismissCallback = useLatestCallback(onDismiss);\n const { scale } = theme.animation;\n const { top, bottom } = useSafeAreaInsets();\n const opacity = useAnimatedValue(visible ? 1 : 0);\n const [visibleInternal, setVisibleInternal] = React.useState(visible);\n\n const showModalAnimation = React.useCallback(() => {\n Animated.timing(opacity, {\n toValue: 1,\n duration: scale * DEFAULT_DURATION,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n }, [opacity, scale]);\n\n const hideModalAnimation = React.useCallback(() => {\n Animated.timing(opacity, {\n toValue: 0,\n duration: scale * DEFAULT_DURATION,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start(({ finished }) => {\n if (!finished) {\n return;\n }\n\n setVisibleInternal(false);\n });\n }, [opacity, scale]);\n\n React.useEffect(() => {\n if (visibleInternal === visible) {\n return;\n }\n\n if (!visibleInternal && visible) {\n setVisibleInternal(true);\n return showModalAnimation();\n }\n\n if (visibleInternal && !visible) {\n return hideModalAnimation();\n }\n }, [visible, showModalAnimation, hideModalAnimation, visibleInternal]);\n\n React.useEffect(() => {\n if (!visible) {\n return undefined;\n }\n\n const onHardwareBackPress = () => {\n if (dismissable || dismissableBackButton) {\n onDismissCallback();\n }\n\n return true;\n };\n\n const subscription = addEventListener(\n BackHandler,\n 'hardwareBackPress',\n onHardwareBackPress\n );\n return () => subscription.remove();\n }, [dismissable, dismissableBackButton, onDismissCallback, visible]);\n\n if (!visibleInternal) {\n return null;\n }\n\n return (\n <Animated.View\n pointerEvents={visible ? 'auto' : 'none'}\n accessibilityViewIsModal\n accessibilityLiveRegion=\"polite\"\n style={StyleSheet.absoluteFill}\n onAccessibilityEscape={onDismissCallback}\n testID={testID}\n >\n <AnimatedPressable\n accessibilityLabel={overlayAccessibilityLabel}\n accessibilityRole=\"button\"\n disabled={!dismissable}\n onPress={dismissable ? onDismissCallback : undefined}\n importantForAccessibility=\"no\"\n style={[\n styles.backdrop,\n {\n backgroundColor: theme.colors?.backdrop,\n opacity,\n },\n ]}\n testID={`${testID}-backdrop`}\n />\n <View\n style={[\n styles.wrapper,\n { marginTop: top, marginBottom: bottom },\n style,\n ]}\n pointerEvents=\"box-none\"\n testID={`${testID}-wrapper`}\n >\n <Surface\n testID={`${testID}-surface`}\n theme={theme}\n style={[{ opacity }, styles.content, contentContainerStyle]}\n container\n >\n {children}\n </Surface>\n </View>\n </Animated.View>\n );\n}\n\nexport default Modal;\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n },\n wrapper: {\n ...StyleSheet.absoluteFillObject,\n justifyContent: 'center',\n },\n // eslint-disable-next-line react-native/no-color-literals\n content: {\n backgroundColor: 'transparent',\n justifyContent: 'center',\n },\n});\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAA,OAAAC,QAAA;AAAA,OAAAC,MAAA;AAAA,OAAAC,UAAA;AAAA,OAAAC,SAAA;AAAA,OAAAC,IAAA;AAW9B,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,OAAOC,iBAAiB,MAAM,qBAAqB;AAEnD,OAAOC,OAAO;AACd,SAASC,gBAAgB;AAEzB,SAASC,gBAAgB;AACzB,SAASC,WAAW;AACpB,OAAOC,gBAAgB;AA8CvB,MAAMC,gBAAgB,GAAG,GAAG;AAC5B,MAAMC,iBAAiB,GAAGb,QAAQ,CAACc,uBAAuB,CAACX,SAAS,CAAC;AAoCrE,SAASY,KAAKA,CAAC;EACbC,WAAW,GAAG,IAAI;EAClBC,qBAAqB,GAAGD,WAAW;EACnCE,OAAO,GAAG,KAAK;EACfC,yBAAyB,GAAG,aAAa;EACzCC,SAAS,GAAGA,CAAA,KAAM,CAAC,CAAC;EACpBC,QAAQ;EACRC,qBAAqB;EACrBC,KAAK;EACLC,KAAK,EAAEC,cAAc;EACrBC,MAAM,GAAG;AACJ,CAAC,EAAE;EAAA,IAAAC,aAAA;EACR,MAAMH,KAAK,GAAGhB,gBAAgB,CAACiB,cAAc,CAAC;EAC9C,MAAMG,iBAAiB,GAAGtB,iBAAiB,CAACc,SAAS,CAAC;EACtD,MAAM;IAAES;EAAM,CAAC,GAAGL,KAAK,CAACM,SAAS;EACjC,MAAM;IAAEC,GAAG;IAAEC;EAAO,CAAC,GAAG3B,iBAAiB,CAAC,CAAC;EAC3C,MAAM4B,OAAO,GAAGtB,gBAAgB,CAACO,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;EACjD,MAAM,CAACgB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