UNPKG

@eslam-elmeniawy/react-native-common-components

Version:

Common `ReactNative` components packed in library for usage in projects.

84 lines (80 loc) 2.53 kB
"use strict"; // External imports. import * as React from 'react'; import { StyleSheet, View } from 'react-native'; import { withTheme } from 'react-native-paper'; // Types imports. // Internal imports. import styles from "./AlertDialog.styles.js"; import { Dialog } from "../Dialog/index.js"; import { Text } from "../Text/index.js"; import { Button } from "../Button/index.js"; /** * AlertDialogComponent (unwrapped, for testing) * @internal For testing purposes only. Do not use in production code. */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const AlertDialogComponent = /*#__PURE__*/React.memo(props => { const { dialogProps, title, titleProps, message, messageProps, actions, theme } = props; const { style: dialogStyle, ...dialogOther } = dialogProps ?? {}; const { type: titleType, size: titleSize, ...titleOther } = titleProps ?? {}; return /*#__PURE__*/_jsxs(Dialog, { style: StyleSheet.flatten([styles.dialog, dialogStyle]), ...dialogOther, children: [Boolean(title) && /*#__PURE__*/_jsx(Text, { type: titleType ?? 'bold', size: titleSize ?? 18, ...titleOther, children: title }), Boolean(message) && /*#__PURE__*/_jsx(Text, { ...(messageProps ?? {}), children: message }), /*#__PURE__*/_jsx(View, { style: StyleSheet.flatten([styles.actionsContainer, (actions?.length ?? 0) > 2 ? styles.actionsContainerColumn : styles.actionsContainerRow]), children: actions?.map(action => { if (action.action) { const { style: actionStyle, textProps: actionTextProps, ...actionOther } = action.actionProps ?? {}; const { style: actionTextStyle, ...actionTextOther } = actionTextProps ?? {}; return /*#__PURE__*/_jsx(Button, { style: StyleSheet.flatten([styles.action, (actions?.length ?? 0) > 2 ? undefined : styles.actionRow, actionStyle]), textProps: { style: StyleSheet.flatten([{ color: theme.colors.primary }, actionTextStyle]), ...actionTextOther }, text: action.action, ...actionOther }, action.action); } return null; }) })] }); }); const AlertDialog = withTheme(AlertDialogComponent); export { AlertDialogComponent }; export default AlertDialog; //# sourceMappingURL=AlertDialog.js.map