'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _reactBootstrap = require('react-bootstrap');

var _ConfirmDialog = require('./ConfirmDialog.scss');

var _ConfirmDialog2 = _interopRequireDefault(_ConfirmDialog);

var _Action = require('../Actions/Action');

var _Action2 = _interopRequireDefault(_Action);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 *
 * @param size optional, allow to change the size of the model ( small / large )
 * @param show allow to show the modal
 * @param header optional, set the text property for the header
 * @param children react's components children
 * @param validateAction object, describe the validate action
 * @param cancelAction object, describe the cancel action
 * @param progressValue number, if set shows progressbar with progress of progressValue
 * @param bodyOverflow bool, default true,
 * modal body automaticaly show a scrollbar if content overflow
 *
 const defaultProps = {
	header: 'Hello world',
	show: true,
	validateAction: {
		label: 'OK',
		onClick: action('ok'),
	},
	cancelAction: {
		label: 'CANCEL',
		onClick: action('cancel'),
	},
};
 const children = (<div>BODY content. You can put what ever you want here</div>);
 <ConfirmDialog {...defaultProps}>{children}</ConfirmDialog>
 * @constructor
 */
function ConfirmDialog(_ref) {
	var size = _ref.size,
	    show = _ref.show,
	    header = _ref.header,
	    children = _ref.children,
	    validateAction = _ref.validateAction,
	    cancelAction = _ref.cancelAction,
	    progressValue = _ref.progressValue,
	    _ref$bodyOverflow = _ref.bodyOverflow,
	    bodyOverflow = _ref$bodyOverflow === undefined ? true : _ref$bodyOverflow;

	return _react2.default.createElement(
		_reactBootstrap.Modal,
		{
			bsSize: size,
			show: show,
			keyboard: true,
			className: (0, _classnames2.default)(_ConfirmDialog2.default['tc-confirm-dialog'], bodyOverflow && _ConfirmDialog2.default['modal-body-overflow'])
		},
		header ? _react2.default.createElement(
			_reactBootstrap.Modal.Header,
			{ closeButton: false },
			_react2.default.createElement(
				_reactBootstrap.Modal.Title,
				null,
				header
			)
		) : null,
		progressValue ? _react2.default.createElement(_reactBootstrap.ProgressBar, { now: progressValue }) : null,
		_react2.default.createElement(
			_reactBootstrap.Modal.Body,
			null,
			children
		),
		_react2.default.createElement(
			_reactBootstrap.Modal.Footer,
			null,
			_react2.default.createElement(_Action2.default, cancelAction),
			_react2.default.createElement(_Action2.default, validateAction)
		)
	);
}

ConfirmDialog.propTypes = {
	header: _react.PropTypes.string,
	size: _react.PropTypes.oneOf(['small', 'large']),
	children: _react.PropTypes.element,
	show: _react.PropTypes.bool,
	cancelAction: _react.PropTypes.shape(_Action2.default.propTypes).isRequired,
	validateAction: _react.PropTypes.shape(_Action2.default.propTypes).isRequired,
	progressValue: _react.PropTypes.number,
	bodyOverflow: _react.PropTypes.bool
};

exports.default = ConfirmDialog;