@rc-component/select 1.4.0 → 1.5.0

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.
@@ -59,7 +59,7 @@ export interface BaseSelectPrivateProps {
59
59
  emptyOptions: boolean;
60
60
  }
61
61
  export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
62
- export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
62
+ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes, Pick<React.HTMLAttributes<HTMLElement>, 'role'> {
63
63
  className?: string;
64
64
  style?: React.CSSProperties;
65
65
  classNames?: Partial<Record<BaseSelectSemanticName, string>>;
@@ -10,6 +10,7 @@ import { isValidateOpenKey } from "../utils/keyUtil";
10
10
  import { clsx } from 'clsx';
11
11
  import { getDOM } from "@rc-component/util/es/Dom/findDOMNode";
12
12
  import { composeRef } from "@rc-component/util/es/ref";
13
+ import pickAttrs from "@rc-component/util/es/pickAttrs";
13
14
  const DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex', 'activeValue', 'onSelectorRemove', 'focused'];
14
15
  export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
15
16
  const {
@@ -83,7 +84,8 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
83
84
  }
84
85
 
85
86
  // Open dropdown when a valid open key is pressed
86
- if (isValidateOpenKey(which)) {
87
+ const isModifier = event.ctrlKey || event.altKey || event.metaKey;
88
+ if (!isModifier && isValidateOpenKey(which)) {
87
89
  toggleOpen(true);
88
90
  }
89
91
  });
@@ -141,6 +143,10 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
141
143
 
142
144
  // ===================== Render =====================
143
145
  const domProps = omit(restProps, DEFAULT_OMIT_PROPS);
146
+ const ariaProps = pickAttrs(domProps, {
147
+ aria: true
148
+ });
149
+ const ariaKeys = Object.keys(ariaProps);
144
150
 
145
151
  // Create context value with wrapped callbacks
146
152
  const contextValue = {
@@ -160,7 +166,7 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
160
166
  }
161
167
  return /*#__PURE__*/React.createElement(SelectInputContext.Provider, {
162
168
  value: contextValue
163
- }, /*#__PURE__*/React.createElement("div", _extends({}, domProps, {
169
+ }, /*#__PURE__*/React.createElement("div", _extends({}, omit(domProps, ariaKeys), {
164
170
  // Style
165
171
  ref: rootRef,
166
172
  className: className,
@@ -8,7 +8,6 @@ export interface BaseSelectContextProps extends BaseSelectProps {
8
8
  triggerOpen: boolean;
9
9
  multiple: boolean;
10
10
  toggleOpen: (open?: boolean) => void;
11
- role?: React.AriaRole;
12
11
  }
13
12
  export declare const BaseSelectContext: React.Context<BaseSelectContextProps>;
14
13
  export default function useBaseProps(): BaseSelectContextProps;
@@ -59,7 +59,7 @@ export interface BaseSelectPrivateProps {
59
59
  emptyOptions: boolean;
60
60
  }
61
61
  export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
62
- export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
62
+ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes, Pick<React.HTMLAttributes<HTMLElement>, 'role'> {
63
63
  className?: string;
64
64
  style?: React.CSSProperties;
65
65
  classNames?: Partial<Record<BaseSelectSemanticName, string>>;
@@ -15,6 +15,7 @@ var _keyUtil = require("../utils/keyUtil");
15
15
  var _clsx = require("clsx");
16
16
  var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
17
17
  var _ref = require("@rc-component/util/lib/ref");
18
+ var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
18
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20
  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); }
20
21
  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; }
@@ -92,7 +93,8 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
92
93
  }
93
94
 
94
95
  // Open dropdown when a valid open key is pressed
95
- if ((0, _keyUtil.isValidateOpenKey)(which)) {
96
+ const isModifier = event.ctrlKey || event.altKey || event.metaKey;
97
+ if (!isModifier && (0, _keyUtil.isValidateOpenKey)(which)) {
96
98
  toggleOpen(true);
97
99
  }
98
100
  });
@@ -150,6 +152,10 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
150
152
 
151
153
  // ===================== Render =====================
152
154
  const domProps = (0, _util.omit)(restProps, DEFAULT_OMIT_PROPS);
155
+ const ariaProps = (0, _pickAttrs.default)(domProps, {
156
+ aria: true
157
+ });
158
+ const ariaKeys = Object.keys(ariaProps);
153
159
 
154
160
  // Create context value with wrapped callbacks
155
161
  const contextValue = {
@@ -169,7 +175,7 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
169
175
  }
170
176
  return /*#__PURE__*/React.createElement(_context.default.Provider, {
171
177
  value: contextValue
172
- }, /*#__PURE__*/React.createElement("div", _extends({}, domProps, {
178
+ }, /*#__PURE__*/React.createElement("div", _extends({}, (0, _util.omit)(domProps, ariaKeys), {
173
179
  // Style
174
180
  ref: rootRef,
175
181
  className: className,
@@ -8,7 +8,6 @@ export interface BaseSelectContextProps extends BaseSelectProps {
8
8
  triggerOpen: boolean;
9
9
  multiple: boolean;
10
10
  toggleOpen: (open?: boolean) => void;
11
- role?: React.AriaRole;
12
11
  }
13
12
  export declare const BaseSelectContext: React.Context<BaseSelectContextProps>;
14
13
  export default function useBaseProps(): BaseSelectContextProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"