Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

72 строки
2.1 KiB

  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
  4. import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
  5. import React, { Component } from 'react';
  6. import PropTypes from 'prop-types';
  7. import classNames from 'classnames';
  8. import { mapToCssModules, tagPropType } from './utils';
  9. var propTypes = {
  10. children: PropTypes.node,
  11. inline: PropTypes.bool,
  12. tag: tagPropType,
  13. innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  14. className: PropTypes.string,
  15. cssModule: PropTypes.object
  16. };
  17. var defaultProps = {
  18. tag: 'form'
  19. };
  20. var Form =
  21. /*#__PURE__*/
  22. function (_Component) {
  23. _inheritsLoose(Form, _Component);
  24. function Form(props) {
  25. var _this;
  26. _this = _Component.call(this, props) || this;
  27. _this.getRef = _this.getRef.bind(_assertThisInitialized(_assertThisInitialized(_this)));
  28. _this.submit = _this.submit.bind(_assertThisInitialized(_assertThisInitialized(_this)));
  29. return _this;
  30. }
  31. var _proto = Form.prototype;
  32. _proto.getRef = function getRef(ref) {
  33. if (this.props.innerRef) {
  34. this.props.innerRef(ref);
  35. }
  36. this.ref = ref;
  37. };
  38. _proto.submit = function submit() {
  39. if (this.ref) {
  40. this.ref.submit();
  41. }
  42. };
  43. _proto.render = function render() {
  44. var _this$props = this.props,
  45. className = _this$props.className,
  46. cssModule = _this$props.cssModule,
  47. inline = _this$props.inline,
  48. Tag = _this$props.tag,
  49. innerRef = _this$props.innerRef,
  50. attributes = _objectWithoutPropertiesLoose(_this$props, ["className", "cssModule", "inline", "tag", "innerRef"]);
  51. var classes = mapToCssModules(classNames(className, inline ? 'form-inline' : false), cssModule);
  52. return React.createElement(Tag, _extends({}, attributes, {
  53. ref: innerRef,
  54. className: classes
  55. }));
  56. };
  57. return Form;
  58. }(Component);
  59. Form.propTypes = propTypes;
  60. Form.defaultProps = defaultProps;
  61. export default Form;