1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | var _typeof = require("@babel/runtime/helpers/typeof");
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = void 0;
|
9 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 | var _classnames = _interopRequireDefault(require("classnames"));
|
12 | var _ref = require("rc-util/lib/ref");
|
13 | var _warning = require("rc-util/lib/warning");
|
14 | function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
15 | function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
16 | var Input = function Input(props, ref) {
|
17 | var _inputNode2;
|
18 | var prefixCls = props.prefixCls,
|
19 | id = props.id,
|
20 | inputElement = props.inputElement,
|
21 | disabled = props.disabled,
|
22 | tabIndex = props.tabIndex,
|
23 | autoFocus = props.autoFocus,
|
24 | autoComplete = props.autoComplete,
|
25 | editable = props.editable,
|
26 | activeDescendantId = props.activeDescendantId,
|
27 | value = props.value,
|
28 | maxLength = props.maxLength,
|
29 | _onKeyDown = props.onKeyDown,
|
30 | _onMouseDown = props.onMouseDown,
|
31 | _onChange = props.onChange,
|
32 | onPaste = props.onPaste,
|
33 | _onCompositionStart = props.onCompositionStart,
|
34 | _onCompositionEnd = props.onCompositionEnd,
|
35 | open = props.open,
|
36 | attrs = props.attrs;
|
37 | var inputNode = inputElement || React.createElement("input", null);
|
38 | var _inputNode = inputNode,
|
39 | originRef = _inputNode.ref,
|
40 | originProps = _inputNode.props;
|
41 | var onOriginKeyDown = originProps.onKeyDown,
|
42 | onOriginChange = originProps.onChange,
|
43 | onOriginMouseDown = originProps.onMouseDown,
|
44 | onOriginCompositionStart = originProps.onCompositionStart,
|
45 | onOriginCompositionEnd = originProps.onCompositionEnd,
|
46 | style = originProps.style;
|
47 | (0, _warning.warning)(!('maxLength' in inputNode.props), "Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.");
|
48 | inputNode = React.cloneElement(inputNode, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
49 | type: 'search'
|
50 | }, originProps), {}, {
|
51 |
|
52 | id: id,
|
53 | ref: (0, _ref.composeRef)(ref, originRef),
|
54 | disabled: disabled,
|
55 | tabIndex: tabIndex,
|
56 | autoComplete: autoComplete || 'off',
|
57 | autoFocus: autoFocus,
|
58 | className: (0, _classnames.default)("".concat(prefixCls, "-selection-search-input"), (_inputNode2 = inputNode) === null || _inputNode2 === void 0 || (_inputNode2 = _inputNode2.props) === null || _inputNode2 === void 0 ? void 0 : _inputNode2.className),
|
59 | role: 'combobox',
|
60 | 'aria-expanded': open || false,
|
61 | 'aria-haspopup': 'listbox',
|
62 | 'aria-owns': "".concat(id, "_list"),
|
63 | 'aria-autocomplete': 'list',
|
64 | 'aria-controls': "".concat(id, "_list"),
|
65 | 'aria-activedescendant': open ? activeDescendantId : undefined
|
66 | }, attrs), {}, {
|
67 | value: editable ? value : '',
|
68 | maxLength: maxLength,
|
69 | readOnly: !editable,
|
70 | unselectable: !editable ? 'on' : null,
|
71 | style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), {}, {
|
72 | opacity: editable ? null : 0
|
73 | }),
|
74 | onKeyDown: function onKeyDown(event) {
|
75 | _onKeyDown(event);
|
76 | if (onOriginKeyDown) {
|
77 | onOriginKeyDown(event);
|
78 | }
|
79 | },
|
80 | onMouseDown: function onMouseDown(event) {
|
81 | _onMouseDown(event);
|
82 | if (onOriginMouseDown) {
|
83 | onOriginMouseDown(event);
|
84 | }
|
85 | },
|
86 | onChange: function onChange(event) {
|
87 | _onChange(event);
|
88 | if (onOriginChange) {
|
89 | onOriginChange(event);
|
90 | }
|
91 | },
|
92 | onCompositionStart: function onCompositionStart(event) {
|
93 | _onCompositionStart(event);
|
94 | if (onOriginCompositionStart) {
|
95 | onOriginCompositionStart(event);
|
96 | }
|
97 | },
|
98 | onCompositionEnd: function onCompositionEnd(event) {
|
99 | _onCompositionEnd(event);
|
100 | if (onOriginCompositionEnd) {
|
101 | onOriginCompositionEnd(event);
|
102 | }
|
103 | },
|
104 | onPaste: onPaste
|
105 | }));
|
106 | return inputNode;
|
107 | };
|
108 | var RefInput = React.forwardRef(Input);
|
109 | if (process.env.NODE_ENV !== 'production') {
|
110 | RefInput.displayName = 'Input';
|
111 | }
|
112 | var _default = exports.default = RefInput; |
\ | No newline at end of file |