|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import _extends from "@babel/runtime/helpers/esm/extends";
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
- 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(_assertThisInitialized(_this)));
- _this.submit = _this.submit.bind(_assertThisInitialized(_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 React.createElement(Tag, _extends({}, attributes, {
- ref: innerRef,
- className: classes
- }));
- };
-
- return Form;
- }(Component);
-
- Form.propTypes = propTypes;
- Form.defaultProps = defaultProps;
- export default Form;
|