1 | const _excluded = ["className", "disabled", "readOnly", "value", "tabIndex", "type", "component"];
|
2 |
|
3 | function _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 |
|
5 | function _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 |
|
7 | import cn from 'classnames';
|
8 | import PropTypes from 'prop-types';
|
9 | import React from 'react';
|
10 | const Input = 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 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 | });
|
35 | Input.displayName = 'Input';
|
36 | Input.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 | };
|
44 | export default Input; |
\ | No newline at end of file |