@rc-component/select 1.0.5 → 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.
package/es/Select.js CHANGED
@@ -40,7 +40,7 @@ import OptionList from "./OptionList";
40
40
  import SelectContext from "./SelectContext";
41
41
  import useCache from "./hooks/useCache";
42
42
  import useFilterOptions from "./hooks/useFilterOptions";
43
- import useId from "./hooks/useId";
43
+ import useId from "@rc-component/util/es/hooks/useId";
44
44
  import useOptions from "./hooks/useOptions";
45
45
  import useRefFunc from "./hooks/useRefFunc";
46
46
  import { hasValue, isComboNoValue, toArray } from "./utils/commonUtil";
@@ -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;
package/lib/Select.js CHANGED
@@ -14,7 +14,7 @@ var _OptionList = _interopRequireDefault(require("./OptionList"));
14
14
  var _SelectContext = _interopRequireDefault(require("./SelectContext"));
15
15
  var _useCache = _interopRequireDefault(require("./hooks/useCache"));
16
16
  var _useFilterOptions = _interopRequireDefault(require("./hooks/useFilterOptions"));
17
- var _useId = _interopRequireDefault(require("./hooks/useId"));
17
+ var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
18
18
  var _useOptions = _interopRequireDefault(require("./hooks/useOptions"));
19
19
  var _useRefFunc = _interopRequireDefault(require("./hooks/useRefFunc"));
20
20
  var _commonUtil = require("./utils/commonUtil");
@@ -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.5",
3
+ "version": "1.0.7",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"
@@ -1,5 +0,0 @@
1
- /** Is client side and not jsdom */
2
- export declare const isBrowserClient: boolean;
3
- /** Get unique id for accessibility usage */
4
- export declare function getUUID(): number | string;
5
- export default function useId(id?: string): string;
package/es/hooks/useId.js DELETED
@@ -1,29 +0,0 @@
1
- import * as React from 'react';
2
- import canUseDom from "@rc-component/util/es/Dom/canUseDom";
3
- let uuid = 0;
4
-
5
- /** Is client side and not jsdom */
6
- export const isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom();
7
-
8
- /** Get unique id for accessibility usage */
9
- export function getUUID() {
10
- let retId;
11
-
12
- // Test never reach
13
- /* istanbul ignore if */
14
- if (isBrowserClient) {
15
- retId = uuid;
16
- uuid += 1;
17
- } else {
18
- retId = 'TEST_OR_SSR';
19
- }
20
- return retId;
21
- }
22
- export default function useId(id) {
23
- // Inner id for accessibility usage. Only work in client side
24
- const [innerId, setInnerId] = React.useState();
25
- React.useEffect(() => {
26
- setInnerId(`rc_select_${getUUID()}`);
27
- }, []);
28
- return id || innerId;
29
- }
@@ -1,5 +0,0 @@
1
- /** Is client side and not jsdom */
2
- export declare const isBrowserClient: boolean;
3
- /** Get unique id for accessibility usage */
4
- export declare function getUUID(): number | string;
5
- export default function useId(id?: string): string;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useId;
7
- exports.getUUID = getUUID;
8
- exports.isBrowserClient = void 0;
9
- var React = _interopRequireWildcard(require("react"));
10
- var _canUseDom = _interopRequireDefault(require("@rc-component/util/lib/Dom/canUseDom"));
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- 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); }
13
- 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; }
14
- let uuid = 0;
15
-
16
- /** Is client side and not jsdom */
17
- const isBrowserClient = exports.isBrowserClient = process.env.NODE_ENV !== 'test' && (0, _canUseDom.default)();
18
-
19
- /** Get unique id for accessibility usage */
20
- function getUUID() {
21
- let retId;
22
-
23
- // Test never reach
24
- /* istanbul ignore if */
25
- if (isBrowserClient) {
26
- retId = uuid;
27
- uuid += 1;
28
- } else {
29
- retId = 'TEST_OR_SSR';
30
- }
31
- return retId;
32
- }
33
- function useId(id) {
34
- // Inner id for accessibility usage. Only work in client side
35
- const [innerId, setInnerId] = React.useState();
36
- React.useEffect(() => {
37
- setInnerId(`rc_select_${getUUID()}`);
38
- }, []);
39
- return id || innerId;
40
- }