@rc-component/select 1.0.0 → 1.0.2
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 +9 -5
- package/es/BaseSelect/index.js +15 -12
- package/es/OptionList.js +11 -4
- package/es/Select.d.ts +5 -2
- package/es/Select.js +12 -3
- package/es/SelectContext.d.ts +6 -1
- package/es/SelectContext.js +3 -0
- package/es/Selector/Input.js +8 -2
- package/es/Selector/index.d.ts +2 -0
- package/es/Selector/index.js +5 -1
- package/es/TransBtn.d.ts +1 -0
- package/es/TransBtn.js +3 -1
- package/lib/BaseSelect/index.d.ts +9 -5
- package/lib/BaseSelect/index.js +13 -10
- package/lib/OptionList.js +11 -4
- package/lib/Select.d.ts +5 -2
- package/lib/Select.js +12 -3
- package/lib/SelectContext.d.ts +6 -1
- package/lib/SelectContext.js +3 -0
- package/lib/Selector/Input.js +8 -2
- package/lib/Selector/index.d.ts +2 -0
- package/lib/Selector/index.js +5 -1
- package/lib/TransBtn.d.ts +1 -0
- package/lib/TransBtn.js +3 -1
- package/package.json +1 -1
package/es/BaseSelect/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/int
|
|
|
2
2
|
import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
|
|
5
|
+
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input';
|
|
5
6
|
export type { DisplayInfoType, DisplayValueType, Mode, Placement, RenderDOMFunc, RenderNode, RawValueType, };
|
|
6
7
|
export interface RefOptionListProps {
|
|
7
8
|
onKeyDown: React.KeyboardEventHandler;
|
|
@@ -53,17 +54,20 @@ export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSele
|
|
|
53
54
|
export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
|
|
54
55
|
className?: string;
|
|
55
56
|
style?: React.CSSProperties;
|
|
56
|
-
|
|
57
|
+
classNames?: Partial<Record<BaseSelectSemanticName, string>>;
|
|
58
|
+
styles?: Partial<Record<BaseSelectSemanticName, React.CSSProperties>>;
|
|
57
59
|
showSearch?: boolean;
|
|
58
60
|
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
|
59
61
|
direction?: 'ltr' | 'rtl';
|
|
60
|
-
maxLength?: number;
|
|
61
|
-
showScrollBar?: boolean | 'optional';
|
|
62
|
-
tabIndex?: number;
|
|
63
62
|
autoFocus?: boolean;
|
|
64
|
-
notFoundContent?: React.ReactNode;
|
|
65
63
|
placeholder?: React.ReactNode;
|
|
64
|
+
maxCount?: number;
|
|
65
|
+
title?: string;
|
|
66
|
+
tabIndex?: number;
|
|
67
|
+
notFoundContent?: React.ReactNode;
|
|
66
68
|
onClear?: () => void;
|
|
69
|
+
maxLength?: number;
|
|
70
|
+
showScrollBar?: boolean | 'optional';
|
|
67
71
|
choiceTransitionName?: string;
|
|
68
72
|
mode?: Mode;
|
|
69
73
|
disabled?: boolean;
|
package/es/BaseSelect/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import
|
|
2
|
+
import cls from 'classnames';
|
|
3
3
|
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";
|
|
@@ -14,7 +14,6 @@ import Selector from "../Selector";
|
|
|
14
14
|
import SelectTrigger from "../SelectTrigger";
|
|
15
15
|
import TransBtn from "../TransBtn";
|
|
16
16
|
import { getSeparatedContent, isValidCount } from "../utils/valueUtil";
|
|
17
|
-
import SelectContext from "../SelectContext";
|
|
18
17
|
import Polite from "./Polite";
|
|
19
18
|
const DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex'];
|
|
20
19
|
export const isMultiple = mode => mode === 'tags' || mode === 'multiple';
|
|
@@ -23,6 +22,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
23
22
|
id,
|
|
24
23
|
prefixCls,
|
|
25
24
|
className,
|
|
25
|
+
styles,
|
|
26
|
+
classNames,
|
|
26
27
|
showSearch,
|
|
27
28
|
tagRender,
|
|
28
29
|
showScrollBar = 'optional',
|
|
@@ -34,6 +35,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
34
35
|
emptyOptions,
|
|
35
36
|
notFoundContent = 'Not Found',
|
|
36
37
|
onClear,
|
|
38
|
+
maxCount,
|
|
37
39
|
// Mode
|
|
38
40
|
mode,
|
|
39
41
|
// Status
|
|
@@ -171,18 +173,14 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
171
173
|
|
|
172
174
|
// ============================= Search =============================
|
|
173
175
|
const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
|
|
174
|
-
const {
|
|
175
|
-
maxCount,
|
|
176
|
-
rawValues
|
|
177
|
-
} = React.useContext(SelectContext) || {};
|
|
178
176
|
const onInternalSearch = (searchText, fromTyping, isCompositing) => {
|
|
179
|
-
if (multiple && isValidCount(maxCount) &&
|
|
177
|
+
if (multiple && isValidCount(maxCount) && displayValues.length >= maxCount) {
|
|
180
178
|
return;
|
|
181
179
|
}
|
|
182
180
|
let ret = true;
|
|
183
181
|
let newSearchText = searchText;
|
|
184
182
|
onActiveValueChange?.(null);
|
|
185
|
-
const separatedList = getSeparatedContent(searchText, tokenSeparators, isValidCount(maxCount) ? maxCount -
|
|
183
|
+
const separatedList = getSeparatedContent(searchText, tokenSeparators, isValidCount(maxCount) ? maxCount - displayValues.length : undefined);
|
|
186
184
|
|
|
187
185
|
// Check if match the `tokenSeparators`
|
|
188
186
|
const patchLabels = isCompositing ? null : separatedList;
|
|
@@ -424,8 +422,10 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
424
422
|
showSearch: mergedShowSearch,
|
|
425
423
|
multiple,
|
|
426
424
|
toggleOpen: onToggleOpen,
|
|
427
|
-
showScrollBar
|
|
428
|
-
|
|
425
|
+
showScrollBar,
|
|
426
|
+
styles,
|
|
427
|
+
classNames
|
|
428
|
+
}), [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen, showScrollBar, styles, classNames]);
|
|
429
429
|
|
|
430
430
|
// ==================================================================
|
|
431
431
|
// == Render ==
|
|
@@ -436,9 +436,10 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
436
436
|
let arrowNode;
|
|
437
437
|
if (showSuffixIcon) {
|
|
438
438
|
arrowNode = /*#__PURE__*/React.createElement(TransBtn, {
|
|
439
|
-
className:
|
|
439
|
+
className: cls(`${prefixCls}-arrow`, classNames?.suffix, {
|
|
440
440
|
[`${prefixCls}-arrow-loading`]: loading
|
|
441
441
|
}),
|
|
442
|
+
style: styles?.suffix,
|
|
442
443
|
customizeIcon: suffixIcon,
|
|
443
444
|
customizeIconProps: {
|
|
444
445
|
loading,
|
|
@@ -471,7 +472,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
471
472
|
});
|
|
472
473
|
|
|
473
474
|
// ============================= Select =============================
|
|
474
|
-
const mergedClassName =
|
|
475
|
+
const mergedClassName = cls(prefixCls, className, {
|
|
475
476
|
[`${prefixCls}-focused`]: mockFocused,
|
|
476
477
|
[`${prefixCls}-multiple`]: multiple,
|
|
477
478
|
[`${prefixCls}-single`]: !multiple,
|
|
@@ -513,6 +514,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
513
514
|
}, customizeRawInputElement ? ( /*#__PURE__*/React.cloneElement(customizeRawInputElement, {
|
|
514
515
|
ref: customizeRawInputRef
|
|
515
516
|
})) : /*#__PURE__*/React.createElement(Selector, _extends({}, props, {
|
|
517
|
+
prefixClassName: classNames?.prefix,
|
|
518
|
+
prefixStyle: styles?.prefix,
|
|
516
519
|
domRef: selectorDomRef,
|
|
517
520
|
prefixCls: prefixCls,
|
|
518
521
|
inputElement: customizeInputElement,
|
package/es/OptionList.js
CHANGED
|
@@ -49,7 +49,9 @@ const OptionList = (_, ref) => {
|
|
|
49
49
|
direction,
|
|
50
50
|
listHeight,
|
|
51
51
|
listItemHeight,
|
|
52
|
-
optionRender
|
|
52
|
+
optionRender,
|
|
53
|
+
classNames: contextClassNames,
|
|
54
|
+
styles: contextStyles
|
|
53
55
|
} = React.useContext(SelectContext);
|
|
54
56
|
const itemPrefixCls = `${prefixCls}-item`;
|
|
55
57
|
const memoFlattenOptions = useMemo(() => flattenOptions, [open, flattenOptions], (prev, next) => next[0] && prev[1] !== next[1]);
|
|
@@ -290,7 +292,9 @@ const OptionList = (_, ref) => {
|
|
|
290
292
|
virtual: virtual,
|
|
291
293
|
direction: direction,
|
|
292
294
|
innerProps: virtual ? null : a11yProps,
|
|
293
|
-
showScrollBar: showScrollBar
|
|
295
|
+
showScrollBar: showScrollBar,
|
|
296
|
+
className: contextClassNames?.list,
|
|
297
|
+
style: contextStyles?.list
|
|
294
298
|
}, (item, itemIndex) => {
|
|
295
299
|
const {
|
|
296
300
|
group,
|
|
@@ -325,7 +329,7 @@ const OptionList = (_, ref) => {
|
|
|
325
329
|
const selected = isSelected(value);
|
|
326
330
|
const mergedDisabled = disabled || !selected && overMaxCount;
|
|
327
331
|
const optionPrefixCls = `${itemPrefixCls}-option`;
|
|
328
|
-
const optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, {
|
|
332
|
+
const optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, contextClassNames?.listItem, {
|
|
329
333
|
[`${optionPrefixCls}-grouped`]: groupOption,
|
|
330
334
|
[`${optionPrefixCls}-active`]: activeIndex === itemIndex && !mergedDisabled,
|
|
331
335
|
[`${optionPrefixCls}-disabled`]: mergedDisabled,
|
|
@@ -356,7 +360,10 @@ const OptionList = (_, ref) => {
|
|
|
356
360
|
onSelectValue(value);
|
|
357
361
|
}
|
|
358
362
|
},
|
|
359
|
-
style:
|
|
363
|
+
style: {
|
|
364
|
+
...contextStyles?.listItem,
|
|
365
|
+
...style
|
|
366
|
+
}
|
|
360
367
|
}), /*#__PURE__*/React.createElement("div", {
|
|
361
368
|
className: `${optionPrefixCls}-content`
|
|
362
369
|
}, typeof optionRender === 'function' ? optionRender(item, {
|
package/es/Select.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* - `combobox` mode not support `optionLabelProp`
|
|
30
30
|
*/
|
|
31
31
|
import * as React from 'react';
|
|
32
|
-
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, DisplayValueType, RenderNode } from './BaseSelect';
|
|
32
|
+
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, BaseSelectSemanticName, DisplayValueType, RenderNode } from './BaseSelect';
|
|
33
33
|
import OptGroup from './OptGroup';
|
|
34
34
|
import Option from './Option';
|
|
35
35
|
import type { FlattenOptionData } from './interface';
|
|
@@ -65,6 +65,7 @@ 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 | 'listItem' | 'list';
|
|
68
69
|
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
|
69
70
|
prefixCls?: string;
|
|
70
71
|
id?: string;
|
|
@@ -104,8 +105,10 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
104
105
|
defaultValue?: ValueType | null;
|
|
105
106
|
maxCount?: number;
|
|
106
107
|
onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
|
|
108
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
109
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
107
110
|
}
|
|
108
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
111
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
|
109
112
|
children?: React.ReactNode;
|
|
110
113
|
} & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
111
114
|
Option: typeof Option;
|
package/es/Select.js
CHANGED
|
@@ -86,6 +86,8 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
86
86
|
labelInValue,
|
|
87
87
|
onChange,
|
|
88
88
|
maxCount,
|
|
89
|
+
classNames,
|
|
90
|
+
styles,
|
|
89
91
|
...restProps
|
|
90
92
|
} = props;
|
|
91
93
|
const mergedId = useId(id);
|
|
@@ -425,9 +427,11 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
425
427
|
listItemHeight,
|
|
426
428
|
childrenAsData,
|
|
427
429
|
maxCount,
|
|
428
|
-
optionRender
|
|
430
|
+
optionRender,
|
|
431
|
+
classNames,
|
|
432
|
+
styles
|
|
429
433
|
};
|
|
430
|
-
}, [maxCount, parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, popupMatchSelectWidth, direction, listHeight, listItemHeight, childrenAsData, optionRender]);
|
|
434
|
+
}, [maxCount, parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, popupMatchSelectWidth, direction, listHeight, listItemHeight, childrenAsData, optionRender, classNames, styles]);
|
|
431
435
|
|
|
432
436
|
// ========================== Warning ===========================
|
|
433
437
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -447,10 +451,15 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
447
451
|
ref: ref,
|
|
448
452
|
omitDomProps: OMIT_DOM_PROPS,
|
|
449
453
|
mode: mode
|
|
454
|
+
// >>> Style
|
|
455
|
+
,
|
|
456
|
+
classNames: classNames,
|
|
457
|
+
styles: styles
|
|
450
458
|
// >>> Values
|
|
451
459
|
,
|
|
452
460
|
displayValues: displayValues,
|
|
453
|
-
onDisplayValuesChange: onDisplayValuesChange
|
|
461
|
+
onDisplayValuesChange: onDisplayValuesChange,
|
|
462
|
+
maxCount: maxCount
|
|
454
463
|
// >>> Trigger
|
|
455
464
|
,
|
|
456
465
|
direction: direction
|
package/es/SelectContext.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { RawValueType, RenderNode } from './BaseSelect';
|
|
3
|
-
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps } from './Select';
|
|
3
|
+
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName } from './Select';
|
|
4
4
|
import type { FlattenOptionData } from './interface';
|
|
5
|
+
/**
|
|
6
|
+
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
7
|
+
*/
|
|
5
8
|
export interface SelectContextProps {
|
|
9
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
10
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
6
11
|
options: BaseOptionType[];
|
|
7
12
|
optionRender?: SelectProps['optionRender'];
|
|
8
13
|
flattenOptions: FlattenOptionData<BaseOptionType>[];
|
package/es/SelectContext.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
// Use any here since we do not get the type during compilation
|
|
4
|
+
/**
|
|
5
|
+
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
6
|
+
*/
|
|
4
7
|
|
|
5
8
|
const SelectContext = /*#__PURE__*/React.createContext(null);
|
|
6
9
|
export default SelectContext;
|
package/es/Selector/Input.js
CHANGED
|
@@ -2,6 +2,7 @@ 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 useBaseProps from "../hooks/useBaseProps";
|
|
5
6
|
const Input = (props, ref) => {
|
|
6
7
|
const {
|
|
7
8
|
prefixCls,
|
|
@@ -25,6 +26,10 @@ const Input = (props, ref) => {
|
|
|
25
26
|
open,
|
|
26
27
|
attrs
|
|
27
28
|
} = props;
|
|
29
|
+
const {
|
|
30
|
+
classNames: contextClassNames,
|
|
31
|
+
styles: contextStyles
|
|
32
|
+
} = useBaseProps() || {};
|
|
28
33
|
let inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
|
|
29
34
|
const {
|
|
30
35
|
ref: originRef,
|
|
@@ -50,7 +55,7 @@ const Input = (props, ref) => {
|
|
|
50
55
|
tabIndex,
|
|
51
56
|
autoComplete: autoComplete || 'off',
|
|
52
57
|
autoFocus,
|
|
53
|
-
className: classNames(`${prefixCls}-selection-search-input`, inputNode?.props?.className),
|
|
58
|
+
className: classNames(`${prefixCls}-selection-search-input`, inputNode?.props?.className, contextClassNames?.input),
|
|
54
59
|
role: 'combobox',
|
|
55
60
|
'aria-expanded': open || false,
|
|
56
61
|
'aria-haspopup': 'listbox',
|
|
@@ -65,7 +70,8 @@ const Input = (props, ref) => {
|
|
|
65
70
|
unselectable: !editable ? 'on' : null,
|
|
66
71
|
style: {
|
|
67
72
|
...style,
|
|
68
|
-
opacity: editable ? null : 0
|
|
73
|
+
opacity: editable ? null : 0,
|
|
74
|
+
...contextStyles?.input
|
|
69
75
|
},
|
|
70
76
|
onKeyDown: event => {
|
|
71
77
|
onKeyDown(event);
|
package/es/Selector/index.d.ts
CHANGED
package/es/Selector/index.js
CHANGED
|
@@ -16,10 +16,13 @@ import useLock from "../hooks/useLock";
|
|
|
16
16
|
import { isValidateOpenKey } from "../utils/keyUtil";
|
|
17
17
|
import MultipleSelector from "./MultipleSelector";
|
|
18
18
|
import SingleSelector from "./SingleSelector";
|
|
19
|
+
import classNames from 'classnames';
|
|
19
20
|
const Selector = (props, ref) => {
|
|
20
21
|
const inputRef = useRef(null);
|
|
21
22
|
const compositionStatusRef = useRef(false);
|
|
22
23
|
const {
|
|
24
|
+
prefixClassName,
|
|
25
|
+
prefixStyle,
|
|
23
26
|
prefixCls,
|
|
24
27
|
open,
|
|
25
28
|
mode,
|
|
@@ -174,7 +177,8 @@ const Selector = (props, ref) => {
|
|
|
174
177
|
onClick: onClick,
|
|
175
178
|
onMouseDown: onMouseDown
|
|
176
179
|
}, prefix && /*#__PURE__*/React.createElement("div", {
|
|
177
|
-
className: `${prefixCls}-prefix
|
|
180
|
+
className: classNames(`${prefixCls}-prefix`, prefixClassName),
|
|
181
|
+
style: prefixStyle
|
|
178
182
|
}, prefix), selectNode);
|
|
179
183
|
};
|
|
180
184
|
const ForwardSelector = /*#__PURE__*/React.forwardRef(Selector);
|
package/es/TransBtn.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { RenderNode } from './BaseSelect';
|
|
3
3
|
export interface TransBtnProps {
|
|
4
4
|
className: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
5
6
|
customizeIcon: RenderNode;
|
|
6
7
|
customizeIconProps?: any;
|
|
7
8
|
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>;
|
package/es/TransBtn.js
CHANGED
|
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
const TransBtn = props => {
|
|
4
4
|
const {
|
|
5
5
|
className,
|
|
6
|
+
style,
|
|
6
7
|
customizeIcon,
|
|
7
8
|
customizeIconProps,
|
|
8
9
|
children,
|
|
@@ -18,7 +19,8 @@ const TransBtn = props => {
|
|
|
18
19
|
},
|
|
19
20
|
style: {
|
|
20
21
|
userSelect: 'none',
|
|
21
|
-
WebkitUserSelect: 'none'
|
|
22
|
+
WebkitUserSelect: 'none',
|
|
23
|
+
...style
|
|
22
24
|
},
|
|
23
25
|
unselectable: "on",
|
|
24
26
|
onClick: onClick,
|
|
@@ -2,6 +2,7 @@ import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/int
|
|
|
2
2
|
import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
|
|
5
|
+
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input';
|
|
5
6
|
export type { DisplayInfoType, DisplayValueType, Mode, Placement, RenderDOMFunc, RenderNode, RawValueType, };
|
|
6
7
|
export interface RefOptionListProps {
|
|
7
8
|
onKeyDown: React.KeyboardEventHandler;
|
|
@@ -53,17 +54,20 @@ export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSele
|
|
|
53
54
|
export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
|
|
54
55
|
className?: string;
|
|
55
56
|
style?: React.CSSProperties;
|
|
56
|
-
|
|
57
|
+
classNames?: Partial<Record<BaseSelectSemanticName, string>>;
|
|
58
|
+
styles?: Partial<Record<BaseSelectSemanticName, React.CSSProperties>>;
|
|
57
59
|
showSearch?: boolean;
|
|
58
60
|
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
|
59
61
|
direction?: 'ltr' | 'rtl';
|
|
60
|
-
maxLength?: number;
|
|
61
|
-
showScrollBar?: boolean | 'optional';
|
|
62
|
-
tabIndex?: number;
|
|
63
62
|
autoFocus?: boolean;
|
|
64
|
-
notFoundContent?: React.ReactNode;
|
|
65
63
|
placeholder?: React.ReactNode;
|
|
64
|
+
maxCount?: number;
|
|
65
|
+
title?: string;
|
|
66
|
+
tabIndex?: number;
|
|
67
|
+
notFoundContent?: React.ReactNode;
|
|
66
68
|
onClear?: () => void;
|
|
69
|
+
maxLength?: number;
|
|
70
|
+
showScrollBar?: boolean | 'optional';
|
|
67
71
|
choiceTransitionName?: string;
|
|
68
72
|
mode?: Mode;
|
|
69
73
|
disabled?: boolean;
|
package/lib/BaseSelect/index.js
CHANGED
|
@@ -19,7 +19,6 @@ var _Selector = _interopRequireDefault(require("../Selector"));
|
|
|
19
19
|
var _SelectTrigger = _interopRequireDefault(require("../SelectTrigger"));
|
|
20
20
|
var _TransBtn = _interopRequireDefault(require("../TransBtn"));
|
|
21
21
|
var _valueUtil = require("../utils/valueUtil");
|
|
22
|
-
var _SelectContext = _interopRequireDefault(require("../SelectContext"));
|
|
23
22
|
var _Polite = _interopRequireDefault(require("./Polite"));
|
|
24
23
|
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); }
|
|
25
24
|
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; }
|
|
@@ -33,6 +32,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
33
32
|
id,
|
|
34
33
|
prefixCls,
|
|
35
34
|
className,
|
|
35
|
+
styles,
|
|
36
|
+
classNames,
|
|
36
37
|
showSearch,
|
|
37
38
|
tagRender,
|
|
38
39
|
showScrollBar = 'optional',
|
|
@@ -44,6 +45,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
44
45
|
emptyOptions,
|
|
45
46
|
notFoundContent = 'Not Found',
|
|
46
47
|
onClear,
|
|
48
|
+
maxCount,
|
|
47
49
|
// Mode
|
|
48
50
|
mode,
|
|
49
51
|
// Status
|
|
@@ -181,18 +183,14 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
181
183
|
|
|
182
184
|
// ============================= Search =============================
|
|
183
185
|
const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
|
|
184
|
-
const {
|
|
185
|
-
maxCount,
|
|
186
|
-
rawValues
|
|
187
|
-
} = React.useContext(_SelectContext.default) || {};
|
|
188
186
|
const onInternalSearch = (searchText, fromTyping, isCompositing) => {
|
|
189
|
-
if (multiple && (0, _valueUtil.isValidCount)(maxCount) &&
|
|
187
|
+
if (multiple && (0, _valueUtil.isValidCount)(maxCount) && displayValues.length >= maxCount) {
|
|
190
188
|
return;
|
|
191
189
|
}
|
|
192
190
|
let ret = true;
|
|
193
191
|
let newSearchText = searchText;
|
|
194
192
|
onActiveValueChange?.(null);
|
|
195
|
-
const separatedList = (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators, (0, _valueUtil.isValidCount)(maxCount) ? maxCount -
|
|
193
|
+
const separatedList = (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators, (0, _valueUtil.isValidCount)(maxCount) ? maxCount - displayValues.length : undefined);
|
|
196
194
|
|
|
197
195
|
// Check if match the `tokenSeparators`
|
|
198
196
|
const patchLabels = isCompositing ? null : separatedList;
|
|
@@ -434,8 +432,10 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
434
432
|
showSearch: mergedShowSearch,
|
|
435
433
|
multiple,
|
|
436
434
|
toggleOpen: onToggleOpen,
|
|
437
|
-
showScrollBar
|
|
438
|
-
|
|
435
|
+
showScrollBar,
|
|
436
|
+
styles,
|
|
437
|
+
classNames
|
|
438
|
+
}), [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen, showScrollBar, styles, classNames]);
|
|
439
439
|
|
|
440
440
|
// ==================================================================
|
|
441
441
|
// == Render ==
|
|
@@ -446,9 +446,10 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
446
446
|
let arrowNode;
|
|
447
447
|
if (showSuffixIcon) {
|
|
448
448
|
arrowNode = /*#__PURE__*/React.createElement(_TransBtn.default, {
|
|
449
|
-
className: (0, _classnames.default)(`${prefixCls}-arrow`, {
|
|
449
|
+
className: (0, _classnames.default)(`${prefixCls}-arrow`, classNames?.suffix, {
|
|
450
450
|
[`${prefixCls}-arrow-loading`]: loading
|
|
451
451
|
}),
|
|
452
|
+
style: styles?.suffix,
|
|
452
453
|
customizeIcon: suffixIcon,
|
|
453
454
|
customizeIconProps: {
|
|
454
455
|
loading,
|
|
@@ -523,6 +524,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
523
524
|
}, customizeRawInputElement ? ( /*#__PURE__*/React.cloneElement(customizeRawInputElement, {
|
|
524
525
|
ref: customizeRawInputRef
|
|
525
526
|
})) : /*#__PURE__*/React.createElement(_Selector.default, _extends({}, props, {
|
|
527
|
+
prefixClassName: classNames?.prefix,
|
|
528
|
+
prefixStyle: styles?.prefix,
|
|
526
529
|
domRef: selectorDomRef,
|
|
527
530
|
prefixCls: prefixCls,
|
|
528
531
|
inputElement: customizeInputElement,
|
package/lib/OptionList.js
CHANGED
|
@@ -57,7 +57,9 @@ const OptionList = (_, ref) => {
|
|
|
57
57
|
direction,
|
|
58
58
|
listHeight,
|
|
59
59
|
listItemHeight,
|
|
60
|
-
optionRender
|
|
60
|
+
optionRender,
|
|
61
|
+
classNames: contextClassNames,
|
|
62
|
+
styles: contextStyles
|
|
61
63
|
} = React.useContext(_SelectContext.default);
|
|
62
64
|
const itemPrefixCls = `${prefixCls}-item`;
|
|
63
65
|
const memoFlattenOptions = (0, _useMemo.default)(() => flattenOptions, [open, flattenOptions], (prev, next) => next[0] && prev[1] !== next[1]);
|
|
@@ -298,7 +300,9 @@ const OptionList = (_, ref) => {
|
|
|
298
300
|
virtual: virtual,
|
|
299
301
|
direction: direction,
|
|
300
302
|
innerProps: virtual ? null : a11yProps,
|
|
301
|
-
showScrollBar: showScrollBar
|
|
303
|
+
showScrollBar: showScrollBar,
|
|
304
|
+
className: contextClassNames?.list,
|
|
305
|
+
style: contextStyles?.list
|
|
302
306
|
}, (item, itemIndex) => {
|
|
303
307
|
const {
|
|
304
308
|
group,
|
|
@@ -333,7 +337,7 @@ const OptionList = (_, ref) => {
|
|
|
333
337
|
const selected = isSelected(value);
|
|
334
338
|
const mergedDisabled = disabled || !selected && overMaxCount;
|
|
335
339
|
const optionPrefixCls = `${itemPrefixCls}-option`;
|
|
336
|
-
const optionClassName = (0, _classnames.default)(itemPrefixCls, optionPrefixCls, className, {
|
|
340
|
+
const optionClassName = (0, _classnames.default)(itemPrefixCls, optionPrefixCls, className, contextClassNames?.listItem, {
|
|
337
341
|
[`${optionPrefixCls}-grouped`]: groupOption,
|
|
338
342
|
[`${optionPrefixCls}-active`]: activeIndex === itemIndex && !mergedDisabled,
|
|
339
343
|
[`${optionPrefixCls}-disabled`]: mergedDisabled,
|
|
@@ -364,7 +368,10 @@ const OptionList = (_, ref) => {
|
|
|
364
368
|
onSelectValue(value);
|
|
365
369
|
}
|
|
366
370
|
},
|
|
367
|
-
style:
|
|
371
|
+
style: {
|
|
372
|
+
...contextStyles?.listItem,
|
|
373
|
+
...style
|
|
374
|
+
}
|
|
368
375
|
}), /*#__PURE__*/React.createElement("div", {
|
|
369
376
|
className: `${optionPrefixCls}-content`
|
|
370
377
|
}, typeof optionRender === 'function' ? optionRender(item, {
|
package/lib/Select.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* - `combobox` mode not support `optionLabelProp`
|
|
30
30
|
*/
|
|
31
31
|
import * as React from 'react';
|
|
32
|
-
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, DisplayValueType, RenderNode } from './BaseSelect';
|
|
32
|
+
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, BaseSelectSemanticName, DisplayValueType, RenderNode } from './BaseSelect';
|
|
33
33
|
import OptGroup from './OptGroup';
|
|
34
34
|
import Option from './Option';
|
|
35
35
|
import type { FlattenOptionData } from './interface';
|
|
@@ -65,6 +65,7 @@ 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 | 'listItem' | 'list';
|
|
68
69
|
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
|
69
70
|
prefixCls?: string;
|
|
70
71
|
id?: string;
|
|
@@ -104,8 +105,10 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
104
105
|
defaultValue?: ValueType | null;
|
|
105
106
|
maxCount?: number;
|
|
106
107
|
onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
|
|
108
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
109
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
107
110
|
}
|
|
108
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
111
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
|
109
112
|
children?: React.ReactNode;
|
|
110
113
|
} & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
111
114
|
Option: typeof Option;
|
package/lib/Select.js
CHANGED
|
@@ -93,6 +93,8 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
93
93
|
labelInValue,
|
|
94
94
|
onChange,
|
|
95
95
|
maxCount,
|
|
96
|
+
classNames,
|
|
97
|
+
styles,
|
|
96
98
|
...restProps
|
|
97
99
|
} = props;
|
|
98
100
|
const mergedId = (0, _useId.default)(id);
|
|
@@ -432,9 +434,11 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
432
434
|
listItemHeight,
|
|
433
435
|
childrenAsData,
|
|
434
436
|
maxCount,
|
|
435
|
-
optionRender
|
|
437
|
+
optionRender,
|
|
438
|
+
classNames,
|
|
439
|
+
styles
|
|
436
440
|
};
|
|
437
|
-
}, [maxCount, parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, popupMatchSelectWidth, direction, listHeight, listItemHeight, childrenAsData, optionRender]);
|
|
441
|
+
}, [maxCount, parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, popupMatchSelectWidth, direction, listHeight, listItemHeight, childrenAsData, optionRender, classNames, styles]);
|
|
438
442
|
|
|
439
443
|
// ========================== Warning ===========================
|
|
440
444
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -454,10 +458,15 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
454
458
|
ref: ref,
|
|
455
459
|
omitDomProps: OMIT_DOM_PROPS,
|
|
456
460
|
mode: mode
|
|
461
|
+
// >>> Style
|
|
462
|
+
,
|
|
463
|
+
classNames: classNames,
|
|
464
|
+
styles: styles
|
|
457
465
|
// >>> Values
|
|
458
466
|
,
|
|
459
467
|
displayValues: displayValues,
|
|
460
|
-
onDisplayValuesChange: onDisplayValuesChange
|
|
468
|
+
onDisplayValuesChange: onDisplayValuesChange,
|
|
469
|
+
maxCount: maxCount
|
|
461
470
|
// >>> Trigger
|
|
462
471
|
,
|
|
463
472
|
direction: direction
|
package/lib/SelectContext.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { RawValueType, RenderNode } from './BaseSelect';
|
|
3
|
-
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps } from './Select';
|
|
3
|
+
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps, SemanticName } from './Select';
|
|
4
4
|
import type { FlattenOptionData } from './interface';
|
|
5
|
+
/**
|
|
6
|
+
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
7
|
+
*/
|
|
5
8
|
export interface SelectContextProps {
|
|
9
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
10
|
+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
6
11
|
options: BaseOptionType[];
|
|
7
12
|
optionRender?: SelectProps['optionRender'];
|
|
8
13
|
flattenOptions: FlattenOptionData<BaseOptionType>[];
|
package/lib/SelectContext.js
CHANGED
|
@@ -8,6 +8,9 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
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); }
|
|
9
9
|
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; }
|
|
10
10
|
// Use any here since we do not get the type during compilation
|
|
11
|
+
/**
|
|
12
|
+
* SelectContext is only used for Select. BaseSelect should not consume this context.
|
|
13
|
+
*/
|
|
11
14
|
|
|
12
15
|
const SelectContext = /*#__PURE__*/React.createContext(null);
|
|
13
16
|
var _default = exports.default = SelectContext;
|
package/lib/Selector/Input.js
CHANGED
|
@@ -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 _useBaseProps = _interopRequireDefault(require("../hooks/useBaseProps"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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
14
|
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; }
|
|
@@ -34,6 +35,10 @@ const Input = (props, ref) => {
|
|
|
34
35
|
open,
|
|
35
36
|
attrs
|
|
36
37
|
} = props;
|
|
38
|
+
const {
|
|
39
|
+
classNames: contextClassNames,
|
|
40
|
+
styles: contextStyles
|
|
41
|
+
} = (0, _useBaseProps.default)() || {};
|
|
37
42
|
let inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
|
|
38
43
|
const {
|
|
39
44
|
ref: originRef,
|
|
@@ -59,7 +64,7 @@ const Input = (props, ref) => {
|
|
|
59
64
|
tabIndex,
|
|
60
65
|
autoComplete: autoComplete || 'off',
|
|
61
66
|
autoFocus,
|
|
62
|
-
className: (0, _classnames.default)(`${prefixCls}-selection-search-input`, inputNode?.props?.className),
|
|
67
|
+
className: (0, _classnames.default)(`${prefixCls}-selection-search-input`, inputNode?.props?.className, contextClassNames?.input),
|
|
63
68
|
role: 'combobox',
|
|
64
69
|
'aria-expanded': open || false,
|
|
65
70
|
'aria-haspopup': 'listbox',
|
|
@@ -74,7 +79,8 @@ const Input = (props, ref) => {
|
|
|
74
79
|
unselectable: !editable ? 'on' : null,
|
|
75
80
|
style: {
|
|
76
81
|
...style,
|
|
77
|
-
opacity: editable ? null : 0
|
|
82
|
+
opacity: editable ? null : 0,
|
|
83
|
+
...contextStyles?.input
|
|
78
84
|
},
|
|
79
85
|
onKeyDown: event => {
|
|
80
86
|
onKeyDown(event);
|
package/lib/Selector/index.d.ts
CHANGED
package/lib/Selector/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var _useLock = _interopRequireDefault(require("../hooks/useLock"));
|
|
|
11
11
|
var _keyUtil = require("../utils/keyUtil");
|
|
12
12
|
var _MultipleSelector = _interopRequireDefault(require("./MultipleSelector"));
|
|
13
13
|
var _SingleSelector = _interopRequireDefault(require("./SingleSelector"));
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
15
|
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); }
|
|
15
16
|
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; }
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -27,6 +28,8 @@ const Selector = (props, ref) => {
|
|
|
27
28
|
const inputRef = (0, _react.useRef)(null);
|
|
28
29
|
const compositionStatusRef = (0, _react.useRef)(false);
|
|
29
30
|
const {
|
|
31
|
+
prefixClassName,
|
|
32
|
+
prefixStyle,
|
|
30
33
|
prefixCls,
|
|
31
34
|
open,
|
|
32
35
|
mode,
|
|
@@ -181,7 +184,8 @@ const Selector = (props, ref) => {
|
|
|
181
184
|
onClick: onClick,
|
|
182
185
|
onMouseDown: onMouseDown
|
|
183
186
|
}, prefix && /*#__PURE__*/React.createElement("div", {
|
|
184
|
-
className: `${prefixCls}-prefix
|
|
187
|
+
className: (0, _classnames.default)(`${prefixCls}-prefix`, prefixClassName),
|
|
188
|
+
style: prefixStyle
|
|
185
189
|
}, prefix), selectNode);
|
|
186
190
|
};
|
|
187
191
|
const ForwardSelector = /*#__PURE__*/React.forwardRef(Selector);
|
package/lib/TransBtn.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { RenderNode } from './BaseSelect';
|
|
3
3
|
export interface TransBtnProps {
|
|
4
4
|
className: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
5
6
|
customizeIcon: RenderNode;
|
|
6
7
|
customizeIconProps?: any;
|
|
7
8
|
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>;
|
package/lib/TransBtn.js
CHANGED
|
@@ -12,6 +12,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
12
12
|
const TransBtn = props => {
|
|
13
13
|
const {
|
|
14
14
|
className,
|
|
15
|
+
style,
|
|
15
16
|
customizeIcon,
|
|
16
17
|
customizeIconProps,
|
|
17
18
|
children,
|
|
@@ -27,7 +28,8 @@ const TransBtn = props => {
|
|
|
27
28
|
},
|
|
28
29
|
style: {
|
|
29
30
|
userSelect: 'none',
|
|
30
|
-
WebkitUserSelect: 'none'
|
|
31
|
+
WebkitUserSelect: 'none',
|
|
32
|
+
...style
|
|
31
33
|
},
|
|
32
34
|
unselectable: "on",
|
|
33
35
|
onClick: onClick,
|