mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
||
|
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
||
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import classNames from 'classnames';
|
||
|
import { mapToCssModules, tagPropType } from './utils';
|
||
|
var propTypes = {
|
||
|
children: PropTypes.node,
|
||
|
inline: PropTypes.bool,
|
||
|
tag: tagPropType,
|
||
|
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
|
||
|
className: PropTypes.string,
|
||
|
cssModule: PropTypes.object
|
||
|
};
|
||
|
var defaultProps = {
|
||
|
tag: 'form'
|
||
|
};
|
||
|
|
||
|
var Form = /*#__PURE__*/function (_Component) {
|
||
|
_inheritsLoose(Form, _Component);
|
||
|
|
||
|
function Form(props) {
|
||
|
var _this;
|
||
|
|
||
|
_this = _Component.call(this, props) || this;
|
||
|
_this.getRef = _this.getRef.bind(_assertThisInitialized(_this));
|
||
|
_this.submit = _this.submit.bind(_assertThisInitialized(_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 = _objectWithoutPropertiesLoose(_this$props, ["className", "cssModule", "inline", "tag", "innerRef"]);
|
||
|
|
||
|
var classes = mapToCssModules(classNames(className, inline ? 'form-inline' : false), cssModule);
|
||
|
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
|
||
|
ref: innerRef,
|
||
|
className: classes
|
||
|
}));
|
||
|
};
|
||
|
|
||
|
return Form;
|
||
|
}(Component);
|
||
|
|
||
|
Form.propTypes = propTypes;
|
||
|
Form.defaultProps = defaultProps;
|
||
|
export default Form;
|