react-web-native-sketch
Version:
[TODO: We need an overview of how this can be used via npm vs as a local package]
109 lines • 5.18 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var react_i18next_1 = require("react-i18next");
var react_redux_1 = require("react-redux");
var redux_1 = require("redux");
var View_1 = require("../../primitives/View/View");
var navigation_1 = require("../../redux/reducers/navigation");
var theme_1 = require("../../utils/theme");
var __1 = require("../..");
var core_1 = require("@material-ui/core");
var styles = function () { return ({
dataContainer: {
flexDirection: 'column',
},
title: {
marginTop: theme_1.appTheme.horizontalMargin,
marginLeft: theme_1.appTheme.horizontalMargin,
marginRight: theme_1.appTheme.horizontalMargin,
},
titleText: {
fontSize: 16,
fontWeight: '500',
},
bodyText: {
fontSize: 16,
fontWeight: '400',
},
button: {
paddingTop: theme_1.appTheme.defaultVerticalMargin,
paddingBottom: theme_1.appTheme.defaultVerticalMargin,
paddingLeft: theme_1.appTheme.defaultHorizontalMargin,
paddingRight: theme_1.appTheme.defaultHorizontalMargin,
},
buttonLabel: {
fontSize: 16,
},
}); };
var CAlert = /** @class */ (function (_super) {
__extends(CAlert, _super);
function CAlert() {
return _super !== null && _super.apply(this, arguments) || this;
}
CAlert.prototype.render = function () {
var _a = this.props, classes = _a.classes, alertId = _a.alertId, alerts = _a.alerts, title = _a.title, hideAlert = _a.hideAlert, onClose = _a.onClose, leftButtonText = _a.leftButtonText, leftButtonOnPress = _a.leftButtonOnPress, rightButtonText = _a.rightButtonText, rightButtonOnPress = _a.rightButtonOnPress, t = _a.t;
return alerts
.filter(function (alert) { return alert.alertId === alertId; })
.map(function (_a, index) {
var visible = _a.visible, body = _a.body, bodyData = _a.bodyData;
return (React.createElement(core_1.Dialog, { key: index, onClose: function () {
onClose && onClose();
hideAlert(body, alertId);
}, open: visible, fullWidth: true },
React.createElement(View_1.View, { style: classes.dataContainer },
title &&
React.createElement(core_1.DialogTitle, null, typeof title === 'string' ? title : title),
body &&
React.createElement(core_1.DialogContent, null, typeof body === 'string'
? React.createElement(core_1.DialogContentText, null, t(body))
: body)),
React.createElement(core_1.DialogActions, null,
leftButtonText &&
React.createElement(__1.Button
// style={singleButton ? classes.singleButton : classes.button}
// labelStyle={classes.buttonLabel}
, {
// style={singleButton ? classes.singleButton : classes.button}
// labelStyle={classes.buttonLabel}
title: leftButtonText,
// labelColor={appTheme.primaryColor}
onPress: function () {
leftButtonOnPress && leftButtonOnPress();
hideAlert(body, alertId);
} }),
rightButtonText &&
React.createElement(__1.Button
// style={singleButton ? classes.singleButton : classes.button}
// labelStyle={classes.buttonLabel}
, {
// style={singleButton ? classes.singleButton : classes.button}
// labelStyle={classes.buttonLabel}
title: rightButtonText,
// labelColor={appTheme.primaryColor}
onPress: function () {
rightButtonOnPress && rightButtonOnPress();
hideAlert(body, alertId);
} }))));
});
};
return CAlert;
}(React.Component));
var StyledAlert = __1.createStyles(styles, 'Alert')(CAlert);
exports.default = StyledAlert;
exports.Alert = redux_1.compose(react_i18next_1.translate(), react_redux_1.connect(function (state) { return ({
alerts: state.navigation.alerts,
}); }, {
hideAlert: navigation_1.hideAlert,
}))(StyledAlert);
//# sourceMappingURL=Alert.js.map