@rc-component/select 1.3.6 → 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.
- package/es/BaseSelect/index.d.ts +1 -1
- package/es/Select.d.ts +1 -1
- package/es/SelectInput/Content/SingleContent.js +4 -10
- package/es/SelectInput/index.js +8 -2
- package/es/hooks/useBaseProps.d.ts +0 -1
- package/lib/BaseSelect/index.d.ts +1 -1
- package/lib/Select.d.ts +1 -1
- package/lib/SelectInput/Content/SingleContent.js +4 -10
- package/lib/SelectInput/index.js +8 -2
- package/lib/hooks/useBaseProps.d.ts +0 -1
- package/package.json +1 -1
package/es/BaseSelect/index.d.ts
CHANGED
|
@@ -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>>;
|
package/es/Select.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
125
125
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
126
126
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
127
127
|
}
|
|
128
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
128
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
129
129
|
Option: typeof Option;
|
|
130
130
|
OptGroup: typeof OptGroup;
|
|
131
131
|
};
|
|
@@ -40,7 +40,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
40
40
|
|
|
41
41
|
// Extract option props, excluding label and value, and handle className/style merging
|
|
42
42
|
const optionProps = React.useMemo(() => {
|
|
43
|
-
|
|
43
|
+
const restProps = {
|
|
44
44
|
className: `${prefixCls}-content-value`,
|
|
45
45
|
style: {
|
|
46
46
|
visibility: mergedSearchValue ? 'hidden' : 'visible'
|
|
@@ -50,23 +50,17 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
50
50
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
51
51
|
if (option?.data) {
|
|
52
52
|
const {
|
|
53
|
-
label,
|
|
54
|
-
value,
|
|
55
53
|
className,
|
|
56
|
-
style
|
|
57
|
-
key,
|
|
58
|
-
...rest
|
|
54
|
+
style
|
|
59
55
|
} = option.data;
|
|
60
|
-
restProps
|
|
61
|
-
...restProps,
|
|
62
|
-
...rest,
|
|
56
|
+
Object.assign(restProps, {
|
|
63
57
|
title: getTitle(option.data),
|
|
64
58
|
className: clsx(restProps.className, className),
|
|
65
59
|
style: {
|
|
66
60
|
...restProps.style,
|
|
67
61
|
...style
|
|
68
62
|
}
|
|
69
|
-
};
|
|
63
|
+
});
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
if (displayValue && !restProps.title) {
|
package/es/SelectInput/index.js
CHANGED
|
@@ -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
|
-
|
|
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>>;
|
package/lib/Select.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
125
125
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
126
126
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
127
127
|
}
|
|
128
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
128
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
129
129
|
Option: typeof Option;
|
|
130
130
|
OptGroup: typeof OptGroup;
|
|
131
131
|
};
|
|
@@ -49,7 +49,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
|
|
50
50
|
// Extract option props, excluding label and value, and handle className/style merging
|
|
51
51
|
const optionProps = React.useMemo(() => {
|
|
52
|
-
|
|
52
|
+
const restProps = {
|
|
53
53
|
className: `${prefixCls}-content-value`,
|
|
54
54
|
style: {
|
|
55
55
|
visibility: mergedSearchValue ? 'hidden' : 'visible'
|
|
@@ -59,23 +59,17 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
59
59
|
const option = selectContext.flattenOptions.find(opt => opt.value === displayValue.value);
|
|
60
60
|
if (option?.data) {
|
|
61
61
|
const {
|
|
62
|
-
label,
|
|
63
|
-
value,
|
|
64
62
|
className,
|
|
65
|
-
style
|
|
66
|
-
key,
|
|
67
|
-
...rest
|
|
63
|
+
style
|
|
68
64
|
} = option.data;
|
|
69
|
-
restProps
|
|
70
|
-
...restProps,
|
|
71
|
-
...rest,
|
|
65
|
+
Object.assign(restProps, {
|
|
72
66
|
title: (0, _commonUtil.getTitle)(option.data),
|
|
73
67
|
className: (0, _clsx.clsx)(restProps.className, className),
|
|
74
68
|
style: {
|
|
75
69
|
...restProps.style,
|
|
76
70
|
...style
|
|
77
71
|
}
|
|
78
|
-
};
|
|
72
|
+
});
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
75
|
if (displayValue && !restProps.title) {
|
package/lib/SelectInput/index.js
CHANGED
|
@@ -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
|
-
|
|
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;
|