You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.8 KiB
119 lines
3.8 KiB
"use strict";
|
|
|
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
|
|
var React = _interopRequireWildcard(require("react"));
|
|
|
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
|
var _ref2 = require("rc-util/lib/ref");
|
|
|
|
var Input = function Input(_ref, ref) {
|
|
var _inputNode2, _inputNode2$props;
|
|
|
|
var prefixCls = _ref.prefixCls,
|
|
id = _ref.id,
|
|
inputElement = _ref.inputElement,
|
|
disabled = _ref.disabled,
|
|
tabIndex = _ref.tabIndex,
|
|
autoFocus = _ref.autoFocus,
|
|
autoComplete = _ref.autoComplete,
|
|
editable = _ref.editable,
|
|
activeDescendantId = _ref.activeDescendantId,
|
|
value = _ref.value,
|
|
maxLength = _ref.maxLength,
|
|
_onKeyDown = _ref.onKeyDown,
|
|
_onMouseDown = _ref.onMouseDown,
|
|
_onChange = _ref.onChange,
|
|
onPaste = _ref.onPaste,
|
|
_onCompositionStart = _ref.onCompositionStart,
|
|
_onCompositionEnd = _ref.onCompositionEnd,
|
|
open = _ref.open,
|
|
attrs = _ref.attrs;
|
|
var inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
|
|
var _inputNode = inputNode,
|
|
originRef = _inputNode.ref,
|
|
_inputNode$props = _inputNode.props,
|
|
onOriginKeyDown = _inputNode$props.onKeyDown,
|
|
onOriginChange = _inputNode$props.onChange,
|
|
onOriginMouseDown = _inputNode$props.onMouseDown,
|
|
onOriginCompositionStart = _inputNode$props.onCompositionStart,
|
|
onOriginCompositionEnd = _inputNode$props.onCompositionEnd,
|
|
style = _inputNode$props.style;
|
|
inputNode = /*#__PURE__*/React.cloneElement(inputNode, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
id: id,
|
|
ref: (0, _ref2.composeRef)(ref, originRef),
|
|
disabled: disabled,
|
|
tabIndex: tabIndex,
|
|
autoComplete: autoComplete || 'off',
|
|
type: 'search',
|
|
autoFocus: autoFocus,
|
|
className: (0, _classnames.default)("".concat(prefixCls, "-selection-search-input"), (_inputNode2 = inputNode) === null || _inputNode2 === void 0 ? void 0 : (_inputNode2$props = _inputNode2.props) === null || _inputNode2$props === void 0 ? void 0 : _inputNode2$props.className),
|
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), {}, {
|
|
opacity: editable ? null : 0
|
|
}),
|
|
role: 'combobox',
|
|
'aria-expanded': open,
|
|
'aria-haspopup': 'listbox',
|
|
'aria-owns': "".concat(id, "_list"),
|
|
'aria-autocomplete': 'list',
|
|
'aria-controls': "".concat(id, "_list"),
|
|
'aria-activedescendant': activeDescendantId
|
|
}, attrs), {}, {
|
|
value: editable ? value : '',
|
|
maxLength: maxLength,
|
|
readOnly: !editable,
|
|
unselectable: !editable ? 'on' : null,
|
|
onKeyDown: function onKeyDown(event) {
|
|
_onKeyDown(event);
|
|
|
|
if (onOriginKeyDown) {
|
|
onOriginKeyDown(event);
|
|
}
|
|
},
|
|
onMouseDown: function onMouseDown(event) {
|
|
_onMouseDown(event);
|
|
|
|
if (onOriginMouseDown) {
|
|
onOriginMouseDown(event);
|
|
}
|
|
},
|
|
onChange: function onChange(event) {
|
|
_onChange(event);
|
|
|
|
if (onOriginChange) {
|
|
onOriginChange(event);
|
|
}
|
|
},
|
|
onCompositionStart: function onCompositionStart(event) {
|
|
_onCompositionStart(event);
|
|
|
|
if (onOriginCompositionStart) {
|
|
onOriginCompositionStart(event);
|
|
}
|
|
},
|
|
onCompositionEnd: function onCompositionEnd(event) {
|
|
_onCompositionEnd(event);
|
|
|
|
if (onOriginCompositionEnd) {
|
|
onOriginCompositionEnd(event);
|
|
}
|
|
},
|
|
onPaste: onPaste
|
|
}));
|
|
return inputNode;
|
|
};
|
|
|
|
var RefInput = /*#__PURE__*/React.forwardRef(Input);
|
|
RefInput.displayName = 'Input';
|
|
var _default = RefInput;
|
|
exports.default = _default; |