zent
Version:
一套前端设计语言和基于React的实现
78 lines (57 loc) • 3.73 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _class, _temp;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('zent-utils/classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _noop = require('zent-utils/lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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 Form = (_temp = _class = function (_Component) {
_inherits(Form, _Component);
function Form() {
_classCallCheck(this, Form);
return _possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments));
}
_createClass(Form, [{
key: 'render',
value: function render() {
var _classNames;
var _props = this.props,
prefix = _props.prefix,
className = _props.className,
style = _props.style,
horizontal = _props.horizontal,
inline = _props.inline,
onSubmit = _props.onSubmit;
var formClassName = (0, _classnames2['default'])((_classNames = {}, _defineProperty(_classNames, prefix + '-form', true), _defineProperty(_classNames, prefix + '-form--horizontal', horizontal), _defineProperty(_classNames, prefix + '-form--inline', inline), _defineProperty(_classNames, className, !!className), _classNames));
return _react2['default'].createElement(
'form',
{ className: formClassName, style: style, onSubmit: onSubmit },
this.props.children
);
}
}]);
return Form;
}(_react.Component), _class.propTypes = {
prefix: _react.PropTypes.string,
className: _react.PropTypes.string,
horizontal: _react.PropTypes.bool,
inline: _react.PropTypes.bool,
onSubmit: _react.PropTypes.func,
children: _react.PropTypes.any,
style: _react.PropTypes.object
}, _class.defaultProps = {
prefix: 'zent',
onSubmit: _noop2['default']
}, _temp);
exports['default'] = Form;
module.exports = exports['default'];
;