@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.
Files changed (41) hide show
  1. package/dist/@tdm-design/ui.js +113060 -0
  2. package/dist/@tdm-design/ui.js.map +1 -0
  3. package/dist/@tdm-design/ui.min.js +373 -0
  4. package/dist/@tdm-design/ui.min.js.LICENSE.txt +129 -0
  5. package/dist/@tdm-design/ui.min.js.map +1 -0
  6. package/dist/reset.css +246 -0
  7. package/dist/tdm-with-locales.js +373 -0
  8. package/dist/tdm-with-locales.js.LICENSE.txt +129 -0
  9. package/dist/tdm-with-locales.js.map +1 -0
  10. package/dist/tdm.css +1 -0
  11. package/es/config-provider/context.d.ts +1 -1
  12. package/es/index.d.ts +2 -2
  13. package/es/index.js +1 -1
  14. package/es/select/Select.d.ts +130 -0
  15. package/es/select/Select.js +333 -0
  16. package/es/select/SingleDisplaySelect.d.ts +5 -0
  17. package/es/select/SingleDisplaySelect.js +157 -0
  18. package/es/select/SortableSelect.d.ts +5 -0
  19. package/es/select/SortableSelect.js +173 -0
  20. package/es/select/index.d.ts +7 -124
  21. package/es/select/index.js +7 -274
  22. package/es/select/style/select-input-multiple.js +4 -1
  23. package/es/version/token.json +1 -1
  24. package/es/version/version.d.ts +1 -1
  25. package/es/version/version.js +1 -1
  26. package/lib/config-provider/context.d.ts +1 -1
  27. package/lib/index.d.ts +2 -2
  28. package/lib/index.js +14 -1
  29. package/lib/select/Select.d.ts +130 -0
  30. package/lib/select/Select.js +340 -0
  31. package/lib/select/SingleDisplaySelect.d.ts +5 -0
  32. package/lib/select/SingleDisplaySelect.js +164 -0
  33. package/lib/select/SortableSelect.d.ts +5 -0
  34. package/lib/select/SortableSelect.js +180 -0
  35. package/lib/select/index.d.ts +7 -124
  36. package/lib/select/index.js +32 -274
  37. package/lib/select/style/select-input-multiple.js +4 -1
  38. package/lib/version/token.json +1 -1
  39. package/lib/version/version.d.ts +1 -1
  40. package/lib/version/version.js +1 -1
  41. package/package.json +10 -3
