@rc-component/select 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,29 +2,20 @@ import * as React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { composeRef } from "@rc-component/util/es/ref";
4
4
  import { warning } from "@rc-component/util/es/warning";
5
+ import composeProps from "@rc-component/util/es/composeProps";
5
6
  import useBaseProps from "../hooks/useBaseProps";
6
7
  const Input = (props, ref) => {
7
8
  const {
8
9
  prefixCls,
9
10
  id,
10
11
  inputElement,
11
- disabled,
12
- tabIndex,
13
- autoFocus,
14
12
  autoComplete,
15
13
  editable,
16
14
  activeDescendantId,
17
15
  value,
18
- maxLength,
19
- onKeyDown,
20
- onMouseDown,
21
- onChange,
22
- onPaste,
23
- onCompositionStart,
24
- onCompositionEnd,
25
- onBlur,
26
16
  open,
27
- attrs
17
+ attrs,
18
+ ...restProps
28
19
  } = props;
29
20
  const {
30
21
  classNames: contextClassNames,
@@ -35,27 +26,15 @@ const Input = (props, ref) => {
35
26
  ref: originRef,
36
27
  props: originProps
37
28
  } = inputNode;
38
- const {
39
- onKeyDown: onOriginKeyDown,
40
- onChange: onOriginChange,
41
- onMouseDown: onOriginMouseDown,
42
- onCompositionStart: onOriginCompositionStart,
43
- onCompositionEnd: onOriginCompositionEnd,
44
- onBlur: onOriginBlur,
45
- style
46
- } = originProps;
47
29
  warning(!('maxLength' in inputNode.props), `Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.`);
48
30
  inputNode = /*#__PURE__*/React.cloneElement(inputNode, {
49
31
  type: 'search',
50
- ...originProps,
32
+ ...composeProps(restProps, originProps, true),
51
33
  // Override over origin props
52
34
  id,
53
35
  ref: composeRef(ref, originRef),
54
- disabled,
55
- tabIndex,
56
36
  autoComplete: autoComplete || 'off',
57
- autoFocus,
58
- className: classNames(`${prefixCls}-selection-search-input`, inputNode?.props?.className, contextClassNames?.input),
37
+ className: classNames(`${prefixCls}-selection-search-input`, originProps.className, contextClassNames?.input),
59
38
  role: 'combobox',
60
39
  'aria-expanded': open || false,
61
40
  'aria-haspopup': 'listbox',
@@ -65,50 +44,12 @@ const Input = (props, ref) => {
65
44
  'aria-activedescendant': open ? activeDescendantId : undefined,
66
45
  ...attrs,
67
46
  value: editable ? value : '',
68
- maxLength,
69
47
  readOnly: !editable,
70
48
  unselectable: !editable ? 'on' : null,
71
49
  style: {
72
- ...style,
50
+ ...originProps.style,
73
51
  opacity: editable ? null : 0,
74
52
  ...contextStyles?.input
75
- },
76
- onKeyDown: event => {
77
- onKeyDown(event);
78
- if (onOriginKeyDown) {
79
- onOriginKeyDown(event);
80
- }
81
- },
82
- onMouseDown: event => {
83
- onMouseDown(event);
84
- if (onOriginMouseDown) {
85
- onOriginMouseDown(event);
86
- }
87
- },
88
- onChange: event => {
89
- onChange(event);
90
- if (onOriginChange) {
91
- onOriginChange(event);
92
- }
93
- },
94
- onCompositionStart(event) {
95
- onCompositionStart(event);
96
- if (onOriginCompositionStart) {
97
- onOriginCompositionStart(event);
98
- }
99
- },
100
- onCompositionEnd(event) {
101
- onCompositionEnd(event);
102
- if (onOriginCompositionEnd) {
103
- onOriginCompositionEnd(event);
104
- }
105
- },
106
- onPaste,
107
- onBlur(event) {
108
- onBlur(event);
109
- if (onOriginBlur) {
110
- onOriginBlur(event);
111
- }
112
53
  }
113
54
  });
114
55
  return inputNode;
@@ -8,6 +8,7 @@ var React = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _ref = require("@rc-component/util/lib/ref");
10
10
  var _warning = require("@rc-component/util/lib/warning");
11
+ var _composeProps = _interopRequireDefault(require("@rc-component/util/lib/composeProps"));
11
12
  var _useBaseProps = _interopRequireDefault(require("../hooks/useBaseProps"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -17,23 +18,13 @@ const Input = (props, ref) => {
17
18
  prefixCls,
18
19
  id,
19
20
  inputElement,
20
- disabled,
21
- tabIndex,
22
- autoFocus,
23
21
  autoComplete,
24
22
  editable,
25
23
  activeDescendantId,
26
24
  value,
27
- maxLength,
28
- onKeyDown,
29
- onMouseDown,
30
- onChange,
31
- onPaste,
32
- onCompositionStart,
33
- onCompositionEnd,
34
- onBlur,
35
25
  open,
36
- attrs
26
+ attrs,
27
+ ...restProps
37
28
  } = props;
38
29
  const {
39
30
  classNames: contextClassNames,
@@ -44,27 +35,15 @@ const Input = (props, ref) => {
44
35
  ref: originRef,
45
36
  props: originProps
46
37
  } = inputNode;
47
- const {
48
- onKeyDown: onOriginKeyDown,
49
- onChange: onOriginChange,
50
- onMouseDown: onOriginMouseDown,
51
- onCompositionStart: onOriginCompositionStart,
52
- onCompositionEnd: onOriginCompositionEnd,
53
- onBlur: onOriginBlur,
54
- style
55
- } = originProps;
56
38
  (0, _warning.warning)(!('maxLength' in inputNode.props), `Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.`);
57
39
  inputNode = /*#__PURE__*/React.cloneElement(inputNode, {
58
40
  type: 'search',
59
- ...originProps,
41
+ ...(0, _composeProps.default)(restProps, originProps, true),
60
42
  // Override over origin props
61
43
  id,
62
44
  ref: (0, _ref.composeRef)(ref, originRef),
63
- disabled,
64
- tabIndex,
65
45
  autoComplete: autoComplete || 'off',
66
- autoFocus,
67
- className: (0, _classnames.default)(`${prefixCls}-selection-search-input`, inputNode?.props?.className, contextClassNames?.input),
46
+ className: (0, _classnames.default)(`${prefixCls}-selection-search-input`, originProps.className, contextClassNames?.input),
68
47
  role: 'combobox',
69
48
  'aria-expanded': open || false,
70
49
  'aria-haspopup': 'listbox',
@@ -74,50 +53,12 @@ const Input = (props, ref) => {
74
53
  'aria-activedescendant': open ? activeDescendantId : undefined,
75
54
  ...attrs,
76
55
  value: editable ? value : '',
77
- maxLength,
78
56
  readOnly: !editable,
79
57
  unselectable: !editable ? 'on' : null,
80
58
  style: {
81
- ...style,
59
+ ...originProps.style,
82
60
  opacity: editable ? null : 0,
83
61
  ...contextStyles?.input
84
- },
85
- onKeyDown: event => {
86
- onKeyDown(event);
87
- if (onOriginKeyDown) {
88
- onOriginKeyDown(event);
89
- }
90
- },
91
- onMouseDown: event => {
92
- onMouseDown(event);
93
- if (onOriginMouseDown) {
94
- onOriginMouseDown(event);
95
- }
96
- },
97
- onChange: event => {
98
- onChange(event);
99
- if (onOriginChange) {
100
- onOriginChange(event);
101
- }
102
- },
103
- onCompositionStart(event) {
104
- onCompositionStart(event);
105
- if (onOriginCompositionStart) {
106
- onOriginCompositionStart(event);
107
- }
108
- },
109
- onCompositionEnd(event) {
110
- onCompositionEnd(event);
111
- if (onOriginCompositionEnd) {
112
- onOriginCompositionEnd(event);
113
- }
114
- },
115
- onPaste,
116
- onBlur(event) {
117
- onBlur(event);
118
- if (onOriginBlur) {
119
- onOriginBlur(event);
120
- }
121
62
  }
122
63
  });
123
64
  return inputNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"