UNPKG

1.74 kBJavaScriptView Raw
1const _excluded = ["disabled", "readOnly"];
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 PropTypes from 'prop-types';
8import React from 'react';
9import * as CustomPropTypes from './PropTypes';
10const propTypes = {
11 value: PropTypes.string,
12 placeholder: PropTypes.string,
13 maxLength: PropTypes.number,
14 onChange: PropTypes.func.isRequired,
15 disabled: CustomPropTypes.disabled,
16 readOnly: CustomPropTypes.disabled
17};
18const MultiselectInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
19 let {
20 disabled,
21 readOnly
22 } = _ref,
23 props = _objectWithoutPropertiesLoose(_ref, _excluded);
24
25 let size = Math.max(String(props.value || props.placeholder || '').length, 1) + 1;
26 return /*#__PURE__*/React.createElement("input", _extends({
27 spellCheck: "false",
28 autoCapitalize: "off"
29 }, props, {
30 size: size,
31 ref: ref,
32 autoComplete: "off",
33 className: "rw-multiselect-input",
34 "aria-disabled": disabled,
35 "aria-readonly": readOnly,
36 disabled: disabled,
37 readOnly: readOnly
38 }));
39});
40MultiselectInput.displayName = 'MultiselectInput';
41MultiselectInput.propTypes = propTypes;
42export default MultiselectInput;
\No newline at end of file