@@ -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;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ "use client";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _Select = _interopRequireDefault(require("./Select"));
11
+ var _popover = _interopRequireDefault(require("../popover"));
12
+ var _tag = _interopRequireDefault(require("../tag"));
13
+ var _configProvider = require("../config-provider");
14
+ var _CloseOutlinedIcon = _interopRequireDefault(require("@tdm-design/icons/CloseOutlinedIcon"));
15
+ 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); }
16
+ function extractValueId(val) {
17
+ if (typeof val === 'object' && val !== null) {
18
+ if ('key' in val && val.key !== undefined) return val.key;
19
+ if ('value' in val && val.value !== undefined) return val.value;
20
+ }
21
+ return val;
22
+ }
23
+ const SingleDisplaySelect = props => {
24
+ const {
25
+ value,
26
+ defaultValue,
27
+ onChange,
28
+ disabled,
29
+ tagRender,
30
+ maxTagPlaceholder,
31
+ prefixCls: customizePrefixCls,
32
+ ...restProps
33
+ } = props;
34
+ const {
35
+ getPrefixCls
36
+ } = _react.default.useContext(_configProvider.ConfigContext);
37
+ const prefixCls = getPrefixCls('select', customizePrefixCls);
38
+ // Maintain internal state for uncontrolled usage
39
+ const [internalValue, setInternalValue] = (0, _react.useState)(() => {
40
+ if (value !== undefined) return value;
41
+ if (defaultValue !== undefined) return defaultValue;
42
+ return [];
43
+ });
44
+ // Keep track of the options to properly call onChange
45
+ const [internalOptions, setInternalOptions] = (0, _react.useState)([]);
46
+ // Sync with controlled value
47
+ (0, _react.useEffect)(() => {
48
+ if (value !== undefined) {
49
+ setInternalValue(value);
50
+ }
51
+ }, [value]);
52
+ // Sync internalOptions when value changes externally if possible
53
+ // In a real scenario we'd need to lookup options from the list if we don't have them
54
+ // For simplicity we just rely on onChange to provide them.
55
+ const handleChange = (val, opt) => {
56
+ if (value === undefined) {
57
+ setInternalValue(val);
58
+ }
59
+ setInternalOptions(opt);
60
+ onChange?.(val, opt);
61
+ };
62
+ const handleRemove = (itemValue, e) => {
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ const prevArray = Array.isArray(internalValue) ? internalValue : [];
66
+ const newValue = prevArray.filter(v => extractValueId(v) !== itemValue);
67
+ // We try to filter internalOptions, if it's not maintained correctly, we might pass []
68
+ // which is better than passing the wrong options.
69
+ const newOptions = Array.isArray(internalOptions) ? internalOptions.filter(opt => extractValueId(opt.value) !== itemValue) : [];
70
+ handleChange(newValue, newOptions);
71
+ };
72
+ const defaultTagRender = (0, _react.useCallback)(tagProps => {
73
+ const {
74
+ label,
75
+ closable,
76
+ onClose,
77
+ disabled: itemDisabled
78
+ } = tagProps;
79
+ const onMouseDown = e => {
80
+ e.preventDefault();
81
+ e.stopPropagation();
82
+ };
83
+ return /*#__PURE__*/_react.default.createElement("span", {
84
+ className: `${prefixCls}-selection-item${itemDisabled ? ` ${prefixCls}-selection-item-disabled` : ''}`,
85
+ onMouseDown: onMouseDown
86
+ }, /*#__PURE__*/_react.default.createElement("span", {
87
+ className: `${prefixCls}-selection-item-content`
88
+ }, label), closable && (/*#__PURE__*/_react.default.createElement("span", {
89
+ className: `${prefixCls}-selection-item-remove`,
90
+ onClick: e => {
91
+ e.stopPropagation();
92
+ onClose?.(e);
93
+ },
94
+ onMouseDown: onMouseDown
95
+ }, /*#__PURE__*/_react.default.createElement(_CloseOutlinedIcon.default, null))));
96
+ }, [prefixCls]);
97
+ const mergedTagRender = tagRender || defaultTagRender;
98
+ const defaultMaxTagPlaceholder = (0, _react.useCallback)(omittedValues => {
99
+ return /*#__PURE__*/_react.default.createElement(_popover.default, {
100
+ content: /*#__PURE__*/_react.default.createElement("div", {
101
+ style: {
102
+ display: 'flex',
103
+ flexWrap: 'wrap',
104
+ gap: 6,
105
+ maxWidth: 350,
106
+ padding: 8
107
+ }
108
+ }, omittedValues.map(v => (/*#__PURE__*/_react.default.createElement(_tag.default, {
109
+ key: extractValueId(v.value),
110
+ closable: !disabled && !v.disabled,
111
+ closeIcon: /*#__PURE__*/_react.default.createElement("span", {
112
+ style: {
113
+ fontSize: 10,
114
+ display: 'inline-flex',
115
+ alignItems: 'center',
116
+ marginLeft: 6
117
+ }
118
+ }, "\u2715"),
119
+ onClose: e => handleRemove(extractValueId(v.value), e),
120
+ style: {
121
+ margin: 0,
122
+ display: 'flex',
123
+ alignItems: 'center',
124
+ padding: '2px 6px',
125
+ borderRadius: 4
126
+ }
127
+ }, v.label)))),
128
+ placement: "top",
129
+ trigger: "hover"
130
+ }, /*#__PURE__*/_react.default.createElement("span", null, "+", omittedValues.length, " ..."));
131
+ }, [disabled, internalValue, internalOptions]);
132
+ const mergedMaxTagPlaceholder = maxTagPlaceholder || defaultMaxTagPlaceholder;
133
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("style", null, `
134
+ .tdm-single-display-select .${prefixCls}-selector {
135
+ align-items: center !important;
136
+ }
137
+ .tdm-single-display-select .${prefixCls}-selection-item {
138
+ margin-top: 0 !important;
139
+ margin-bottom: 0 !important;
140
+ max-width: 100% !important;
141
+ }
142
+ .tdm-single-display-select .${prefixCls}-content-item {
143
+ max-width: 100% !important;
144
+ }
145
+ .tdm-single-display-select .${prefixCls}-selection-overflow {
146
+ flex-wrap: nowrap !important;
147
+ overflow: hidden;
148
+ }
149
+ .tdm-single-display-select .${prefixCls}-selection-overflow-item {
150
+ max-width: 100% !important;
151
+ }
152
+ `), /*#__PURE__*/_react.default.createElement(_Select.default, {
153
+ ...restProps,
154
+ className: `tdm-single-display-select ${restProps.className || ''}`,
155
+ mode: restProps.mode || 'multiple',
156
+ value: internalValue,
157
+ onChange: handleChange,
158
+ disabled: disabled,
159
+ maxTagCount: restProps.maxTagCount !== undefined ? restProps.maxTagCount : 1,
160
+ tagRender: mergedTagRender,
161
+ maxTagPlaceholder: mergedMaxTagPlaceholder
162
+ }));
163
+ };
164
+ var _default = exports.default = SingleDisplaySelect;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { SelectProps, BaseOptionType, DefaultOptionType } from './Select';
3
+ export type SortableSelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = SelectProps<ValueType, OptionType>;
4
+ declare const SortableSelect: <ValueType extends any[] = any[], OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SortableSelectProps<ValueType, OptionType>) => React.JSX.Element;
5
+ export default SortableSelect;