@tdm-design/ui 0.0.14 → 0.0.16
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 +113056 -0
- package/dist/@tdm-design/ui.js.map +1 -0
- package/dist/@tdm-design/ui.min.js +369 -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 +369 -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/drawer/style/index.js +5 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +1 -1
- package/es/modal/style/confirm.js +6 -2
- package/es/modal/style/index.js +7 -2
- 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 +153 -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/drawer/style/index.js +5 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +14 -1
- package/lib/modal/style/confirm.js +6 -2
- package/lib/modal/style/index.js +7 -2
- 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 +160 -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 +11 -4
package/lib/index.js
CHANGED
|
@@ -208,6 +208,12 @@ Object.defineProperty(exports, "Select", {
|
|
|
208
208
|
return _select.default;
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
+
Object.defineProperty(exports, "SingleDisplaySelect", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function () {
|
|
214
|
+
return _select.SingleDisplaySelect;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
211
217
|
Object.defineProperty(exports, "Skeleton", {
|
|
212
218
|
enumerable: true,
|
|
213
219
|
get: function () {
|
|
@@ -220,6 +226,12 @@ Object.defineProperty(exports, "Slider", {
|
|
|
220
226
|
return _slider.default;
|
|
221
227
|
}
|
|
222
228
|
});
|
|
229
|
+
Object.defineProperty(exports, "SortableSelect", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function () {
|
|
232
|
+
return _select.SortableSelect;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
223
235
|
Object.defineProperty(exports, "Space", {
|
|
224
236
|
enumerable: true,
|
|
225
237
|
get: function () {
|
|
@@ -359,7 +371,7 @@ var _radio = _interopRequireDefault(require("./radio"));
|
|
|
359
371
|
var _result = _interopRequireDefault(require("./result"));
|
|
360
372
|
var _row = _interopRequireDefault(require("./row"));
|
|
361
373
|
var _segmented = _interopRequireDefault(require("./segmented"));
|
|
362
|
-
var _select =
|
|
374
|
+
var _select = _interopRequireWildcard(require("./select"));
|
|
363
375
|
var _skeleton = _interopRequireDefault(require("./skeleton"));
|
|
364
376
|
var _slider = _interopRequireDefault(require("./slider"));
|
|
365
377
|
var _space = _interopRequireDefault(require("./space"));
|
|
@@ -377,6 +389,7 @@ var _upload = _interopRequireDefault(require("./upload"));
|
|
|
377
389
|
var _version = _interopRequireDefault(require("./version"));
|
|
378
390
|
var _watermark = _interopRequireDefault(require("./watermark"));
|
|
379
391
|
var _styled = _interopRequireDefault(require("./config-provider/styled"));
|
|
392
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
380
393
|
// export { default as Alert } from './alert'; // TODO: Uncomment when alert implementation is completed
|
|
381
394
|
// export type { AlertProps, ErrorBoundaryProps } from './alert'; // TODO: Uncomment when anchor implementation is completed
|
|
382
395
|
|
|
@@ -61,7 +61,8 @@ const genModalConfirmStyle = token => {
|
|
|
61
61
|
display: 'flex',
|
|
62
62
|
flexDirection: 'column',
|
|
63
63
|
flex: 'auto',
|
|
64
|
-
gap: token.marginXXS
|
|
64
|
+
gap: token.marginXXS,
|
|
65
|
+
minWidth: 0
|
|
65
66
|
},
|
|
66
67
|
[`${confirmComponentCls}-body-no-icon ${confirmComponentCls}-paragraph`]: {
|
|
67
68
|
maxWidth: '100%'
|
|
@@ -70,7 +71,10 @@ const genModalConfirmStyle = token => {
|
|
|
70
71
|
color: token.colorTextStrong,
|
|
71
72
|
fontWeight: token.fontWeightStrong,
|
|
72
73
|
fontSize: fontSizeTextLG,
|
|
73
|
-
lineHeight: lineHeightTextLG
|
|
74
|
+
lineHeight: lineHeightTextLG,
|
|
75
|
+
whiteSpace: 'nowrap',
|
|
76
|
+
overflow: 'hidden',
|
|
77
|
+
textOverflow: 'ellipsis'
|
|
74
78
|
},
|
|
75
79
|
[`${confirmComponentCls}-container`]: {
|
|
76
80
|
color: token.colorText,
|
package/lib/modal/style/index.js
CHANGED
|
@@ -127,7 +127,10 @@ const genModalStyle = token => {
|
|
|
127
127
|
fontWeight: token.fontWeightStrong,
|
|
128
128
|
fontSize: token.titleFontSize,
|
|
129
129
|
lineHeight: token.titleLineHeight,
|
|
130
|
-
wordWrap: 'break-word'
|
|
130
|
+
wordWrap: 'break-word',
|
|
131
|
+
whiteSpace: 'nowrap',
|
|
132
|
+
overflow: 'hidden',
|
|
133
|
+
textOverflow: 'ellipsis'
|
|
131
134
|
},
|
|
132
135
|
[`${componentCls}-container`]: {
|
|
133
136
|
position: 'relative',
|
|
@@ -186,9 +189,11 @@ const genModalStyle = token => {
|
|
|
186
189
|
background: token.headerBg,
|
|
187
190
|
borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`,
|
|
188
191
|
padding: token.headerPadding,
|
|
192
|
+
paddingInlineEnd: token.calc(token.modalHeaderHeight).equal(),
|
|
189
193
|
borderBottom: token.headerBorderBottom,
|
|
190
194
|
// boxShadow: token.boxShadowMD,
|
|
191
|
-
flex: '0 0 auto'
|
|
195
|
+
flex: '0 0 auto',
|
|
196
|
+
overflow: 'hidden'
|
|
192
197
|
},
|
|
193
198
|
[`${componentCls}-body`]: {
|
|
194
199
|
fontSize: token.fontSize,
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { BaseSelectRef, SelectProps as RcSelectProps } from '@rc-component/select';
|
|
3
|
+
import { OptGroup, Option } from '@rc-component/select';
|
|
4
|
+
import type { OptionProps } from '@rc-component/select/lib/Option';
|
|
5
|
+
import type { BaseOptionType, DefaultOptionType } from '@rc-component/select/lib/Select';
|
|
6
|
+
import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks';
|
|
7
|
+
import type { SelectCommonPlacement } from '../_util/motion';
|
|
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
|
+
/**
|
|
99
|
+
* @description Maximum number of lines to display tags before collapsing into `+N`
|
|
100
|
+
* @type number
|
|
101
|
+
*/
|
|
102
|
+
maxLines?: number;
|
|
103
|
+
/** @deprecated Please use `classNames.popup.root` instead */
|
|
104
|
+
popupClassName?: string;
|
|
105
|
+
/** @deprecated Please use `classNames.popup.root` instead */
|
|
106
|
+
dropdownClassName?: string;
|
|
107
|
+
/** @deprecated Please use `styles.popup` instead */
|
|
108
|
+
dropdownStyle?: React.CSSProperties;
|
|
109
|
+
/** @deprecated Please use `popupRender` instead */
|
|
110
|
+
dropdownRender?: SelectProps['popupRender'];
|
|
111
|
+
/** @deprecated Please use `onOpenChange` instead */
|
|
112
|
+
onDropdownVisibleChange?: SelectProps['onPopupVisibleChange'];
|
|
113
|
+
/** @deprecated Please use `popupMatchSelectWidth` instead */
|
|
114
|
+
dropdownMatchSelectWidth?: boolean | number;
|
|
115
|
+
popupMatchSelectWidth?: boolean | number;
|
|
116
|
+
styles?: SelectStylesType;
|
|
117
|
+
classNames?: SelectClassNamesType;
|
|
118
|
+
onOpenChange?: (visible: boolean) => void;
|
|
119
|
+
}
|
|
120
|
+
declare const Select: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
121
|
+
displayName?: string;
|
|
122
|
+
SECRET_COMBOBOX_MODE_DO_NOT_USE: string;
|
|
123
|
+
/** @deprecated Please use `options` instead. */
|
|
124
|
+
Option: typeof Option;
|
|
125
|
+
/** @deprecated Please use `options` instead. */
|
|
126
|
+
OptGroup: typeof OptGroup;
|
|
127
|
+
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
|
|
128
|
+
};
|
|
129
|
+
declare const PurePanel: (props: import("../_util/type").AnyObject) => React.JSX.Element;
|
|
130
|
+
export default Select;
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// TODO: 4.0 - codemod should help to change `filterOption` to support node props.
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.default = void 0;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _select = _interopRequireWildcard(require("@rc-component/select"));
|
|
12
|
+
var _util = require("@rc-component/util");
|
|
13
|
+
var _clsx = require("clsx");
|
|
14
|
+
var _hooks = require("../_util/hooks");
|
|
15
|
+
var _motion = require("../_util/motion");
|
|
16
|
+
var _PurePanel = _interopRequireDefault(require("../_util/PurePanel"));
|
|
17
|
+
var _statusUtils = require("../_util/statusUtils");
|
|
18
|
+
var _warning = require("../_util/warning");
|
|
19
|
+
var _configProvider = require("../config-provider");
|
|
20
|
+
var _context = require("../config-provider/context");
|
|
21
|
+
var _defaultRenderEmpty = _interopRequireDefault(require("../config-provider/defaultRenderEmpty"));
|
|
22
|
+
var _DisabledContext = _interopRequireDefault(require("../config-provider/DisabledContext"));
|
|
23
|
+
var _useCSSVarCls = _interopRequireDefault(require("../config-provider/hooks/useCSSVarCls"));
|
|
24
|
+
var _useSize = _interopRequireDefault(require("../config-provider/hooks/useSize"));
|
|
25
|
+
var _context2 = require("../form/context");
|
|
26
|
+
var _useVariants = _interopRequireDefault(require("../form/hooks/useVariants"));
|
|
27
|
+
var _Compact = require("../space/Compact");
|
|
28
|
+
var _internal = require("../theme/internal");
|
|
29
|
+
var _mergedBuiltinPlacements = _interopRequireDefault(require("./mergedBuiltinPlacements"));
|
|
30
|
+
var _style = _interopRequireDefault(require("./style"));
|
|
31
|
+
var _useIcons = _interopRequireDefault(require("./useIcons"));
|
|
32
|
+
var _usePopupRender = _interopRequireDefault(require("./usePopupRender"));
|
|
33
|
+
var _useShowArrow = _interopRequireDefault(require("./useShowArrow"));
|
|
34
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
35
|
+
const SECRET_COMBOBOX_MODE_DO_NOT_USE = 'SECRET_COMBOBOX_MODE_DO_NOT_USE';
|
|
36
|
+
const InternalSelect = (props, ref) => {
|
|
37
|
+
const {
|
|
38
|
+
prefixCls: customizePrefixCls,
|
|
39
|
+
bordered,
|
|
40
|
+
className,
|
|
41
|
+
rootClassName,
|
|
42
|
+
getPopupContainer,
|
|
43
|
+
popupClassName,
|
|
44
|
+
dropdownClassName,
|
|
45
|
+
listHeight = 256,
|
|
46
|
+
placement,
|
|
47
|
+
listItemHeight: customListItemHeight,
|
|
48
|
+
size: customizeSize,
|
|
49
|
+
disabled: customDisabled,
|
|
50
|
+
notFoundContent,
|
|
51
|
+
status: customStatus,
|
|
52
|
+
builtinPlacements,
|
|
53
|
+
dropdownMatchSelectWidth,
|
|
54
|
+
popupMatchSelectWidth,
|
|
55
|
+
direction: propDirection,
|
|
56
|
+
style,
|
|
57
|
+
allowClear,
|
|
58
|
+
variant: customizeVariant,
|
|
59
|
+
popupStyle,
|
|
60
|
+
dropdownStyle,
|
|
61
|
+
transitionName,
|
|
62
|
+
tagRender,
|
|
63
|
+
maxCount,
|
|
64
|
+
prefix,
|
|
65
|
+
dropdownRender,
|
|
66
|
+
/**
|
|
67
|
+
* @since 5.25.0
|
|
68
|
+
*/
|
|
69
|
+
popupRender,
|
|
70
|
+
onDropdownVisibleChange,
|
|
71
|
+
onOpenChange,
|
|
72
|
+
styles,
|
|
73
|
+
classNames,
|
|
74
|
+
isFilterItem,
|
|
75
|
+
// TDM_CUSTOM: custom select filter
|
|
76
|
+
optionFilterProp,
|
|
77
|
+
maxLines,
|
|
78
|
+
...rest
|
|
79
|
+
} = props;
|
|
80
|
+
const {
|
|
81
|
+
getPopupContainer: getContextPopupContainer,
|
|
82
|
+
getPrefixCls,
|
|
83
|
+
renderEmpty,
|
|
84
|
+
direction: contextDirection,
|
|
85
|
+
virtual,
|
|
86
|
+
popupMatchSelectWidth: contextPopupMatchSelectWidth,
|
|
87
|
+
popupOverflow
|
|
88
|
+
} = React.useContext(_configProvider.ConfigContext);
|
|
89
|
+
const {
|
|
90
|
+
showSearch,
|
|
91
|
+
optionFilterProp: contextOptionFilterProp,
|
|
92
|
+
maxLines: contextMaxLines,
|
|
93
|
+
style: contextStyle,
|
|
94
|
+
styles: contextStyles,
|
|
95
|
+
className: contextClassName,
|
|
96
|
+
classNames: contextClassNames
|
|
97
|
+
} = (0, _context.useComponentConfig)('select');
|
|
98
|
+
const mergedMaxLines = maxLines ?? contextMaxLines;
|
|
99
|
+
const [, token] = (0, _internal.useToken)();
|
|
100
|
+
const listItemHeight = customListItemHeight ?? token?.controlHeight;
|
|
101
|
+
const prefixCls = getPrefixCls('select', customizePrefixCls);
|
|
102
|
+
const rootPrefixCls = getPrefixCls();
|
|
103
|
+
const direction = propDirection ?? contextDirection;
|
|
104
|
+
const {
|
|
105
|
+
compactSize,
|
|
106
|
+
compactItemClassnames
|
|
107
|
+
} = (0, _Compact.useCompactItemContext)(prefixCls, direction);
|
|
108
|
+
const [variant, enableVariantCls] = (0, _useVariants.default)('select', customizeVariant, bordered);
|
|
109
|
+
const rootCls = (0, _useCSSVarCls.default)(prefixCls);
|
|
110
|
+
const [hashId, cssVarCls] = (0, _style.default)(prefixCls, rootCls);
|
|
111
|
+
const mode = React.useMemo(() => {
|
|
112
|
+
const {
|
|
113
|
+
mode: m
|
|
114
|
+
} = props;
|
|
115
|
+
if (m === 'combobox') {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (m === SECRET_COMBOBOX_MODE_DO_NOT_USE) {
|
|
119
|
+
return 'combobox';
|
|
120
|
+
}
|
|
121
|
+
return m;
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
}, [props.mode]);
|
|
124
|
+
const isMultiple = mode === 'multiple' || mode === 'tags';
|
|
125
|
+
const showSuffixIcon = (0, _useShowArrow.default)(props.suffixIcon, props.showArrow);
|
|
126
|
+
const mergedPopupMatchSelectWidth = popupMatchSelectWidth ?? dropdownMatchSelectWidth ?? contextPopupMatchSelectWidth;
|
|
127
|
+
const mergedPopupRender = (0, _usePopupRender.default)(popupRender || dropdownRender);
|
|
128
|
+
const mergedOnOpenChange = onOpenChange || onDropdownVisibleChange;
|
|
129
|
+
// ===================== Form Status =====================
|
|
130
|
+
const {
|
|
131
|
+
status: contextStatus,
|
|
132
|
+
hasFeedback,
|
|
133
|
+
isFormItemInput,
|
|
134
|
+
feedbackIcon
|
|
135
|
+
} = React.useContext(_context2.FormItemInputContext);
|
|
136
|
+
const mergedStatus = (0, _statusUtils.getMergedStatus)(contextStatus, customStatus);
|
|
137
|
+
// ===================== Empty =====================
|
|
138
|
+
let mergedNotFound;
|
|
139
|
+
if (notFoundContent !== undefined) {
|
|
140
|
+
mergedNotFound = notFoundContent;
|
|
141
|
+
} else if (mode === 'combobox') {
|
|
142
|
+
mergedNotFound = null;
|
|
143
|
+
} else {
|
|
144
|
+
mergedNotFound = renderEmpty?.('Select') || /*#__PURE__*/React.createElement(_defaultRenderEmpty.default, {
|
|
145
|
+
componentName: "Select"
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// ===================== Icons =====================
|
|
149
|
+
const {
|
|
150
|
+
suffixIcon,
|
|
151
|
+
itemIcon,
|
|
152
|
+
removeIcon,
|
|
153
|
+
clearIcon
|
|
154
|
+
} = (0, _useIcons.default)({
|
|
155
|
+
...rest,
|
|
156
|
+
multiple: isMultiple,
|
|
157
|
+
hasFeedback,
|
|
158
|
+
feedbackIcon,
|
|
159
|
+
showSuffixIcon,
|
|
160
|
+
prefixCls,
|
|
161
|
+
componentName: 'Select'
|
|
162
|
+
});
|
|
163
|
+
const mergedAllowClear = allowClear === true ? {
|
|
164
|
+
clearIcon
|
|
165
|
+
} : allowClear;
|
|
166
|
+
const selectProps = (0, _util.omit)(rest, ['suffixIcon', 'itemIcon']);
|
|
167
|
+
const mergedSize = (0, _useSize.default)(ctx => customizeSize ?? compactSize ?? ctx);
|
|
168
|
+
// ===================== Disabled =====================
|
|
169
|
+
const disabled = React.useContext(_DisabledContext.default);
|
|
170
|
+
const mergedDisabled = customDisabled ?? disabled;
|
|
171
|
+
// ========== Merged Props for Semantic ==================
|
|
172
|
+
const mergedProps = {
|
|
173
|
+
...props,
|
|
174
|
+
variant,
|
|
175
|
+
status: mergedStatus,
|
|
176
|
+
disabled: mergedDisabled,
|
|
177
|
+
size: mergedSize
|
|
178
|
+
};
|
|
179
|
+
const [mergedClassNames, mergedStyles] = (0, _hooks.useMergeSemantic)([contextClassNames, classNames], [contextStyles, styles], {
|
|
180
|
+
props: mergedProps
|
|
181
|
+
}, {
|
|
182
|
+
popup: {
|
|
183
|
+
_default: 'root'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
const mergedPopupClassName = (0, _clsx.clsx)(mergedClassNames.popup?.root, popupClassName, dropdownClassName, {
|
|
187
|
+
[`${prefixCls}-dropdown-${direction}`]: direction === 'rtl'
|
|
188
|
+
}, rootClassName, cssVarCls, rootCls, hashId);
|
|
189
|
+
const mergedPopupStyle = {
|
|
190
|
+
...mergedStyles.popup?.root,
|
|
191
|
+
...(popupStyle ?? dropdownStyle)
|
|
192
|
+
};
|
|
193
|
+
const mergedClassName = (0, _clsx.clsx)({
|
|
194
|
+
[`${prefixCls}-lg`]: mergedSize === 'large',
|
|
195
|
+
[`${prefixCls}-sm`]: mergedSize === 'small',
|
|
196
|
+
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
197
|
+
[`${prefixCls}-${variant}`]: enableVariantCls,
|
|
198
|
+
[`${prefixCls}-in-form-item`]: isFormItemInput,
|
|
199
|
+
// TDM_CUSTOM: custom select filter
|
|
200
|
+
[`${prefixCls}-filter`]: isFilterItem
|
|
201
|
+
}, (0, _statusUtils.getStatusClassNames)(prefixCls, mergedStatus, hasFeedback), compactItemClassnames, contextClassName, className, mergedClassNames.root, rootClassName, cssVarCls, rootCls, hashId);
|
|
202
|
+
// ===================== Placement =====================
|
|
203
|
+
const memoPlacement = React.useMemo(() => {
|
|
204
|
+
if (placement !== undefined) {
|
|
205
|
+
return placement;
|
|
206
|
+
}
|
|
207
|
+
return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
|
|
208
|
+
}, [placement, direction]);
|
|
209
|
+
// ====================== Warning ======================
|
|
210
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
211
|
+
const warning = (0, _warning.devUseWarning)('Select');
|
|
212
|
+
const deprecatedProps = {
|
|
213
|
+
dropdownMatchSelectWidth: 'popupMatchSelectWidth',
|
|
214
|
+
dropdownStyle: 'styles.popup.root',
|
|
215
|
+
dropdownClassName: 'classNames.popup.root',
|
|
216
|
+
popupClassName: 'classNames.popup.root',
|
|
217
|
+
dropdownRender: 'popupRender',
|
|
218
|
+
onDropdownVisibleChange: 'onOpenChange',
|
|
219
|
+
bordered: 'variant'
|
|
220
|
+
};
|
|
221
|
+
Object.entries(deprecatedProps).forEach(([oldProp, newProp]) => {
|
|
222
|
+
warning.deprecated(!(oldProp in props), oldProp, newProp);
|
|
223
|
+
});
|
|
224
|
+
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;
|
|
225
|
+
process.env.NODE_ENV !== "production" ? warning(!(typeof maxCount !== 'undefined' && !isMultiple), 'usage', '`maxCount` only works with mode `multiple` or `tags`') : void 0;
|
|
226
|
+
}
|
|
227
|
+
// ====================== MaxLines ======================
|
|
228
|
+
const internalSelectRef = React.useRef(null);
|
|
229
|
+
React.useImperativeHandle(ref, () => internalSelectRef.current);
|
|
230
|
+
const [linesMaxTagCount, setLinesMaxTagCount] = React.useState(undefined);
|
|
231
|
+
const calculateMaxLinesTags = React.useCallback(() => {
|
|
232
|
+
if (!mergedMaxLines || !isMultiple) return;
|
|
233
|
+
const container = internalSelectRef.current?.nativeElement;
|
|
234
|
+
if (!container) return;
|
|
235
|
+
const tagElements = container.querySelectorAll(`.${prefixCls}-selection-item, .${prefixCls}-content-item`);
|
|
236
|
+
if (tagElements.length === 0) {
|
|
237
|
+
setLinesMaxTagCount(undefined);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const firstTagTop = tagElements[0].offsetTop;
|
|
241
|
+
const tagHeight = tagElements[0].offsetHeight || 24;
|
|
242
|
+
const rowHeightThreshold = tagHeight + 6;
|
|
243
|
+
const maxAllowedTop = firstTagTop + rowHeightThreshold * (mergedMaxLines - 1);
|
|
244
|
+
let fitCount = tagElements.length;
|
|
245
|
+
for (let i = 0; i < tagElements.length; i++) {
|
|
246
|
+
const el = tagElements[i];
|
|
247
|
+
if (el.offsetTop > maxAllowedTop) {
|
|
248
|
+
fitCount = Math.max(1, i - 1);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (fitCount < tagElements.length) {
|
|
253
|
+
setLinesMaxTagCount(fitCount);
|
|
254
|
+
} else {
|
|
255
|
+
setLinesMaxTagCount(undefined);
|
|
256
|
+
}
|
|
257
|
+
}, [mergedMaxLines, isMultiple, prefixCls]);
|
|
258
|
+
React.useLayoutEffect(() => {
|
|
259
|
+
if (!mergedMaxLines || !isMultiple) {
|
|
260
|
+
setLinesMaxTagCount(undefined);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
setLinesMaxTagCount(undefined);
|
|
264
|
+
const timer = requestAnimationFrame(() => {
|
|
265
|
+
calculateMaxLinesTags();
|
|
266
|
+
});
|
|
267
|
+
return () => cancelAnimationFrame(timer);
|
|
268
|
+
}, [props.value, mergedMaxLines, isMultiple, calculateMaxLinesTags]);
|
|
269
|
+
React.useLayoutEffect(() => {
|
|
270
|
+
if (!mergedMaxLines || !isMultiple) return;
|
|
271
|
+
const container = internalSelectRef.current?.nativeElement;
|
|
272
|
+
if (!container || typeof ResizeObserver === 'undefined') return;
|
|
273
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
274
|
+
calculateMaxLinesTags();
|
|
275
|
+
});
|
|
276
|
+
resizeObserver.observe(container);
|
|
277
|
+
return () => resizeObserver.disconnect();
|
|
278
|
+
}, [mergedMaxLines, isMultiple, calculateMaxLinesTags]);
|
|
279
|
+
// ====================== zIndex =========================
|
|
280
|
+
const [zIndex] = (0, _hooks.useZIndex)('SelectLike', mergedStyles.popup?.root?.zIndex ?? mergedPopupStyle?.zIndex);
|
|
281
|
+
// ====================== Render =======================
|
|
282
|
+
return /*#__PURE__*/React.createElement(_select.default, {
|
|
283
|
+
ref: internalSelectRef,
|
|
284
|
+
virtual: virtual,
|
|
285
|
+
classNames: mergedClassNames,
|
|
286
|
+
styles: mergedStyles,
|
|
287
|
+
showSearch: showSearch,
|
|
288
|
+
optionFilterProp: optionFilterProp ?? contextOptionFilterProp ?? 'label',
|
|
289
|
+
...selectProps,
|
|
290
|
+
maxTagCount: mergedMaxLines && isMultiple ? linesMaxTagCount : props.maxTagCount ?? (isMultiple ? maxCount : undefined),
|
|
291
|
+
style: {
|
|
292
|
+
...mergedStyles.root,
|
|
293
|
+
...contextStyle,
|
|
294
|
+
...style
|
|
295
|
+
},
|
|
296
|
+
popupMatchSelectWidth: mergedPopupMatchSelectWidth,
|
|
297
|
+
transitionName: (0, _motion.getTransitionName)(rootPrefixCls, 'slide-up', transitionName),
|
|
298
|
+
builtinPlacements: (0, _mergedBuiltinPlacements.default)(builtinPlacements, popupOverflow),
|
|
299
|
+
listHeight: listHeight,
|
|
300
|
+
listItemHeight: listItemHeight,
|
|
301
|
+
mode: mode,
|
|
302
|
+
prefixCls: prefixCls,
|
|
303
|
+
placement: memoPlacement,
|
|
304
|
+
direction: direction,
|
|
305
|
+
prefix: prefix,
|
|
306
|
+
suffixIcon: suffixIcon,
|
|
307
|
+
menuItemSelectedIcon: itemIcon,
|
|
308
|
+
removeIcon: removeIcon,
|
|
309
|
+
allowClear: mergedAllowClear,
|
|
310
|
+
notFoundContent: mergedNotFound,
|
|
311
|
+
className: mergedClassName,
|
|
312
|
+
getPopupContainer: getPopupContainer || getContextPopupContainer,
|
|
313
|
+
popupClassName: mergedPopupClassName,
|
|
314
|
+
disabled: mergedDisabled,
|
|
315
|
+
popupStyle: {
|
|
316
|
+
...mergedStyles.popup?.root,
|
|
317
|
+
...mergedPopupStyle,
|
|
318
|
+
zIndex
|
|
319
|
+
},
|
|
320
|
+
maxCount: isMultiple ? maxCount : undefined,
|
|
321
|
+
tagRender: isMultiple ? tagRender : undefined,
|
|
322
|
+
popupRender: mergedPopupRender,
|
|
323
|
+
onPopupVisibleChange: mergedOnOpenChange
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
327
|
+
InternalSelect.displayName = 'Select';
|
|
328
|
+
}
|
|
329
|
+
const Select = /*#__PURE__*/React.forwardRef(InternalSelect);
|
|
330
|
+
// We don't care debug panel
|
|
331
|
+
/* istanbul ignore next */
|
|
332
|
+
const PurePanel = (0, _PurePanel.default)(Select, 'popupAlign');
|
|
333
|
+
Select.SECRET_COMBOBOX_MODE_DO_NOT_USE = SECRET_COMBOBOX_MODE_DO_NOT_USE;
|
|
334
|
+
Select.Option = _select.Option;
|
|
335
|
+
Select.OptGroup = _select.OptGroup;
|
|
336
|
+
Select._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
|
337
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
338
|
+
Select.displayName = 'Select';
|
|
339
|
+
}
|
|
340
|
+
var _default = exports.default = Select;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectProps, BaseOptionType, DefaultOptionType } from './Select';
|
|
3
|
+
export type SingleDisplaySelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = SelectProps<ValueType, OptionType>;
|
|
4
|
+
declare const SingleDisplaySelect: <ValueType extends any[] = any[], OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SingleDisplaySelectProps<ValueType, OptionType>) => React.JSX.Element;
|
|
5
|
+
export default SingleDisplaySelect;
|