@eslam-elmeniawy/react-native-common-components
Version:
Common `ReactNative` components packed in library for usage in projects.
85 lines (81 loc) • 3.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativePaper = require("react-native-paper");
var _AlertDialogStyles = _interopRequireDefault(require("./AlertDialog.styles.js"));
var _index = require("../Dialog/index.js");
var _index2 = require("../Text/index.js");
var _index3 = require("../Button/index.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
// External imports.
// Types imports.
// Internal imports.
const AlertDialog = /*#__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__*/(0, _jsxRuntime.jsxs)(_index.Dialog, {
style: _reactNative.StyleSheet.flatten([_AlertDialogStyles.default.dialog, dialogStyle]),
...dialogOther,
children: [Boolean(title) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Text, {
type: titleType ?? 'bold',
size: titleSize ?? 18,
...titleOther,
children: title
}), Boolean(message) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Text, {
...(messageProps ?? {}),
children: message
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: _reactNative.StyleSheet.flatten([_AlertDialogStyles.default.actionsContainer, (actions?.length ?? 0) > 2 ? _AlertDialogStyles.default.actionsContainerColumn : _AlertDialogStyles.default.actionsContainerRow]),
children: actions?.map(action => {
if (action.action) {
const {
style: actionStyle,
textProps: actionTextProps,
...actionOther
} = action.actionProps ?? {};
const {
style: actionTextStyle,
...actionTextOther
} = actionTextProps ?? {};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index3.Button, {
style: _reactNative.StyleSheet.flatten([_AlertDialogStyles.default.action, (actions?.length ?? 0) > 2 ? undefined : _AlertDialogStyles.default.actionRow, actionStyle]),
textProps: {
style: _reactNative.StyleSheet.flatten([{
color: theme.colors.primary
}, actionTextStyle]),
...actionTextOther
},
text: action.action,
...actionOther
}, action.action);
}
return null;
})
})]
});
});
var _default = exports.default = (0, _reactNativePaper.withTheme)(AlertDialog);
//# sourceMappingURL=AlertDialog.js.map