@rc-component/select 1.0.2 → 1.0.4
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.js +4 -9
- package/es/OptionList.js +6 -5
- package/es/Select.d.ts +3 -2
- package/es/SelectContext.d.ts +7 -3
- package/es/SelectTrigger.d.ts +0 -1
- package/es/SelectTrigger.js +0 -2
- package/es/Selector/index.d.ts +1 -5
- package/es/Selector/index.js +5 -4
- package/lib/BaseSelect/index.js +4 -9
- package/lib/OptionList.js +6 -5
- package/lib/Select.d.ts +3 -2
- package/lib/SelectContext.d.ts +7 -3
- package/lib/SelectTrigger.d.ts +0 -1
- package/lib/SelectTrigger.js +0 -2
- package/lib/Selector/index.d.ts +1 -5
- package/lib/Selector/index.js +5 -4
- package/package.json +1 -1
package/es/BaseSelect/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
|
4
4
|
import useMergedState from "@rc-component/util/es/hooks/useMergedState";
|
|
5
5
|
import isMobile from "@rc-component/util/es/isMobile";
|
|
6
6
|
import { useComposeRef } from "@rc-component/util/es/ref";
|
|
7
|
+
import { getDOM } from "@rc-component/util/es/Dom/findDOMNode";
|
|
7
8
|
import * as React from 'react';
|
|
8
9
|
import { useAllowClear } from "../hooks/useAllowClear";
|
|
9
10
|
import { BaseSelectContext } from "../hooks/useBaseProps";
|
|
@@ -109,11 +110,11 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
109
110
|
|
|
110
111
|
// ============================== Refs ==============================
|
|
111
112
|
const containerRef = React.useRef(null);
|
|
112
|
-
const selectorDomRef = React.useRef(null);
|
|
113
113
|
const triggerRef = React.useRef(null);
|
|
114
114
|
const selectorRef = React.useRef(null);
|
|
115
115
|
const listRef = React.useRef(null);
|
|
116
116
|
const blurRef = React.useRef(false);
|
|
117
|
+
const customDomRef = React.useRef(null);
|
|
117
118
|
|
|
118
119
|
/** Used for component focused management */
|
|
119
120
|
const [mockFocused, setMockFocused, cancelSetMockFocused] = useDelayReset();
|
|
@@ -123,7 +124,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
123
124
|
focus: selectorRef.current?.focus,
|
|
124
125
|
blur: selectorRef.current?.blur,
|
|
125
126
|
scrollTo: arg => listRef.current?.scrollTo(arg),
|
|
126
|
-
nativeElement: containerRef.current ||
|
|
127
|
+
nativeElement: containerRef.current || selectorRef.current?.nativeElement || getDOM(customDomRef.current)
|
|
127
128
|
}));
|
|
128
129
|
|
|
129
130
|
// ========================== Search Value ==========================
|
|
@@ -141,7 +142,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
141
142
|
|
|
142
143
|
// Used for customize replacement for `rc-cascader`
|
|
143
144
|
const customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
|
|
144
|
-
const customizeRawInputRef = useComposeRef(
|
|
145
|
+
const customizeRawInputRef = useComposeRef(customDomRef, customizeRawInputElement?.props?.ref);
|
|
145
146
|
|
|
146
147
|
// ============================== Open ==============================
|
|
147
148
|
// SSR not support Portal which means we need delay `open` for the first time render
|
|
@@ -504,11 +505,6 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
504
505
|
builtinPlacements: builtinPlacements,
|
|
505
506
|
getPopupContainer: getPopupContainer,
|
|
506
507
|
empty: emptyOptions,
|
|
507
|
-
getTriggerDOMNode: node =>
|
|
508
|
-
// TODO: This is workaround and should be removed in `rc-select`
|
|
509
|
-
// And use new standard `nativeElement` for ref.
|
|
510
|
-
// But we should update `rc-resize-observer` first.
|
|
511
|
-
selectorDomRef.current || node,
|
|
512
508
|
onPopupVisibleChange: onTriggerVisibleChange,
|
|
513
509
|
onPopupMouseEnter: onPopupMouseEnter
|
|
514
510
|
}, customizeRawInputElement ? ( /*#__PURE__*/React.cloneElement(customizeRawInputElement, {
|
|
@@ -516,7 +512,6 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
516
512
|
})) : /*#__PURE__*/React.createElement(Selector, _extends({}, props, {
|
|
517
513
|
prefixClassName: classNames?.prefix,
|
|
518
514
|
prefixStyle: styles?.prefix,
|
|
519
|
-
domRef: selectorDomRef,
|
|
520
515
|
prefixCls: prefixCls,
|
|
521
516
|
inputElement: customizeInputElement,
|
|
522
517
|
ref: selectorRef,
|
package/es/OptionList.js
CHANGED
|
@@ -130,9 +130,10 @@ const OptionList = (_, ref) => {
|
|
|
130
130
|
const timeoutId = setTimeout(() => {
|
|
131
131
|
if (!multiple && open && rawValues.size === 1) {
|
|
132
132
|
const value = Array.from(rawValues)[0];
|
|
133
|
+
// Scroll to the option closest to the searchValue if searching.
|
|
133
134
|
const index = memoFlattenOptions.findIndex(({
|
|
134
135
|
data
|
|
135
|
-
}) => data.value === value);
|
|
136
|
+
}) => searchValue ? String(data.value).startsWith(searchValue) : data.value === value);
|
|
136
137
|
if (index !== -1) {
|
|
137
138
|
setActive(index);
|
|
138
139
|
scrollIntoView(index);
|
|
@@ -293,8 +294,8 @@ const OptionList = (_, ref) => {
|
|
|
293
294
|
direction: direction,
|
|
294
295
|
innerProps: virtual ? null : a11yProps,
|
|
295
296
|
showScrollBar: showScrollBar,
|
|
296
|
-
className: contextClassNames?.list,
|
|
297
|
-
style: contextStyles?.list
|
|
297
|
+
className: contextClassNames?.popup?.list,
|
|
298
|
+
style: contextStyles?.popup?.list
|
|
298
299
|
}, (item, itemIndex) => {
|
|
299
300
|
const {
|
|
300
301
|
group,
|
|
@@ -329,7 +330,7 @@ const OptionList = (_, ref) => {
|
|
|
329
330
|
const selected = isSelected(value);
|
|
330
331
|
const mergedDisabled = disabled || !selected && overMaxCount;
|
|
331
332
|
const optionPrefixCls = `${itemPrefixCls}-option`;
|
|
332
|
-
const optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, contextClassNames?.listItem, {
|
|
333
|
+
const optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, contextClassNames?.popup?.listItem, {
|
|
333
334
|
[`${optionPrefixCls}-grouped`]: groupOption,
|
|
334
335
|
[`${optionPrefixCls}-active`]: activeIndex === itemIndex && !mergedDisabled,
|
|
335
336
|
[`${optionPrefixCls}-disabled`]: mergedDisabled,
|
|
@@ -361,7 +362,7 @@ const OptionList = (_, ref) => {
|
|
|
361
362
|
}
|
|
362
363
|
},
|
|
363
364
|
style: {
|
|
364
|
-
...contextStyles?.listItem,
|
|
365
|
+
...contextStyles?.popup?.listItem,
|
|
365
366
|
...style
|
|
366
367
|
}
|
|
367
368
|
}), /*#__PURE__*/React.createElement("div", {
|
package/es/Select.d.ts
CHANGED
|
@@ -65,7 +65,8 @@ export interface DefaultOptionType extends BaseOptionType {
|
|
|
65
65
|
}
|
|
66
66
|
export type SelectHandler<ValueType, OptionType extends BaseOptionType = DefaultOptionType> = (value: ValueType, option: OptionType) => void;
|
|
67
67
|
type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
|
68
|
-
export type SemanticName = BaseSelectSemanticName
|
|
68
|
+
export type SemanticName = BaseSelectSemanticName;
|
|
69
|
+
export type PopupSemantic = 'listItem' | 'list';
|
|
69
70
|
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
|
70
71
|
prefixCls?: string;
|
|
71
72
|
id?: string;
|
|
@@ -108,7 +109,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
108
109
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
109
110
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
110
111
|
}
|
|
111
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
112
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
|
112
113
|
children?: React.ReactNode;
|
|
113
114
|
} & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
114
115
|
Option: typeof Option;
|
package/es/SelectContext.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { RawValueType, RenderNode } from './BaseSelect';
|
|
3
|
-
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName } from './Select';
|
|
3
|
+
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName, PopupSemantic } from './Select';
|
|
4
4
|
import type { FlattenOptionData } from './interface';
|
|
5
5
|
/**
|
|
6
6
|
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
7
7
|
*/
|
|
8
8
|
export interface SelectContextProps {
|
|
9
|
-
classNames?: Partial<Record<SemanticName, string
|
|
10
|
-
|
|
9
|
+
classNames?: Partial<Record<SemanticName, string>> & {
|
|
10
|
+
popup?: Partial<Record<PopupSemantic, string>>;
|
|
11
|
+
};
|
|
12
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
|
|
13
|
+
popup?: Partial<Record<PopupSemantic, React.CSSProperties>>;
|
|
14
|
+
};
|
|
11
15
|
options: BaseOptionType[];
|
|
12
16
|
optionRender?: SelectProps['optionRender'];
|
|
13
17
|
flattenOptions: FlattenOptionData<BaseOptionType>[];
|
package/es/SelectTrigger.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export interface SelectTriggerProps {
|
|
|
22
22
|
getPopupContainer?: RenderDOMFunc;
|
|
23
23
|
popupAlign: AlignType;
|
|
24
24
|
empty: boolean;
|
|
25
|
-
getTriggerDOMNode: (node: HTMLElement) => HTMLElement;
|
|
26
25
|
onPopupVisibleChange?: (visible: boolean) => void;
|
|
27
26
|
onPopupMouseEnter: () => void;
|
|
28
27
|
}
|
package/es/SelectTrigger.js
CHANGED
|
@@ -63,7 +63,6 @@ const SelectTrigger = (props, ref) => {
|
|
|
63
63
|
popupAlign,
|
|
64
64
|
getPopupContainer,
|
|
65
65
|
empty,
|
|
66
|
-
getTriggerDOMNode,
|
|
67
66
|
onPopupVisibleChange,
|
|
68
67
|
onPopupMouseEnter,
|
|
69
68
|
...restProps
|
|
@@ -127,7 +126,6 @@ const SelectTrigger = (props, ref) => {
|
|
|
127
126
|
[`${popupPrefixCls}-empty`]: empty
|
|
128
127
|
}),
|
|
129
128
|
popupStyle: mergedPopupStyle,
|
|
130
|
-
getTriggerDOMNode: getTriggerDOMNode,
|
|
131
129
|
onPopupVisibleChange: onPopupVisibleChange
|
|
132
130
|
}), children);
|
|
133
131
|
};
|
package/es/Selector/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface RefSelectorProps {
|
|
|
40
40
|
focus: (options?: FocusOptions) => void;
|
|
41
41
|
blur: () => void;
|
|
42
42
|
scrollTo?: ScrollTo;
|
|
43
|
+
nativeElement: HTMLDivElement;
|
|
43
44
|
}
|
|
44
45
|
export interface SelectorProps {
|
|
45
46
|
prefixClassName: string;
|
|
@@ -77,11 +78,6 @@ export interface SelectorProps {
|
|
|
77
78
|
onRemove: (value: DisplayValueType) => void;
|
|
78
79
|
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
79
80
|
onInputBlur?: () => void;
|
|
80
|
-
/**
|
|
81
|
-
* @private get real dom for trigger align.
|
|
82
|
-
* This may be removed after React provides replacement of `findDOMNode`
|
|
83
|
-
*/
|
|
84
|
-
domRef: React.Ref<HTMLDivElement>;
|
|
85
81
|
}
|
|
86
82
|
declare const ForwardSelector: React.ForwardRefExoticComponent<SelectorProps & React.RefAttributes<RefSelectorProps>>;
|
|
87
83
|
export default ForwardSelector;
|
package/es/Selector/index.js
CHANGED
|
@@ -35,18 +35,19 @@ const Selector = (props, ref) => {
|
|
|
35
35
|
onSearchSubmit,
|
|
36
36
|
onToggleOpen,
|
|
37
37
|
onInputKeyDown,
|
|
38
|
-
onInputBlur
|
|
39
|
-
domRef
|
|
38
|
+
onInputBlur
|
|
40
39
|
} = props;
|
|
41
40
|
|
|
42
41
|
// ======================= Ref =======================
|
|
42
|
+
const containerRef = React.useRef(null);
|
|
43
43
|
React.useImperativeHandle(ref, () => ({
|
|
44
44
|
focus: options => {
|
|
45
45
|
inputRef.current.focus(options);
|
|
46
46
|
},
|
|
47
47
|
blur: () => {
|
|
48
48
|
inputRef.current.blur();
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
|
+
nativeElement: containerRef.current
|
|
50
51
|
}));
|
|
51
52
|
|
|
52
53
|
// ====================== Input ======================
|
|
@@ -172,7 +173,7 @@ const Selector = (props, ref) => {
|
|
|
172
173
|
};
|
|
173
174
|
const selectNode = mode === 'multiple' || mode === 'tags' ? /*#__PURE__*/React.createElement(MultipleSelector, _extends({}, props, sharedProps)) : /*#__PURE__*/React.createElement(SingleSelector, _extends({}, props, sharedProps));
|
|
174
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
175
|
-
ref:
|
|
176
|
+
ref: containerRef,
|
|
176
177
|
className: `${prefixCls}-selector`,
|
|
177
178
|
onClick: onClick,
|
|
178
179
|
onMouseDown: onMouseDown
|
package/lib/BaseSelect/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/ho
|
|
|
9
9
|
var _useMergedState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMergedState"));
|
|
10
10
|
var _isMobile = _interopRequireDefault(require("@rc-component/util/lib/isMobile"));
|
|
11
11
|
var _ref = require("@rc-component/util/lib/ref");
|
|
12
|
+
var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
|
|
12
13
|
var React = _interopRequireWildcard(require("react"));
|
|
13
14
|
var _useAllowClear = require("../hooks/useAllowClear");
|
|
14
15
|
var _useBaseProps = require("../hooks/useBaseProps");
|
|
@@ -119,11 +120,11 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
119
120
|
|
|
120
121
|
// ============================== Refs ==============================
|
|
121
122
|
const containerRef = React.useRef(null);
|
|
122
|
-
const selectorDomRef = React.useRef(null);
|
|
123
123
|
const triggerRef = React.useRef(null);
|
|
124
124
|
const selectorRef = React.useRef(null);
|
|
125
125
|
const listRef = React.useRef(null);
|
|
126
126
|
const blurRef = React.useRef(false);
|
|
127
|
+
const customDomRef = React.useRef(null);
|
|
127
128
|
|
|
128
129
|
/** Used for component focused management */
|
|
129
130
|
const [mockFocused, setMockFocused, cancelSetMockFocused] = (0, _useDelayReset.default)();
|
|
@@ -133,7 +134,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
133
134
|
focus: selectorRef.current?.focus,
|
|
134
135
|
blur: selectorRef.current?.blur,
|
|
135
136
|
scrollTo: arg => listRef.current?.scrollTo(arg),
|
|
136
|
-
nativeElement: containerRef.current ||
|
|
137
|
+
nativeElement: containerRef.current || selectorRef.current?.nativeElement || (0, _findDOMNode.getDOM)(customDomRef.current)
|
|
137
138
|
}));
|
|
138
139
|
|
|
139
140
|
// ========================== Search Value ==========================
|
|
@@ -151,7 +152,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
151
152
|
|
|
152
153
|
// Used for customize replacement for `rc-cascader`
|
|
153
154
|
const customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
|
|
154
|
-
const customizeRawInputRef = (0, _ref.useComposeRef)(
|
|
155
|
+
const customizeRawInputRef = (0, _ref.useComposeRef)(customDomRef, customizeRawInputElement?.props?.ref);
|
|
155
156
|
|
|
156
157
|
// ============================== Open ==============================
|
|
157
158
|
// SSR not support Portal which means we need delay `open` for the first time render
|
|
@@ -514,11 +515,6 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
514
515
|
builtinPlacements: builtinPlacements,
|
|
515
516
|
getPopupContainer: getPopupContainer,
|
|
516
517
|
empty: emptyOptions,
|
|
517
|
-
getTriggerDOMNode: node =>
|
|
518
|
-
// TODO: This is workaround and should be removed in `rc-select`
|
|
519
|
-
// And use new standard `nativeElement` for ref.
|
|
520
|
-
// But we should update `rc-resize-observer` first.
|
|
521
|
-
selectorDomRef.current || node,
|
|
522
518
|
onPopupVisibleChange: onTriggerVisibleChange,
|
|
523
519
|
onPopupMouseEnter: onPopupMouseEnter
|
|
524
520
|
}, customizeRawInputElement ? ( /*#__PURE__*/React.cloneElement(customizeRawInputElement, {
|
|
@@ -526,7 +522,6 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
526
522
|
})) : /*#__PURE__*/React.createElement(_Selector.default, _extends({}, props, {
|
|
527
523
|
prefixClassName: classNames?.prefix,
|
|
528
524
|
prefixStyle: styles?.prefix,
|
|
529
|
-
domRef: selectorDomRef,
|
|
530
525
|
prefixCls: prefixCls,
|
|
531
526
|
inputElement: customizeInputElement,
|
|
532
527
|
ref: selectorRef,
|
package/lib/OptionList.js
CHANGED
|
@@ -138,9 +138,10 @@ const OptionList = (_, ref) => {
|
|
|
138
138
|
const timeoutId = setTimeout(() => {
|
|
139
139
|
if (!multiple && open && rawValues.size === 1) {
|
|
140
140
|
const value = Array.from(rawValues)[0];
|
|
141
|
+
// Scroll to the option closest to the searchValue if searching.
|
|
141
142
|
const index = memoFlattenOptions.findIndex(({
|
|
142
143
|
data
|
|
143
|
-
}) => data.value === value);
|
|
144
|
+
}) => searchValue ? String(data.value).startsWith(searchValue) : data.value === value);
|
|
144
145
|
if (index !== -1) {
|
|
145
146
|
setActive(index);
|
|
146
147
|
scrollIntoView(index);
|
|
@@ -301,8 +302,8 @@ const OptionList = (_, ref) => {
|
|
|
301
302
|
direction: direction,
|
|
302
303
|
innerProps: virtual ? null : a11yProps,
|
|
303
304
|
showScrollBar: showScrollBar,
|
|
304
|
-
className: contextClassNames?.list,
|
|
305
|
-
style: contextStyles?.list
|
|
305
|
+
className: contextClassNames?.popup?.list,
|
|
306
|
+
style: contextStyles?.popup?.list
|
|
306
307
|
}, (item, itemIndex) => {
|
|
307
308
|
const {
|
|
308
309
|
group,
|
|
@@ -337,7 +338,7 @@ const OptionList = (_, ref) => {
|
|
|
337
338
|
const selected = isSelected(value);
|
|
338
339
|
const mergedDisabled = disabled || !selected && overMaxCount;
|
|
339
340
|
const optionPrefixCls = `${itemPrefixCls}-option`;
|
|
340
|
-
const optionClassName = (0, _classnames.default)(itemPrefixCls, optionPrefixCls, className, contextClassNames?.listItem, {
|
|
341
|
+
const optionClassName = (0, _classnames.default)(itemPrefixCls, optionPrefixCls, className, contextClassNames?.popup?.listItem, {
|
|
341
342
|
[`${optionPrefixCls}-grouped`]: groupOption,
|
|
342
343
|
[`${optionPrefixCls}-active`]: activeIndex === itemIndex && !mergedDisabled,
|
|
343
344
|
[`${optionPrefixCls}-disabled`]: mergedDisabled,
|
|
@@ -369,7 +370,7 @@ const OptionList = (_, ref) => {
|
|
|
369
370
|
}
|
|
370
371
|
},
|
|
371
372
|
style: {
|
|
372
|
-
...contextStyles?.listItem,
|
|
373
|
+
...contextStyles?.popup?.listItem,
|
|
373
374
|
...style
|
|
374
375
|
}
|
|
375
376
|
}), /*#__PURE__*/React.createElement("div", {
|
package/lib/Select.d.ts
CHANGED
|
@@ -65,7 +65,8 @@ export interface DefaultOptionType extends BaseOptionType {
|
|
|
65
65
|
}
|
|
66
66
|
export type SelectHandler<ValueType, OptionType extends BaseOptionType = DefaultOptionType> = (value: ValueType, option: OptionType) => void;
|
|
67
67
|
type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
|
68
|
-
export type SemanticName = BaseSelectSemanticName
|
|
68
|
+
export type SemanticName = BaseSelectSemanticName;
|
|
69
|
+
export type PopupSemantic = 'listItem' | 'list';
|
|
69
70
|
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
|
70
71
|
prefixCls?: string;
|
|
71
72
|
id?: string;
|
|
@@ -108,7 +109,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
108
109
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
109
110
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
110
111
|
}
|
|
111
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
112
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
|
112
113
|
children?: React.ReactNode;
|
|
113
114
|
} & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
114
115
|
Option: typeof Option;
|
package/lib/SelectContext.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { RawValueType, RenderNode } from './BaseSelect';
|
|
3
|
-
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName } from './Select';
|
|
3
|
+
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName, PopupSemantic } from './Select';
|
|
4
4
|
import type { FlattenOptionData } from './interface';
|
|
5
5
|
/**
|
|
6
6
|
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
7
7
|
*/
|
|
8
8
|
export interface SelectContextProps {
|
|
9
|
-
classNames?: Partial<Record<SemanticName, string
|
|
10
|
-
|
|
9
|
+
classNames?: Partial<Record<SemanticName, string>> & {
|
|
10
|
+
popup?: Partial<Record<PopupSemantic, string>>;
|
|
11
|
+
};
|
|
12
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
|
|
13
|
+
popup?: Partial<Record<PopupSemantic, React.CSSProperties>>;
|
|
14
|
+
};
|
|
11
15
|
options: BaseOptionType[];
|
|
12
16
|
optionRender?: SelectProps['optionRender'];
|
|
13
17
|
flattenOptions: FlattenOptionData<BaseOptionType>[];
|
package/lib/SelectTrigger.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export interface SelectTriggerProps {
|
|
|
22
22
|
getPopupContainer?: RenderDOMFunc;
|
|
23
23
|
popupAlign: AlignType;
|
|
24
24
|
empty: boolean;
|
|
25
|
-
getTriggerDOMNode: (node: HTMLElement) => HTMLElement;
|
|
26
25
|
onPopupVisibleChange?: (visible: boolean) => void;
|
|
27
26
|
onPopupMouseEnter: () => void;
|
|
28
27
|
}
|
package/lib/SelectTrigger.js
CHANGED
|
@@ -72,7 +72,6 @@ const SelectTrigger = (props, ref) => {
|
|
|
72
72
|
popupAlign,
|
|
73
73
|
getPopupContainer,
|
|
74
74
|
empty,
|
|
75
|
-
getTriggerDOMNode,
|
|
76
75
|
onPopupVisibleChange,
|
|
77
76
|
onPopupMouseEnter,
|
|
78
77
|
...restProps
|
|
@@ -136,7 +135,6 @@ const SelectTrigger = (props, ref) => {
|
|
|
136
135
|
[`${popupPrefixCls}-empty`]: empty
|
|
137
136
|
}),
|
|
138
137
|
popupStyle: mergedPopupStyle,
|
|
139
|
-
getTriggerDOMNode: getTriggerDOMNode,
|
|
140
138
|
onPopupVisibleChange: onPopupVisibleChange
|
|
141
139
|
}), children);
|
|
142
140
|
};
|
package/lib/Selector/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface RefSelectorProps {
|
|
|
40
40
|
focus: (options?: FocusOptions) => void;
|
|
41
41
|
blur: () => void;
|
|
42
42
|
scrollTo?: ScrollTo;
|
|
43
|
+
nativeElement: HTMLDivElement;
|
|
43
44
|
}
|
|
44
45
|
export interface SelectorProps {
|
|
45
46
|
prefixClassName: string;
|
|
@@ -77,11 +78,6 @@ export interface SelectorProps {
|
|
|
77
78
|
onRemove: (value: DisplayValueType) => void;
|
|
78
79
|
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
79
80
|
onInputBlur?: () => void;
|
|
80
|
-
/**
|
|
81
|
-
* @private get real dom for trigger align.
|
|
82
|
-
* This may be removed after React provides replacement of `findDOMNode`
|
|
83
|
-
*/
|
|
84
|
-
domRef: React.Ref<HTMLDivElement>;
|
|
85
81
|
}
|
|
86
82
|
declare const ForwardSelector: React.ForwardRefExoticComponent<SelectorProps & React.RefAttributes<RefSelectorProps>>;
|
|
87
83
|
export default ForwardSelector;
|
package/lib/Selector/index.js
CHANGED
|
@@ -42,18 +42,19 @@ const Selector = (props, ref) => {
|
|
|
42
42
|
onSearchSubmit,
|
|
43
43
|
onToggleOpen,
|
|
44
44
|
onInputKeyDown,
|
|
45
|
-
onInputBlur
|
|
46
|
-
domRef
|
|
45
|
+
onInputBlur
|
|
47
46
|
} = props;
|
|
48
47
|
|
|
49
48
|
// ======================= Ref =======================
|
|
49
|
+
const containerRef = React.useRef(null);
|
|
50
50
|
React.useImperativeHandle(ref, () => ({
|
|
51
51
|
focus: options => {
|
|
52
52
|
inputRef.current.focus(options);
|
|
53
53
|
},
|
|
54
54
|
blur: () => {
|
|
55
55
|
inputRef.current.blur();
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
|
+
nativeElement: containerRef.current
|
|
57
58
|
}));
|
|
58
59
|
|
|
59
60
|
// ====================== Input ======================
|
|
@@ -179,7 +180,7 @@ const Selector = (props, ref) => {
|
|
|
179
180
|
};
|
|
180
181
|
const selectNode = mode === 'multiple' || mode === 'tags' ? /*#__PURE__*/React.createElement(_MultipleSelector.default, _extends({}, props, sharedProps)) : /*#__PURE__*/React.createElement(_SingleSelector.default, _extends({}, props, sharedProps));
|
|
181
182
|
return /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
ref:
|
|
183
|
+
ref: containerRef,
|
|
183
184
|
className: `${prefixCls}-selector`,
|
|
184
185
|
onClick: onClick,
|
|
185
186
|
onMouseDown: onMouseDown
|