fk-react-ui-components
Version:
Step 1 : Create a file in [ Seeds / Plants / Trees ] <br> Step 2 : It should export an Object with component name and story Component [Refer other components] <br> Step 3 : Story Component should return a react component <br> Step 3 : Created file should
111 lines (88 loc) • 5.2 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ContentContainerWrapper = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _AttributeModifier = require('../AttributeModifier');
var _AttributeModifier2 = _interopRequireDefault(_AttributeModifier);
var _styles = require('./styles');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ContentContainerWrapper = exports.ContentContainerWrapper = function (_Component) {
_inherits(ContentContainerWrapper, _Component);
function ContentContainerWrapper() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, ContentContainerWrapper);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ContentContainerWrapper.__proto__ || Object.getPrototypeOf(ContentContainerWrapper)).call.apply(_ref, [this].concat(args))), _this), _this.onCancel = function (content, showConfirmationDialog) {
_this.props.closeChildComponent();
_this.props.onCancel(content, showConfirmationDialog);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(ContentContainerWrapper, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
_styles.ContainerWrapper,
null,
_react2.default.createElement(_AttributeModifier2.default, {
validateFunction: this.props.validateInput,
onSave: this.props.onChange,
title: this.props.title,
description: this.props.description,
onCancel: this.onCancel,
content: this.props.content,
inputType: this.props.type,
loading: this.props.editState.isLoading,
error: this.props.editState.isError,
success: this.props.editState.isSuccess,
successMessage: this.props.successMessage,
errorMessage: this.props.errorMessage,
showConfirmationDialog: this.props.showConfirmationDialog
})
);
}
}]);
return ContentContainerWrapper;
}(_react.Component);
ContentContainerWrapper.propTypes = {
closeChildComponent: _propTypes2.default.func.isRequired,
onCancel: _propTypes2.default.func,
onChange: _propTypes2.default.func.isRequired,
content: _propTypes2.default.string.isRequired,
type: _propTypes2.default.string.isRequired,
title: _propTypes2.default.string,
description: _propTypes2.default.string,
validateInput: _propTypes2.default.func.isRequired,
showConfirmationDialog: _propTypes2.default.bool,
successMessage: _propTypes2.default.string,
errorMessage: _propTypes2.default.string,
editState: _propTypes2.default.shape({
isLoading: _propTypes2.default.bool,
isSuccess: _propTypes2.default.bool,
isError: _propTypes2.default.bool
})
};
ContentContainerWrapper.defaultProps = {
onCancel: function onCancel() {},
title: '',
description: '',
successMessage: 'Value updated successfully',
errorMessage: 'Value updation failed!',
showConfirmationDialog: false,
editState: _propTypes2.default.shape({
isLoading: false,
isSuccess: false,
isError: false
})
};