34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
import classNames from 'classnames';
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
var propTypes = {
|
|
/**
|
|
* Specify whether the feedback is for valid or invalid fields
|
|
*
|
|
* @type {('valid'|'invalid')}
|
|
*/
|
|
type: PropTypes.string.isRequired,
|
|
as: PropTypes.elementType
|
|
};
|
|
var defaultProps = {
|
|
type: 'valid'
|
|
};
|
|
var Feedback = React.forwardRef( // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
|
|
function (_ref, ref) {
|
|
var _ref$as = _ref.as,
|
|
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
className = _ref.className,
|
|
type = _ref.type,
|
|
props = _objectWithoutPropertiesLoose(_ref, ["as", "className", "type"]);
|
|
|
|
return React.createElement(Component, _extends({}, props, {
|
|
ref: ref,
|
|
className: classNames(className, type && type + "-feedback")
|
|
}));
|
|
});
|
|
Feedback.displayName = 'Feedback';
|
|
Feedback.propTypes = propTypes;
|
|
Feedback.defaultProps = defaultProps;
|
|
export default Feedback; |