UNPKG

1.69 kBJavaScriptView Raw
1const _excluded = ["className", "disabled", "readOnly", "value", "tabIndex", "type", "component"];
2
3function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
5function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
7import cn from 'classnames';
8import PropTypes from 'prop-types';
9import React from 'react';
10const Input = /*#__PURE__*/React.forwardRef((_ref, ref) => {
11 let {
12 className,
13 disabled,
14 readOnly,
15 value,
16 tabIndex,
17 type = 'text',
18 component: Component = 'input'
19 } = _ref,
20 props = _objectWithoutPropertiesLoose(_ref, _excluded);
21
22 return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
23 ref: ref,
24 type: type,
25 tabIndex: tabIndex || 0,
26 autoComplete: "off",
27 disabled: disabled,
28 readOnly: readOnly,
29 "aria-disabled": disabled,
30 "aria-readonly": readOnly,
31 value: value == null ? '' : value,
32 className: cn(className, 'rw-input')
33 }));
34});
35Input.displayName = 'Input';
36Input.propTypes = {
37 disabled: PropTypes.bool,
38 readOnly: PropTypes.bool,
39 value: PropTypes.string,
40 type: PropTypes.string,
41 tabIndex: PropTypes.number,
42 component: PropTypes.any
43};
44export default Input;
\No newline at end of file