@tdm-design/ui 0.0.15 → 0.0.17
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/dist/@tdm-design/ui.js +113060 -0
- package/dist/@tdm-design/ui.js.map +1 -0
- package/dist/@tdm-design/ui.min.js +373 -0
- package/dist/@tdm-design/ui.min.js.LICENSE.txt +129 -0
- package/dist/@tdm-design/ui.min.js.map +1 -0
- package/dist/reset.css +246 -0
- package/dist/tdm-with-locales.js +373 -0
- package/dist/tdm-with-locales.js.LICENSE.txt +129 -0
- package/dist/tdm-with-locales.js.map +1 -0
- package/dist/tdm.css +1 -0
- package/es/config-provider/context.d.ts +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +1 -1
- package/es/select/Select.d.ts +130 -0
- package/es/select/Select.js +333 -0
- package/es/select/SingleDisplaySelect.d.ts +5 -0
- package/es/select/SingleDisplaySelect.js +157 -0
- package/es/select/SortableSelect.d.ts +5 -0
- package/es/select/SortableSelect.js +173 -0
- package/es/select/index.d.ts +7 -124
- package/es/select/index.js +7 -274
- package/es/select/style/select-input-multiple.js +4 -1
- package/es/version/token.json +1 -1
- package/es/version/version.d.ts +1 -1
- package/es/version/version.js +1 -1
- package/lib/config-provider/context.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +14 -1
- package/lib/select/Select.d.ts +130 -0
- package/lib/select/Select.js +340 -0
- package/lib/select/SingleDisplaySelect.d.ts +5 -0
- package/lib/select/SingleDisplaySelect.js +164 -0
- package/lib/select/SortableSelect.d.ts +5 -0
- package/lib/select/SortableSelect.js +180 -0
- package/lib/select/index.d.ts +7 -124
- package/lib/select/index.js +32 -274
- package/lib/select/style/select-input-multiple.js +4 -1
- package/lib/version/token.json +1 -1
- package/lib/version/version.d.ts +1 -1
- package/lib/version/version.js +1 -1
- package/package.json +10 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import Select from './Select';
|
|
5
|
+
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
6
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, useSortable, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
|
7
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
8
|
+
import { ConfigContext } from '../config-provider';
|
|
9
|
+
function extractValueId(val) {
|
|
10
|
+
if (typeof val === 'object' && val !== null) {
|
|
11
|
+
if ('key' in val && val.key !== undefined) return val.key;
|
|
12
|
+
if ('value' in val && val.value !== undefined) return val.value;
|
|
13
|
+
}
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
import CloseOutlinedIcon from '@tdm-design/icons/CloseOutlinedIcon';
|
|
17
|
+
const DraggableTag = props => {
|
|
18
|
+
const {
|
|
19
|
+
value,
|
|
20
|
+
closable,
|
|
21
|
+
onClose,
|
|
22
|
+
label,
|
|
23
|
+
disabled,
|
|
24
|
+
prefixCls,
|
|
25
|
+
customTagRender
|
|
26
|
+
} = props;
|
|
27
|
+
const id = extractValueId(value);
|
|
28
|
+
const {
|
|
29
|
+
attributes,
|
|
30
|
+
listeners,
|
|
31
|
+
setNodeRef,
|
|
32
|
+
transform,
|
|
33
|
+
transition,
|
|
34
|
+
isDragging
|
|
35
|
+
} = useSortable({
|
|
36
|
+
id,
|
|
37
|
+
disabled: disabled || !id
|
|
38
|
+
});
|
|
39
|
+
const mergedStyle = {
|
|
40
|
+
transform: CSS.Transform.toString(transform),
|
|
41
|
+
transition,
|
|
42
|
+
opacity: isDragging ? 0.4 : undefined,
|
|
43
|
+
zIndex: isDragging ? 1 : undefined,
|
|
44
|
+
cursor: disabled || !id ? 'default' : 'move'
|
|
45
|
+
};
|
|
46
|
+
const onMouseDown = e => {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
};
|
|
50
|
+
if (customTagRender) {
|
|
51
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
ref: setNodeRef,
|
|
53
|
+
style: {
|
|
54
|
+
...mergedStyle,
|
|
55
|
+
display: 'inline-flex'
|
|
56
|
+
},
|
|
57
|
+
...attributes,
|
|
58
|
+
...listeners,
|
|
59
|
+
onMouseDown: onMouseDown
|
|
60
|
+
}, customTagRender(props));
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
63
|
+
ref: setNodeRef,
|
|
64
|
+
style: mergedStyle,
|
|
65
|
+
className: `${prefixCls}-selection-item${disabled ? ` ${prefixCls}-selection-item-disabled` : ''}`,
|
|
66
|
+
...attributes,
|
|
67
|
+
...listeners,
|
|
68
|
+
onMouseDown: onMouseDown
|
|
69
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
className: `${prefixCls}-selection-item-content`
|
|
71
|
+
}, label), closable && (/*#__PURE__*/React.createElement("span", {
|
|
72
|
+
className: `${prefixCls}-selection-item-remove`,
|
|
73
|
+
onClick: e => {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
onClose?.(e);
|
|
76
|
+
},
|
|
77
|
+
onMouseDown: e => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
}
|
|
81
|
+
}, /*#__PURE__*/React.createElement(CloseOutlinedIcon, null))));
|
|
82
|
+
};
|
|
83
|
+
const SortableSelect = props => {
|
|
84
|
+
const {
|
|
85
|
+
value,
|
|
86
|
+
defaultValue,
|
|
87
|
+
onChange,
|
|
88
|
+
disabled,
|
|
89
|
+
prefixCls: customizePrefixCls,
|
|
90
|
+
tagRender: customTagRender,
|
|
91
|
+
...restProps
|
|
92
|
+
} = props;
|
|
93
|
+
const {
|
|
94
|
+
getPrefixCls
|
|
95
|
+
} = React.useContext(ConfigContext);
|
|
96
|
+
const prefixCls = getPrefixCls('select', customizePrefixCls);
|
|
97
|
+
// Maintain internal state for uncontrolled usage
|
|
98
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
99
|
+
if (value !== undefined) return value;
|
|
100
|
+
if (defaultValue !== undefined) return defaultValue;
|
|
101
|
+
return [];
|
|
102
|
+
});
|
|
103
|
+
// Sync with controlled value
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (value !== undefined) {
|
|
106
|
+
setInternalValue(value);
|
|
107
|
+
}
|
|
108
|
+
}, [value]);
|
|
109
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
|
110
|
+
activationConstraint: {
|
|
111
|
+
distance: 5
|
|
112
|
+
}
|
|
113
|
+
}), useSensor(KeyboardSensor, {
|
|
114
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
115
|
+
}));
|
|
116
|
+
const handleDragEnd = useCallback(event => {
|
|
117
|
+
const {
|
|
118
|
+
active,
|
|
119
|
+
over
|
|
120
|
+
} = event;
|
|
121
|
+
if (!over || active.id === over.id) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
setInternalValue(prev => {
|
|
125
|
+
const prevArray = Array.isArray(prev) ? prev : [];
|
|
126
|
+
const oldIndex = prevArray.findIndex(item => extractValueId(item) === active.id);
|
|
127
|
+
const newIndex = prevArray.findIndex(item => extractValueId(item) === over.id);
|
|
128
|
+
if (oldIndex !== -1 && newIndex !== -1) {
|
|
129
|
+
const newArray = arrayMove(prevArray, oldIndex, newIndex);
|
|
130
|
+
// Only call onChange if the new array is actually different
|
|
131
|
+
onChange?.(newArray, []); // We skip options parameter for simplicity here
|
|
132
|
+
return newArray;
|
|
133
|
+
}
|
|
134
|
+
return prev;
|
|
135
|
+
});
|
|
136
|
+
}, [onChange]);
|
|
137
|
+
const handleChange = (val, opt) => {
|
|
138
|
+
if (value === undefined) {
|
|
139
|
+
setInternalValue(val);
|
|
140
|
+
}
|
|
141
|
+
onChange?.(val, opt);
|
|
142
|
+
};
|
|
143
|
+
const tagRender = useCallback(tagProps => {
|
|
144
|
+
return /*#__PURE__*/React.createElement(DraggableTag, {
|
|
145
|
+
...tagProps,
|
|
146
|
+
disabled: !!disabled,
|
|
147
|
+
prefixCls: prefixCls,
|
|
148
|
+
customTagRender: customTagRender
|
|
149
|
+
});
|
|
150
|
+
}, [disabled, prefixCls, customTagRender]);
|
|
151
|
+
// Extract sortable items
|
|
152
|
+
const items = Array.isArray(internalValue) ? internalValue.map(extractValueId) : [];
|
|
153
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
154
|
+
sensors: sensors,
|
|
155
|
+
collisionDetection: closestCenter,
|
|
156
|
+
onDragEnd: handleDragEnd
|
|
157
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
158
|
+
items: items,
|
|
159
|
+
strategy: horizontalListSortingStrategy
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
161
|
+
...restProps,
|
|
162
|
+
mode: restProps.mode || 'multiple',
|
|
163
|
+
value: internalValue,
|
|
164
|
+
onChange: handleChange,
|
|
165
|
+
disabled: disabled,
|
|
166
|
+
prefixCls: customizePrefixCls,
|
|
167
|
+
tagRender: tagRender,
|
|
168
|
+
// Force disable maxTagCount & maxLines so all tags are rendered
|
|
169
|
+
maxTagCount: undefined,
|
|
170
|
+
maxLines: undefined
|
|
171
|
+
})));
|
|
172
|
+
};
|
|
173
|
+
export default SortableSelect;
|
package/es/select/index.d.ts
CHANGED
|
@@ -1,125 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import type { InputStatus } from '../_util/statusUtils';
|
|
9
|
-
import type { Variant } from '../config-provider';
|
|
10
|
-
import type { SizeType } from '../config-provider/SizeContext';
|
|
11
|
-
type RawValue = string | number;
|
|
12
|
-
export type { BaseOptionType, DefaultOptionType, OptionProps, BaseSelectRef as RefSelectProps };
|
|
13
|
-
export interface LabeledValue {
|
|
14
|
-
key?: string;
|
|
15
|
-
value: RawValue;
|
|
16
|
-
label: React.ReactNode;
|
|
17
|
-
}
|
|
18
|
-
export type SelectValue = RawValue | RawValue[] | LabeledValue | LabeledValue[] | undefined;
|
|
19
|
-
export interface InternalSelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends Omit<RcSelectProps<ValueType, OptionType>, 'mode'> {
|
|
20
|
-
rootClassName?: string;
|
|
21
|
-
prefix?: React.ReactNode;
|
|
22
|
-
suffixIcon?: React.ReactNode;
|
|
23
|
-
size?: SizeType;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
mode?: 'multiple' | 'tags' | 'SECRET_COMBOBOX_MODE_DO_NOT_USE' | 'combobox';
|
|
26
|
-
/** @deprecated Use `variant` instead. */
|
|
27
|
-
bordered?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated `showArrow` is deprecated which will be removed in next major version. It will be a
|
|
30
|
-
* default behavior, you can hide it by setting `suffixIcon` to null.
|
|
31
|
-
*/
|
|
32
|
-
showArrow?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* @since 5.13.0
|
|
35
|
-
* @default "outlined"
|
|
36
|
-
*/
|
|
37
|
-
variant?: Variant;
|
|
38
|
-
classNames?: SelectSemanticClassNames & {
|
|
39
|
-
popup?: SelectPopupSemanticClassNames;
|
|
40
|
-
};
|
|
41
|
-
styles?: SelectSemanticStyles & {
|
|
42
|
-
popup?: SelectPopupSemanticStyles;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @description Whether the option is a filter item
|
|
46
|
-
* @default false
|
|
47
|
-
* @type boolean
|
|
48
|
-
* TDM_CUSTOM: custom select filter (BEGIN)
|
|
49
|
-
*/
|
|
50
|
-
isFilterItem?: boolean;
|
|
51
|
-
}
|
|
52
|
-
export type SelectSemanticName = keyof SelectSemanticClassNames & keyof SelectSemanticStyles;
|
|
53
|
-
export type SelectSemanticClassNames = {
|
|
54
|
-
root?: string;
|
|
55
|
-
prefix?: string;
|
|
56
|
-
suffix?: string;
|
|
57
|
-
input?: string;
|
|
58
|
-
placeholder?: string;
|
|
59
|
-
content?: string;
|
|
60
|
-
item?: string;
|
|
61
|
-
itemContent?: string;
|
|
62
|
-
itemRemove?: string;
|
|
63
|
-
clear?: string;
|
|
64
|
-
};
|
|
65
|
-
export type SelectSemanticStyles = {
|
|
66
|
-
root?: React.CSSProperties;
|
|
67
|
-
prefix?: React.CSSProperties;
|
|
68
|
-
suffix?: React.CSSProperties;
|
|
69
|
-
input?: React.CSSProperties;
|
|
70
|
-
placeholder?: React.CSSProperties;
|
|
71
|
-
content?: React.CSSProperties;
|
|
72
|
-
item?: React.CSSProperties;
|
|
73
|
-
itemContent?: React.CSSProperties;
|
|
74
|
-
itemRemove?: React.CSSProperties;
|
|
75
|
-
clear?: React.CSSProperties;
|
|
76
|
-
};
|
|
77
|
-
export type SelectPopupSemanticName = keyof SelectPopupSemanticClassNames & keyof SelectPopupSemanticStyles;
|
|
78
|
-
export type SelectPopupSemanticClassNames = {
|
|
79
|
-
root?: string;
|
|
80
|
-
listItem?: string;
|
|
81
|
-
list?: string;
|
|
82
|
-
};
|
|
83
|
-
export type SelectPopupSemanticStyles = {
|
|
84
|
-
root?: React.CSSProperties;
|
|
85
|
-
listItem?: React.CSSProperties;
|
|
86
|
-
list?: React.CSSProperties;
|
|
87
|
-
};
|
|
88
|
-
export type SelectClassNamesType = SemanticClassNamesType<SelectProps, SelectSemanticClassNames, {
|
|
89
|
-
popup?: SelectPopupSemanticClassNames;
|
|
90
|
-
}>;
|
|
91
|
-
export type SelectStylesType = SemanticStylesType<SelectProps, SelectSemanticStyles, {
|
|
92
|
-
popup?: SelectPopupSemanticStyles;
|
|
93
|
-
}>;
|
|
94
|
-
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends Omit<InternalSelectProps<ValueType, OptionType>, 'mode' | 'getInputElement' | 'getRawInputElement' | 'backfill' | 'placement' | 'dropdownClassName' | 'dropdownStyle'> {
|
|
95
|
-
placement?: SelectCommonPlacement;
|
|
96
|
-
mode?: 'multiple' | 'tags';
|
|
97
|
-
status?: InputStatus;
|
|
98
|
-
/** @deprecated Please use `classNames.popup.root` instead */
|
|
99
|
-
popupClassName?: string;
|
|
100
|
-
/** @deprecated Please use `classNames.popup.root` instead */
|
|
101
|
-
dropdownClassName?: string;
|
|
102
|
-
/** @deprecated Please use `styles.popup` instead */
|
|
103
|
-
dropdownStyle?: React.CSSProperties;
|
|
104
|
-
/** @deprecated Please use `popupRender` instead */
|
|
105
|
-
dropdownRender?: SelectProps['popupRender'];
|
|
106
|
-
/** @deprecated Please use `onOpenChange` instead */
|
|
107
|
-
onDropdownVisibleChange?: SelectProps['onPopupVisibleChange'];
|
|
108
|
-
/** @deprecated Please use `popupMatchSelectWidth` instead */
|
|
109
|
-
dropdownMatchSelectWidth?: boolean | number;
|
|
110
|
-
popupMatchSelectWidth?: boolean | number;
|
|
111
|
-
styles?: SelectStylesType;
|
|
112
|
-
classNames?: SelectClassNamesType;
|
|
113
|
-
onOpenChange?: (visible: boolean) => void;
|
|
114
|
-
}
|
|
115
|
-
declare const Select: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
116
|
-
displayName?: string;
|
|
117
|
-
SECRET_COMBOBOX_MODE_DO_NOT_USE: string;
|
|
118
|
-
/** @deprecated Please use `options` instead. */
|
|
119
|
-
Option: typeof Option;
|
|
120
|
-
/** @deprecated Please use `options` instead. */
|
|
121
|
-
OptGroup: typeof OptGroup;
|
|
122
|
-
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
|
|
123
|
-
};
|
|
124
|
-
declare const PurePanel: (props: import("../_util/type").AnyObject) => React.JSX.Element;
|
|
1
|
+
import Select from './Select';
|
|
2
|
+
import SortableSelect from './SortableSelect';
|
|
3
|
+
import SingleDisplaySelect from './SingleDisplaySelect';
|
|
4
|
+
export type { SortableSelectProps } from './SortableSelect';
|
|
5
|
+
export type { SingleDisplaySelectProps } from './SingleDisplaySelect';
|
|
6
|
+
export * from './Select';
|
|
7
|
+
export { SortableSelect, SingleDisplaySelect };
|
|
125
8
|
export default Select;
|
package/es/select/index.js
CHANGED
|
@@ -1,277 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import genPurePanel from '../_util/PurePanel';
|
|
11
|
-
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
|
|
12
|
-
import { devUseWarning } from '../_util/warning';
|
|
13
|
-
import { ConfigContext } from '../config-provider';
|
|
14
|
-
import { useComponentConfig } from '../config-provider/context';
|
|
15
|
-
import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
|
|
16
|
-
import DisabledContext from '../config-provider/DisabledContext';
|
|
17
|
-
import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
|
|
18
|
-
import useSize from '../config-provider/hooks/useSize';
|
|
19
|
-
import { FormItemInputContext } from '../form/context';
|
|
20
|
-
import useVariants from '../form/hooks/useVariants';
|
|
21
|
-
import { useCompactItemContext } from '../space/Compact';
|
|
22
|
-
import { useToken } from '../theme/internal';
|
|
23
|
-
import mergedBuiltinPlacements from './mergedBuiltinPlacements';
|
|
24
|
-
import useStyle from './style';
|
|
25
|
-
import useIcons from './useIcons';
|
|
26
|
-
import usePopupRender from './usePopupRender';
|
|
27
|
-
import useShowArrow from './useShowArrow';
|
|
28
|
-
const SECRET_COMBOBOX_MODE_DO_NOT_USE = 'SECRET_COMBOBOX_MODE_DO_NOT_USE';
|
|
29
|
-
const InternalSelect = (props, ref) => {
|
|
30
|
-
const {
|
|
31
|
-
prefixCls: customizePrefixCls,
|
|
32
|
-
bordered,
|
|
33
|
-
className,
|
|
34
|
-
rootClassName,
|
|
35
|
-
getPopupContainer,
|
|
36
|
-
popupClassName,
|
|
37
|
-
dropdownClassName,
|
|
38
|
-
listHeight = 256,
|
|
39
|
-
placement,
|
|
40
|
-
listItemHeight: customListItemHeight,
|
|
41
|
-
size: customizeSize,
|
|
42
|
-
disabled: customDisabled,
|
|
43
|
-
notFoundContent,
|
|
44
|
-
status: customStatus,
|
|
45
|
-
builtinPlacements,
|
|
46
|
-
dropdownMatchSelectWidth,
|
|
47
|
-
popupMatchSelectWidth,
|
|
48
|
-
direction: propDirection,
|
|
49
|
-
style,
|
|
50
|
-
allowClear,
|
|
51
|
-
variant: customizeVariant,
|
|
52
|
-
popupStyle,
|
|
53
|
-
dropdownStyle,
|
|
54
|
-
transitionName,
|
|
55
|
-
tagRender,
|
|
56
|
-
maxCount,
|
|
57
|
-
prefix,
|
|
58
|
-
dropdownRender,
|
|
59
|
-
/**
|
|
60
|
-
* @since 5.25.0
|
|
61
|
-
*/
|
|
62
|
-
popupRender,
|
|
63
|
-
onDropdownVisibleChange,
|
|
64
|
-
onOpenChange,
|
|
65
|
-
styles,
|
|
66
|
-
classNames,
|
|
67
|
-
isFilterItem,
|
|
68
|
-
// TDM_CUSTOM: custom select filter
|
|
69
|
-
optionFilterProp,
|
|
70
|
-
...rest
|
|
71
|
-
} = props;
|
|
72
|
-
const {
|
|
73
|
-
getPopupContainer: getContextPopupContainer,
|
|
74
|
-
getPrefixCls,
|
|
75
|
-
renderEmpty,
|
|
76
|
-
direction: contextDirection,
|
|
77
|
-
virtual,
|
|
78
|
-
popupMatchSelectWidth: contextPopupMatchSelectWidth,
|
|
79
|
-
popupOverflow
|
|
80
|
-
} = React.useContext(ConfigContext);
|
|
81
|
-
const {
|
|
82
|
-
showSearch,
|
|
83
|
-
optionFilterProp: contextOptionFilterProp,
|
|
84
|
-
style: contextStyle,
|
|
85
|
-
styles: contextStyles,
|
|
86
|
-
className: contextClassName,
|
|
87
|
-
classNames: contextClassNames
|
|
88
|
-
} = useComponentConfig('select');
|
|
89
|
-
const [, token] = useToken();
|
|
90
|
-
const listItemHeight = customListItemHeight ?? token?.controlHeight;
|
|
91
|
-
const prefixCls = getPrefixCls('select', customizePrefixCls);
|
|
92
|
-
const rootPrefixCls = getPrefixCls();
|
|
93
|
-
const direction = propDirection ?? contextDirection;
|
|
94
|
-
const {
|
|
95
|
-
compactSize,
|
|
96
|
-
compactItemClassnames
|
|
97
|
-
} = useCompactItemContext(prefixCls, direction);
|
|
98
|
-
const [variant, enableVariantCls] = useVariants('select', customizeVariant, bordered);
|
|
99
|
-
const rootCls = useCSSVarCls(prefixCls);
|
|
100
|
-
const [hashId, cssVarCls] = useStyle(prefixCls, rootCls);
|
|
101
|
-
const mode = React.useMemo(() => {
|
|
102
|
-
const {
|
|
103
|
-
mode: m
|
|
104
|
-
} = props;
|
|
105
|
-
if (m === 'combobox') {
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
if (m === SECRET_COMBOBOX_MODE_DO_NOT_USE) {
|
|
109
|
-
return 'combobox';
|
|
110
|
-
}
|
|
111
|
-
return m;
|
|
112
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
-
}, [props.mode]);
|
|
114
|
-
const isMultiple = mode === 'multiple' || mode === 'tags';
|
|
115
|
-
const showSuffixIcon = useShowArrow(props.suffixIcon, props.showArrow);
|
|
116
|
-
const mergedPopupMatchSelectWidth = popupMatchSelectWidth ?? dropdownMatchSelectWidth ?? contextPopupMatchSelectWidth;
|
|
117
|
-
const mergedPopupRender = usePopupRender(popupRender || dropdownRender);
|
|
118
|
-
const mergedOnOpenChange = onOpenChange || onDropdownVisibleChange;
|
|
119
|
-
// ===================== Form Status =====================
|
|
120
|
-
const {
|
|
121
|
-
status: contextStatus,
|
|
122
|
-
hasFeedback,
|
|
123
|
-
isFormItemInput,
|
|
124
|
-
feedbackIcon
|
|
125
|
-
} = React.useContext(FormItemInputContext);
|
|
126
|
-
const mergedStatus = getMergedStatus(contextStatus, customStatus);
|
|
127
|
-
// ===================== Empty =====================
|
|
128
|
-
let mergedNotFound;
|
|
129
|
-
if (notFoundContent !== undefined) {
|
|
130
|
-
mergedNotFound = notFoundContent;
|
|
131
|
-
} else if (mode === 'combobox') {
|
|
132
|
-
mergedNotFound = null;
|
|
133
|
-
} else {
|
|
134
|
-
mergedNotFound = renderEmpty?.('Select') || /*#__PURE__*/React.createElement(DefaultRenderEmpty, {
|
|
135
|
-
componentName: "Select"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
// ===================== Icons =====================
|
|
139
|
-
const {
|
|
140
|
-
suffixIcon,
|
|
141
|
-
itemIcon,
|
|
142
|
-
removeIcon,
|
|
143
|
-
clearIcon
|
|
144
|
-
} = useIcons({
|
|
145
|
-
...rest,
|
|
146
|
-
multiple: isMultiple,
|
|
147
|
-
hasFeedback,
|
|
148
|
-
feedbackIcon,
|
|
149
|
-
showSuffixIcon,
|
|
150
|
-
prefixCls,
|
|
151
|
-
componentName: 'Select'
|
|
152
|
-
});
|
|
153
|
-
const mergedAllowClear = allowClear === true ? {
|
|
154
|
-
clearIcon
|
|
155
|
-
} : allowClear;
|
|
156
|
-
const selectProps = omit(rest, ['suffixIcon', 'itemIcon']);
|
|
157
|
-
const mergedSize = useSize(ctx => customizeSize ?? compactSize ?? ctx);
|
|
158
|
-
// ===================== Disabled =====================
|
|
159
|
-
const disabled = React.useContext(DisabledContext);
|
|
160
|
-
const mergedDisabled = customDisabled ?? disabled;
|
|
161
|
-
// ========== Merged Props for Semantic ==================
|
|
162
|
-
const mergedProps = {
|
|
163
|
-
...props,
|
|
164
|
-
variant,
|
|
165
|
-
status: mergedStatus,
|
|
166
|
-
disabled: mergedDisabled,
|
|
167
|
-
size: mergedSize
|
|
168
|
-
};
|
|
169
|
-
const [mergedClassNames, mergedStyles] = useMergeSemantic([contextClassNames, classNames], [contextStyles, styles], {
|
|
170
|
-
props: mergedProps
|
|
171
|
-
}, {
|
|
172
|
-
popup: {
|
|
173
|
-
_default: 'root'
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
const mergedPopupClassName = clsx(mergedClassNames.popup?.root, popupClassName, dropdownClassName, {
|
|
177
|
-
[`${prefixCls}-dropdown-${direction}`]: direction === 'rtl'
|
|
178
|
-
}, rootClassName, cssVarCls, rootCls, hashId);
|
|
179
|
-
const mergedPopupStyle = {
|
|
180
|
-
...mergedStyles.popup?.root,
|
|
181
|
-
...(popupStyle ?? dropdownStyle)
|
|
182
|
-
};
|
|
183
|
-
const mergedClassName = clsx({
|
|
184
|
-
[`${prefixCls}-lg`]: mergedSize === 'large',
|
|
185
|
-
[`${prefixCls}-sm`]: mergedSize === 'small',
|
|
186
|
-
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
187
|
-
[`${prefixCls}-${variant}`]: enableVariantCls,
|
|
188
|
-
[`${prefixCls}-in-form-item`]: isFormItemInput,
|
|
189
|
-
// TDM_CUSTOM: custom select filter
|
|
190
|
-
[`${prefixCls}-filter`]: isFilterItem
|
|
191
|
-
}, getStatusClassNames(prefixCls, mergedStatus, hasFeedback), compactItemClassnames, contextClassName, className, mergedClassNames.root, rootClassName, cssVarCls, rootCls, hashId);
|
|
192
|
-
// ===================== Placement =====================
|
|
193
|
-
const memoPlacement = React.useMemo(() => {
|
|
194
|
-
if (placement !== undefined) {
|
|
195
|
-
return placement;
|
|
196
|
-
}
|
|
197
|
-
return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
|
|
198
|
-
}, [placement, direction]);
|
|
199
|
-
// ====================== Warning ======================
|
|
200
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
201
|
-
const warning = devUseWarning('Select');
|
|
202
|
-
const deprecatedProps = {
|
|
203
|
-
dropdownMatchSelectWidth: 'popupMatchSelectWidth',
|
|
204
|
-
dropdownStyle: 'styles.popup.root',
|
|
205
|
-
dropdownClassName: 'classNames.popup.root',
|
|
206
|
-
popupClassName: 'classNames.popup.root',
|
|
207
|
-
dropdownRender: 'popupRender',
|
|
208
|
-
onDropdownVisibleChange: 'onOpenChange',
|
|
209
|
-
bordered: 'variant'
|
|
210
|
-
};
|
|
211
|
-
Object.entries(deprecatedProps).forEach(([oldProp, newProp]) => {
|
|
212
|
-
warning.deprecated(!(oldProp in props), oldProp, newProp);
|
|
213
|
-
});
|
|
214
|
-
process.env.NODE_ENV !== "production" ? warning(!('showArrow' in props), 'deprecated', '`showArrow` is deprecated which will be removed in next major version. It will be a default behavior, you can hide it by setting `suffixIcon` to null.') : void 0;
|
|
215
|
-
process.env.NODE_ENV !== "production" ? warning(!(typeof maxCount !== 'undefined' && !isMultiple), 'usage', '`maxCount` only works with mode `multiple` or `tags`') : void 0;
|
|
216
|
-
}
|
|
217
|
-
// ====================== zIndex =========================
|
|
218
|
-
const [zIndex] = useZIndex('SelectLike', mergedStyles.popup?.root?.zIndex ?? mergedPopupStyle?.zIndex);
|
|
219
|
-
// ====================== Render =======================
|
|
220
|
-
return /*#__PURE__*/React.createElement(RcSelect, {
|
|
221
|
-
ref: ref,
|
|
222
|
-
virtual: virtual,
|
|
223
|
-
classNames: mergedClassNames,
|
|
224
|
-
styles: mergedStyles,
|
|
225
|
-
showSearch: showSearch,
|
|
226
|
-
optionFilterProp: optionFilterProp ?? contextOptionFilterProp ?? 'label',
|
|
227
|
-
...selectProps,
|
|
228
|
-
style: {
|
|
229
|
-
...mergedStyles.root,
|
|
230
|
-
...contextStyle,
|
|
231
|
-
...style
|
|
232
|
-
},
|
|
233
|
-
popupMatchSelectWidth: mergedPopupMatchSelectWidth,
|
|
234
|
-
transitionName: getTransitionName(rootPrefixCls, 'slide-up', transitionName),
|
|
235
|
-
builtinPlacements: mergedBuiltinPlacements(builtinPlacements, popupOverflow),
|
|
236
|
-
listHeight: listHeight,
|
|
237
|
-
listItemHeight: listItemHeight,
|
|
238
|
-
mode: mode,
|
|
239
|
-
prefixCls: prefixCls,
|
|
240
|
-
placement: memoPlacement,
|
|
241
|
-
direction: direction,
|
|
242
|
-
prefix: prefix,
|
|
243
|
-
suffixIcon: suffixIcon,
|
|
244
|
-
menuItemSelectedIcon: itemIcon,
|
|
245
|
-
removeIcon: removeIcon,
|
|
246
|
-
allowClear: mergedAllowClear,
|
|
247
|
-
notFoundContent: mergedNotFound,
|
|
248
|
-
className: mergedClassName,
|
|
249
|
-
getPopupContainer: getPopupContainer || getContextPopupContainer,
|
|
250
|
-
popupClassName: mergedPopupClassName,
|
|
251
|
-
disabled: mergedDisabled,
|
|
252
|
-
popupStyle: {
|
|
253
|
-
...mergedStyles.popup?.root,
|
|
254
|
-
...mergedPopupStyle,
|
|
255
|
-
zIndex
|
|
256
|
-
},
|
|
257
|
-
maxCount: isMultiple ? maxCount : undefined,
|
|
258
|
-
tagRender: isMultiple ? tagRender : undefined,
|
|
259
|
-
popupRender: mergedPopupRender,
|
|
260
|
-
onPopupVisibleChange: mergedOnOpenChange
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
264
|
-
InternalSelect.displayName = 'Select';
|
|
265
|
-
}
|
|
266
|
-
const Select = /*#__PURE__*/React.forwardRef(InternalSelect);
|
|
267
|
-
// We don't care debug panel
|
|
268
|
-
/* istanbul ignore next */
|
|
269
|
-
const PurePanel = genPurePanel(Select, 'popupAlign');
|
|
270
|
-
Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = SECRET_COMBOBOX_MODE_DO_NOT_USE;
|
|
271
|
-
Select.Option = Option;
|
|
272
|
-
Select.OptGroup = OptGroup;
|
|
273
|
-
Select._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
|
274
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
275
|
-
Select.displayName = 'Select';
|
|
276
|
-
}
|
|
3
|
+
import Select from './Select';
|
|
4
|
+
import SortableSelect from './SortableSelect';
|
|
5
|
+
import SingleDisplaySelect from './SingleDisplaySelect';
|
|
6
|
+
export * from './Select';
|
|
7
|
+
export { SortableSelect, SingleDisplaySelect };
|
|
8
|
+
Select.SortableSelect = SortableSelect;
|
|
9
|
+
Select.SingleDisplaySelect = SingleDisplaySelect;
|
|
277
10
|
export default Select;
|
|
@@ -63,7 +63,10 @@ const genSelectInputMultipleStyle = token => {
|
|
|
63
63
|
},
|
|
64
64
|
'&-item': {
|
|
65
65
|
lineHeight: 1,
|
|
66
|
-
maxWidth: `calc(
|
|
66
|
+
maxWidth: `calc(50% - ${FIXED_INPUT_MIN_WIDTH}px)`
|
|
67
|
+
},
|
|
68
|
+
'&-item-suffix': {
|
|
69
|
+
maxWidth: '100%'
|
|
67
70
|
},
|
|
68
71
|
[`${componentCls}-content-item-prefix + ${componentCls}-content-item-suffix,
|
|
69
72
|
${componentCls}-content-item-suffix:first-child`]: {
|