GoScrobble/web/node_modules/reactstrap/lib/Form.js

87 lines
2.7 KiB
JavaScript

"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _utils = require("./utils");
var propTypes = {
children: _propTypes.default.node,
inline: _propTypes.default.bool,
tag: _utils.tagPropType,
innerRef: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func, _propTypes.default.string]),
className: _propTypes.default.string,
cssModule: _propTypes.default.object
};
var defaultProps = {
tag: 'form'
};
var Form = /*#__PURE__*/function (_Component) {
(0, _inheritsLoose2.default)(Form, _Component);
function Form(props) {
var _this;
_this = _Component.call(this, props) || this;
_this.getRef = _this.getRef.bind((0, _assertThisInitialized2.default)(_this));
_this.submit = _this.submit.bind((0, _assertThisInitialized2.default)(_this));
return _this;
}
var _proto = Form.prototype;
_proto.getRef = function getRef(ref) {
if (this.props.innerRef) {
this.props.innerRef(ref);
}
this.ref = ref;
};
_proto.submit = function submit() {
if (this.ref) {
this.ref.submit();
}
};
_proto.render = function render() {
var _this$props = this.props,
className = _this$props.className,
cssModule = _this$props.cssModule,
inline = _this$props.inline,
Tag = _this$props.tag,
innerRef = _this$props.innerRef,
attributes = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["className", "cssModule", "inline", "tag", "innerRef"]);
var classes = (0, _utils.mapToCssModules)((0, _classnames.default)(className, inline ? 'form-inline' : false), cssModule);
return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({}, attributes, {
ref: innerRef,
className: classes
}));
};
return Form;
}(_react.Component);
Form.propTypes = propTypes;
Form.defaultProps = defaultProps;
var _default = Form;
exports.default = _default;