one-design-next 0.0.78 → 0.0.81
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/clarify-dock/style/index.css +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/select/SelectFeedback.d.ts +2 -0
- package/dist/select/SelectFeedback.js +102 -5
- package/dist/select/index.d.ts +1 -1
- package/dist/select/index.js +59 -39
- package/dist/select/style/index.css +7 -0
- package/dist/virtual-list/index.d.ts +5 -1
- package/dist/virtual-list/index.js +7 -8
- package/dist/virtual-list/style/index.css +54 -0
- package/package.json +1 -1
|
@@ -545,13 +545,15 @@ div[data-odn-clarify-dock] [data-odn-clarify-dock-body] {
|
|
|
545
545
|
div[data-odn-clarify-dock] [data-odn-date-picker-container]:not([data-odn-date-picker-container-range]) {
|
|
546
546
|
display: inline-block;
|
|
547
547
|
box-sizing: border-box;
|
|
548
|
-
|
|
548
|
+
font-size: var(--odn-font-size-text-sm);
|
|
549
|
+
width: calc(10ch + 10px + 32px + 2px);
|
|
549
550
|
}
|
|
550
551
|
|
|
551
552
|
div[data-odn-clarify-dock] [data-odn-date-picker-container-range] {
|
|
552
553
|
display: inline-block;
|
|
553
554
|
box-sizing: border-box;
|
|
554
|
-
|
|
555
|
+
font-size: var(--odn-font-size-text-sm);
|
|
556
|
+
width: calc(21ch + 10px + 32px + 2px);
|
|
555
557
|
}
|
|
556
558
|
|
|
557
559
|
div[data-odn-clarify-dock] [data-odn-date-picker-input] {
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export { default as TextSwap, type TextSwapFlipProps, type TextSwapProps, } from
|
|
|
50
50
|
export { default as TimePicker, type TimePickerProps } from './time-picker';
|
|
51
51
|
export { default as Tooltip } from './tooltip';
|
|
52
52
|
export { default as TreeSelect, type TreeNodeData, type TreeSelectProps, } from './tree-select';
|
|
53
|
-
export { default as VirtualList, type VirtualListProps } from './virtual-list';
|
|
53
|
+
export { default as VirtualList, type VirtualListProps, type VirtualListRef, } from './virtual-list';
|
|
54
54
|
export { default as ActionBar, type ActionBarProps } from './action-bar';
|
|
55
55
|
export { default as AgentStep, type AgentStepGroupProps, type AgentStepProps, } from './agent-step';
|
|
56
56
|
export { default as AgentThink, type AgentThinkProps } from './agent-think';
|
|
@@ -6,6 +6,8 @@ export type SelectFeedbackState = {
|
|
|
6
6
|
export interface SelectFeedbackProps {
|
|
7
7
|
feedback: SelectFeedbackState | null;
|
|
8
8
|
onUndo?: () => void;
|
|
9
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
10
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
9
11
|
}
|
|
10
12
|
declare const SelectFeedback: React.FC<SelectFeedbackProps>;
|
|
11
13
|
export default SelectFeedback;
|
|
@@ -1,17 +1,114 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
var ANIMATE_MS = 300;
|
|
4
|
+
var ANIMATE_DELAY_MS = 50;
|
|
5
|
+
var COLLAPSED_STYLE = {
|
|
6
|
+
height: '0px',
|
|
7
|
+
marginTop: '0',
|
|
8
|
+
marginBottom: '0',
|
|
9
|
+
paddingTop: '0',
|
|
10
|
+
paddingBottom: '0',
|
|
11
|
+
opacity: '0'
|
|
12
|
+
};
|
|
13
|
+
var EXPANDED_STYLE = {
|
|
14
|
+
height: '',
|
|
15
|
+
marginTop: '',
|
|
16
|
+
marginBottom: '',
|
|
17
|
+
paddingTop: '',
|
|
18
|
+
paddingBottom: '',
|
|
19
|
+
opacity: ''
|
|
20
|
+
};
|
|
21
|
+
function prefersReducedMotion() {
|
|
22
|
+
return typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
23
|
+
}
|
|
2
24
|
var SelectFeedback = function SelectFeedback(_ref) {
|
|
3
25
|
var feedback = _ref.feedback,
|
|
4
|
-
onUndo = _ref.onUndo
|
|
5
|
-
|
|
26
|
+
onUndo = _ref.onUndo,
|
|
27
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
28
|
+
onMouseLeave = _ref.onMouseLeave;
|
|
29
|
+
var _useState = useState(feedback),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
rendered = _useState2[0],
|
|
32
|
+
setRendered = _useState2[1];
|
|
33
|
+
var _useState3 = useState(Boolean(feedback)),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
open = _useState4[0],
|
|
36
|
+
setOpen = _useState4[1];
|
|
37
|
+
var rootRef = useRef(null);
|
|
38
|
+
var timersRef = useRef([]);
|
|
39
|
+
var clearTimers = function clearTimers() {
|
|
40
|
+
timersRef.current.forEach(function (id) {
|
|
41
|
+
return window.clearTimeout(id);
|
|
42
|
+
});
|
|
43
|
+
timersRef.current = [];
|
|
44
|
+
};
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (feedback) {
|
|
47
|
+
setRendered(feedback);
|
|
48
|
+
setOpen(true);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setOpen(false);
|
|
52
|
+
}, [feedback]);
|
|
53
|
+
useLayoutEffect(function () {
|
|
54
|
+
var el = rootRef.current;
|
|
55
|
+
if (!el) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
clearTimers();
|
|
59
|
+
if (prefersReducedMotion()) {
|
|
60
|
+
if (open) {
|
|
61
|
+
Object.assign(el.style, EXPANDED_STYLE);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setRendered(null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (open) {
|
|
68
|
+
el.style.transition = 'none';
|
|
69
|
+
Object.assign(el.style, EXPANDED_STYLE);
|
|
70
|
+
el.style.height = '';
|
|
71
|
+
var height = el.offsetHeight;
|
|
72
|
+
Object.assign(el.style, COLLAPSED_STYLE);
|
|
73
|
+
void el.offsetHeight;
|
|
74
|
+
el.style.transition = '';
|
|
75
|
+
var expandId = window.setTimeout(function () {
|
|
76
|
+
Object.assign(el.style, EXPANDED_STYLE, {
|
|
77
|
+
height: "".concat(height, "px")
|
|
78
|
+
});
|
|
79
|
+
var settleId = window.setTimeout(function () {
|
|
80
|
+
el.style.height = '';
|
|
81
|
+
}, ANIMATE_MS + ANIMATE_DELAY_MS);
|
|
82
|
+
timersRef.current.push(settleId);
|
|
83
|
+
}, 0);
|
|
84
|
+
timersRef.current.push(expandId);
|
|
85
|
+
} else {
|
|
86
|
+
el.style.height = "".concat(el.offsetHeight, "px");
|
|
87
|
+
void el.offsetHeight;
|
|
88
|
+
var collapseId = window.setTimeout(function () {
|
|
89
|
+
Object.assign(el.style, COLLAPSED_STYLE);
|
|
90
|
+
var doneId = window.setTimeout(function () {
|
|
91
|
+
setRendered(null);
|
|
92
|
+
}, ANIMATE_MS);
|
|
93
|
+
timersRef.current.push(doneId);
|
|
94
|
+
}, 0);
|
|
95
|
+
timersRef.current.push(collapseId);
|
|
96
|
+
}
|
|
97
|
+
return clearTimers;
|
|
98
|
+
}, [open]);
|
|
99
|
+
if (!rendered) {
|
|
6
100
|
return null;
|
|
7
101
|
}
|
|
8
102
|
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
ref: rootRef,
|
|
9
104
|
className: "odn-select-feedback",
|
|
10
105
|
role: "status",
|
|
11
|
-
"data-odn-select-feedback": true
|
|
106
|
+
"data-odn-select-feedback": true,
|
|
107
|
+
onMouseEnter: onMouseEnter,
|
|
108
|
+
onMouseLeave: onMouseLeave
|
|
12
109
|
}, /*#__PURE__*/React.createElement("span", {
|
|
13
110
|
className: "odn-select-feedback-message"
|
|
14
|
-
},
|
|
111
|
+
}, rendered.message), rendered.undoable ? /*#__PURE__*/React.createElement("button", {
|
|
15
112
|
type: "button",
|
|
16
113
|
className: "odn-select-feedback-undo",
|
|
17
114
|
onClick: onUndo
|
package/dist/select/index.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
72
72
|
* 传入 tokenSeparators 时默认 true;也可单独开启(需 allowClear)。
|
|
73
73
|
*/
|
|
74
74
|
clearUndo?: boolean;
|
|
75
|
-
/** 反馈条自动消失时长(ms
|
|
75
|
+
/** 反馈条自动消失时长(ms)。下拉打开或悬停反馈条时不计时,离开后再开始 */
|
|
76
76
|
feedbackDuration?: number;
|
|
77
77
|
}
|
|
78
78
|
export interface SelectButtonProps {
|
package/dist/select/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
-
var _excluded = ["className", "rootClassName", "style", "light", "mode", "suffixIcon", "popupClassName", "popupMatchSelectWidth", "visible", "onVisibleChange", "showInnerSearch", "popupRender", "searchValue", "onSearch", "maxCount", "defaultValue", "value", "onChange", "placeholder", "showSearch", "size", "autoClearSearchValue", "optionRender", "tagRender", "options", "allowClear", "onClear", "tokenSeparators", "tokenMismatch", "tokenFeedback", "validateTokens", "onTokenPaste", "clearUndo", "feedbackDuration", "disabled"];
|
|
8
|
+
var _excluded = ["className", "rootClassName", "style", "light", "mode", "suffixIcon", "popupClassName", "popupMatchSelectWidth", "visible", "open", "onVisibleChange", "showInnerSearch", "popupRender", "searchValue", "onSearch", "maxCount", "defaultValue", "value", "onChange", "placeholder", "showSearch", "size", "autoClearSearchValue", "optionRender", "tagRender", "options", "allowClear", "onClear", "tokenSeparators", "tokenMismatch", "tokenFeedback", "validateTokens", "onTokenPaste", "clearUndo", "feedbackDuration", "disabled"];
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import RcSelect, { OptGroup, Option } from 'rc-select';
|
|
11
11
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -17,6 +17,7 @@ import "./style";
|
|
|
17
17
|
import { countValidValues, formatTokenPasteFeedback, readClipboardText, resolveTokenPaste, splitByTokenSeparators, toRawValueList } from "./tokenUtils";
|
|
18
18
|
import useIcons from "./useIcons";
|
|
19
19
|
var InternalSelect = function InternalSelect(props, ref) {
|
|
20
|
+
var _ref;
|
|
20
21
|
var className = props.className,
|
|
21
22
|
rootClassName = props.rootClassName,
|
|
22
23
|
style = props.style,
|
|
@@ -29,6 +30,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
29
30
|
popupClassName = props.popupClassName,
|
|
30
31
|
popupMatchSelectWidth = props.popupMatchSelectWidth,
|
|
31
32
|
visibleProp = props.visible,
|
|
33
|
+
openProp = props.open,
|
|
32
34
|
onVisibleChange = props.onVisibleChange,
|
|
33
35
|
_props$showInnerSearc = props.showInnerSearch,
|
|
34
36
|
showInnerSearch = _props$showInnerSearc === void 0 ? false : _props$showInnerSearc,
|
|
@@ -102,10 +104,14 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
102
104
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
103
105
|
feedback = _useState10[0],
|
|
104
106
|
setFeedback = _useState10[1];
|
|
107
|
+
var _useState11 = useState(false),
|
|
108
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
109
|
+
feedbackHovered = _useState12[0],
|
|
110
|
+
setFeedbackHovered = _useState12[1];
|
|
105
111
|
var undoSnapshotRef = useRef(null);
|
|
106
|
-
var feedbackTimerRef = useRef();
|
|
107
112
|
var dropdownSearchInputRef = useRef(null);
|
|
108
113
|
var pastingRef = useRef(false);
|
|
114
|
+
var mergedOpen = (_ref = visibleProp !== null && visibleProp !== void 0 ? visibleProp : openProp) !== null && _ref !== void 0 ? _ref : Boolean(visible);
|
|
109
115
|
var handleVisibleChange = function handleVisibleChange(bool) {
|
|
110
116
|
if (visibleProp === undefined) {
|
|
111
117
|
setVisible(bool);
|
|
@@ -144,12 +150,24 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
144
150
|
}
|
|
145
151
|
}, [visible]);
|
|
146
152
|
useEffect(function () {
|
|
153
|
+
if (!feedback) {
|
|
154
|
+
setFeedbackHovered(false);
|
|
155
|
+
}
|
|
156
|
+
}, [feedback]);
|
|
157
|
+
|
|
158
|
+
// 下拉盖住 / 悬停反馈条时不计时;可看见且离开后再开始 duration
|
|
159
|
+
useEffect(function () {
|
|
160
|
+
if (!feedback || mergedOpen || feedbackHovered) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
var timer = window.setTimeout(function () {
|
|
164
|
+
setFeedback(null);
|
|
165
|
+
undoSnapshotRef.current = null;
|
|
166
|
+
}, feedbackDuration);
|
|
147
167
|
return function () {
|
|
148
|
-
|
|
149
|
-
clearTimeout(feedbackTimerRef.current);
|
|
150
|
-
}
|
|
168
|
+
window.clearTimeout(timer);
|
|
151
169
|
};
|
|
152
|
-
}, []);
|
|
170
|
+
}, [feedback, mergedOpen, feedbackHovered, feedbackDuration]);
|
|
153
171
|
var showFeedback = function showFeedback(next) {
|
|
154
172
|
if (!enableTokenFeedback && !(next !== null && next !== void 0 && next.undoable)) {
|
|
155
173
|
setFeedback(null);
|
|
@@ -160,15 +178,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
160
178
|
return;
|
|
161
179
|
}
|
|
162
180
|
setFeedback(next);
|
|
163
|
-
if (feedbackTimerRef.current) {
|
|
164
|
-
clearTimeout(feedbackTimerRef.current);
|
|
165
|
-
}
|
|
166
|
-
if (next) {
|
|
167
|
-
feedbackTimerRef.current = setTimeout(function () {
|
|
168
|
-
setFeedback(null);
|
|
169
|
-
undoSnapshotRef.current = null;
|
|
170
|
-
}, feedbackDuration);
|
|
171
|
-
}
|
|
172
181
|
};
|
|
173
182
|
var commitValue = function commitValue(next, option) {
|
|
174
183
|
if (valueProp === undefined) {
|
|
@@ -187,7 +196,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
187
196
|
});
|
|
188
197
|
};
|
|
189
198
|
var handlePasteCapture = /*#__PURE__*/function () {
|
|
190
|
-
var
|
|
199
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
191
200
|
var text, tokens, currentRaw, result;
|
|
192
201
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
193
202
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -243,18 +252,23 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
243
252
|
onSearch === null || onSearch === void 0 || onSearch('');
|
|
244
253
|
}
|
|
245
254
|
|
|
255
|
+
// 分隔符拆词是提交,关掉下拉让反馈条可见
|
|
256
|
+
if (mergedOpen) {
|
|
257
|
+
handleVisibleChange(false);
|
|
258
|
+
}
|
|
259
|
+
|
|
246
260
|
// 让受控/非受控 onChange 完成后再放开,避免同一次粘贴被 rc-select 再处理
|
|
247
261
|
window.setTimeout(function () {
|
|
248
262
|
pastingRef.current = false;
|
|
249
263
|
}, 0);
|
|
250
|
-
case
|
|
264
|
+
case 22:
|
|
251
265
|
case "end":
|
|
252
266
|
return _context.stop();
|
|
253
267
|
}
|
|
254
268
|
}, _callee);
|
|
255
269
|
}));
|
|
256
270
|
return function handlePasteCapture(_x) {
|
|
257
|
-
return
|
|
271
|
+
return _ref2.apply(this, arguments);
|
|
258
272
|
};
|
|
259
273
|
}();
|
|
260
274
|
var handleClear = function handleClear() {
|
|
@@ -346,7 +360,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
346
360
|
removeIcon: removeIcon,
|
|
347
361
|
clearIcon: clearIcon,
|
|
348
362
|
maxCount: maxCount,
|
|
349
|
-
open:
|
|
363
|
+
open: mergedOpen,
|
|
350
364
|
onDropdownVisibleChange: handleVisibleChange,
|
|
351
365
|
searchValue: searchValue,
|
|
352
366
|
onSearch: handleSearch,
|
|
@@ -420,32 +434,38 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
420
434
|
"data-odn-select-shell": true
|
|
421
435
|
}, selectNode, /*#__PURE__*/React.createElement(SelectFeedback, {
|
|
422
436
|
feedback: enableTokenFeedback || feedback !== null && feedback !== void 0 && feedback.undoable && enableClearUndo ? feedback : null,
|
|
423
|
-
onUndo: handleUndo
|
|
437
|
+
onUndo: handleUndo,
|
|
438
|
+
onMouseEnter: function onMouseEnter() {
|
|
439
|
+
return setFeedbackHovered(true);
|
|
440
|
+
},
|
|
441
|
+
onMouseLeave: function onMouseLeave() {
|
|
442
|
+
return setFeedbackHovered(false);
|
|
443
|
+
}
|
|
424
444
|
}));
|
|
425
445
|
};
|
|
426
446
|
|
|
427
447
|
// Select.Button 组件接口
|
|
428
448
|
|
|
429
449
|
// Select.Button 组件
|
|
430
|
-
var SelectButton = /*#__PURE__*/React.forwardRef(function (
|
|
431
|
-
var
|
|
432
|
-
showArrow =
|
|
433
|
-
|
|
434
|
-
size =
|
|
435
|
-
|
|
436
|
-
disabled =
|
|
437
|
-
prefix =
|
|
438
|
-
|
|
439
|
-
placeholder =
|
|
440
|
-
value =
|
|
441
|
-
|
|
442
|
-
active =
|
|
443
|
-
|
|
444
|
-
allowClear =
|
|
445
|
-
onClick =
|
|
446
|
-
onClear =
|
|
447
|
-
className =
|
|
448
|
-
style =
|
|
450
|
+
var SelectButton = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
451
|
+
var _ref3$showArrow = _ref3.showArrow,
|
|
452
|
+
showArrow = _ref3$showArrow === void 0 ? true : _ref3$showArrow,
|
|
453
|
+
_ref3$size = _ref3.size,
|
|
454
|
+
size = _ref3$size === void 0 ? 'middle' : _ref3$size,
|
|
455
|
+
_ref3$disabled = _ref3.disabled,
|
|
456
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
457
|
+
prefix = _ref3.prefix,
|
|
458
|
+
_ref3$placeholder = _ref3.placeholder,
|
|
459
|
+
placeholder = _ref3$placeholder === void 0 ? '请选择' : _ref3$placeholder,
|
|
460
|
+
value = _ref3.value,
|
|
461
|
+
_ref3$active = _ref3.active,
|
|
462
|
+
active = _ref3$active === void 0 ? false : _ref3$active,
|
|
463
|
+
_ref3$allowClear = _ref3.allowClear,
|
|
464
|
+
allowClear = _ref3$allowClear === void 0 ? false : _ref3$allowClear,
|
|
465
|
+
onClick = _ref3.onClick,
|
|
466
|
+
onClear = _ref3.onClear,
|
|
467
|
+
className = _ref3.className,
|
|
468
|
+
style = _ref3.style;
|
|
449
469
|
var buttonClasses = clsx('odn-select-button odn-select odn-select-outlined odn-select-single odn-select-allow-clear odn-select-show-arrow', "odn-select-button-".concat(size), {
|
|
450
470
|
'odn-select-button-disabled': disabled,
|
|
451
471
|
'odn-select-open': active
|
|
@@ -1904,6 +1904,7 @@ html {
|
|
|
1904
1904
|
display: flex;
|
|
1905
1905
|
align-items: center;
|
|
1906
1906
|
gap: 8px;
|
|
1907
|
+
overflow: hidden;
|
|
1907
1908
|
margin-top: 8px;
|
|
1908
1909
|
padding: 8px 12px;
|
|
1909
1910
|
border-radius: var(--odn-select-border-radius-sm);
|
|
@@ -1911,8 +1912,14 @@ html {
|
|
|
1911
1912
|
color: var(--odn-select-feedback-color);
|
|
1912
1913
|
font-size: 13px;
|
|
1913
1914
|
line-height: 20px;
|
|
1915
|
+
transition: all 300ms cubic-bezier(0.32, 0.72, 0, 1) 50ms, opacity 200ms cubic-bezier(0.32, 0.72, 0, 1);
|
|
1914
1916
|
}
|
|
1915
1917
|
|
|
1918
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1919
|
+
.odn-select-feedback {
|
|
1920
|
+
transition: none;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1916
1923
|
.odn-select-feedback-message {
|
|
1917
1924
|
flex: 1;
|
|
1918
1925
|
min-width: 0;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { ListRef } from 'rc-virtual-list';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import './style';
|
|
4
|
+
export type VirtualListRef = ListRef;
|
|
3
5
|
export interface VirtualListProps<T = unknown> extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
4
6
|
/**
|
|
5
7
|
* @description 列表项的渲染函数
|
|
@@ -94,5 +96,7 @@ export interface VirtualListProps<T = unknown> extends Omit<React.HTMLAttributes
|
|
|
94
96
|
/**
|
|
95
97
|
* VirtualList 虚拟列表
|
|
96
98
|
*/
|
|
97
|
-
declare const VirtualList: <T = unknown>(
|
|
99
|
+
declare const VirtualList: <T = unknown>(props: VirtualListProps<T> & {
|
|
100
|
+
ref?: React.Ref<ListRef>;
|
|
101
|
+
}) => React.ReactElement;
|
|
98
102
|
export default VirtualList;
|
|
@@ -8,7 +8,7 @@ import "./style";
|
|
|
8
8
|
/**
|
|
9
9
|
* VirtualList 虚拟列表
|
|
10
10
|
*/
|
|
11
|
-
var VirtualList = function
|
|
11
|
+
var VirtualList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
12
12
|
var _ref$component = _ref.component,
|
|
13
13
|
component = _ref$component === void 0 ? 'div' : _ref$component,
|
|
14
14
|
className = _ref.className,
|
|
@@ -18,18 +18,16 @@ var VirtualList = function VirtualList(_ref) {
|
|
|
18
18
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
19
19
|
var defaultStyles = {
|
|
20
20
|
verticalScrollBar: {
|
|
21
|
-
width: '
|
|
21
|
+
width: 'var(--odn-virtual-list-scrollbar-thickness, 10px)'
|
|
22
22
|
},
|
|
23
23
|
verticalScrollBarThumb: {
|
|
24
|
-
|
|
25
|
-
backgroundColor: 'var(--odn-color-border)'
|
|
24
|
+
backgroundColor: 'transparent'
|
|
26
25
|
},
|
|
27
26
|
horizontalScrollBar: {
|
|
28
|
-
height: '
|
|
27
|
+
height: 'var(--odn-virtual-list-scrollbar-thickness, 10px)'
|
|
29
28
|
},
|
|
30
29
|
horizontalScrollBarThumb: {
|
|
31
|
-
|
|
32
|
-
backgroundColor: 'var(--odn-color-border)'
|
|
30
|
+
backgroundColor: 'transparent'
|
|
33
31
|
}
|
|
34
32
|
};
|
|
35
33
|
var mergedStyles = _objectSpread(_objectSpread(_objectSpread({}, defaultStyles), styles), {}, {
|
|
@@ -39,6 +37,7 @@ var VirtualList = function VirtualList(_ref) {
|
|
|
39
37
|
horizontalScrollBarThumb: _objectSpread(_objectSpread({}, defaultStyles.horizontalScrollBarThumb), styles === null || styles === void 0 ? void 0 : styles.horizontalScrollBarThumb)
|
|
40
38
|
});
|
|
41
39
|
return /*#__PURE__*/React.createElement(RcVirtualList, _extends({
|
|
40
|
+
ref: ref,
|
|
42
41
|
"data-odn-virtual-list": true,
|
|
43
42
|
prefixCls: "odn-virtual-list",
|
|
44
43
|
component: component,
|
|
@@ -46,5 +45,5 @@ var VirtualList = function VirtualList(_ref) {
|
|
|
46
45
|
styles: mergedStyles,
|
|
47
46
|
showScrollBar: showScrollBar
|
|
48
47
|
}, otherProps));
|
|
49
|
-
};
|
|
48
|
+
});
|
|
50
49
|
export default VirtualList;
|
|
@@ -1,7 +1,61 @@
|
|
|
1
1
|
html {
|
|
2
2
|
--odn-virtual-list-background-color: transparent;
|
|
3
|
+
--odn-virtual-list-scrollbar-thickness: 10px;
|
|
4
|
+
--odn-virtual-list-scrollbar-side-padding: 1px;
|
|
5
|
+
--odn-virtual-list-scrollbar-side-hover-padding: 1px;
|
|
6
|
+
--odn-virtual-list-scrollbar-color: var(--odn-color-border);
|
|
7
|
+
--odn-virtual-list-scrollbar-hover-color: var(--odn-color-border);
|
|
8
|
+
--odn-virtual-list-scrollbar-hover-cursor: default;
|
|
9
|
+
--odn-virtual-list-scrollbar-radius: 9999px;
|
|
3
10
|
}
|
|
4
11
|
|
|
5
12
|
[data-odn-virtual-list] {
|
|
6
13
|
background-color: var(--odn-virtual-list-background-color);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.odn-virtual-list-scrollbar {
|
|
17
|
+
touch-action: none;
|
|
18
|
+
user-select: none;
|
|
19
|
+
}
|
|
20
|
+
.odn-virtual-list-scrollbar:hover {
|
|
21
|
+
cursor: var(--odn-virtual-list-scrollbar-hover-cursor);
|
|
22
|
+
}
|
|
23
|
+
.odn-virtual-list-scrollbar:hover .odn-virtual-list-scrollbar-thumb {
|
|
24
|
+
background-color: var(--odn-virtual-list-scrollbar-hover-color) !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.odn-virtual-list-scrollbar-vertical {
|
|
28
|
+
width: var(--odn-virtual-list-scrollbar-thickness) !important;
|
|
29
|
+
}
|
|
30
|
+
.odn-virtual-list-scrollbar-vertical .odn-virtual-list-scrollbar-thumb {
|
|
31
|
+
width: auto !important;
|
|
32
|
+
left: var(--odn-virtual-list-scrollbar-side-padding);
|
|
33
|
+
right: var(--odn-virtual-list-scrollbar-side-padding);
|
|
34
|
+
transition: left 0.1s, right 0.1s, background-color 0.15s;
|
|
35
|
+
}
|
|
36
|
+
.odn-virtual-list-scrollbar-vertical:hover .odn-virtual-list-scrollbar-thumb {
|
|
37
|
+
left: var(--odn-virtual-list-scrollbar-side-hover-padding);
|
|
38
|
+
right: var(--odn-virtual-list-scrollbar-side-hover-padding);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.odn-virtual-list-scrollbar-horizontal {
|
|
42
|
+
height: var(--odn-virtual-list-scrollbar-thickness) !important;
|
|
43
|
+
}
|
|
44
|
+
.odn-virtual-list-scrollbar-horizontal .odn-virtual-list-scrollbar-thumb {
|
|
45
|
+
height: auto !important;
|
|
46
|
+
top: var(--odn-virtual-list-scrollbar-side-padding);
|
|
47
|
+
bottom: var(--odn-virtual-list-scrollbar-side-padding);
|
|
48
|
+
transition: top 0.1s, bottom 0.1s, background-color 0.15s;
|
|
49
|
+
}
|
|
50
|
+
.odn-virtual-list-scrollbar-horizontal:hover .odn-virtual-list-scrollbar-thumb {
|
|
51
|
+
top: var(--odn-virtual-list-scrollbar-side-hover-padding);
|
|
52
|
+
bottom: var(--odn-virtual-list-scrollbar-side-hover-padding);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.odn-virtual-list-scrollbar-thumb {
|
|
56
|
+
background-color: var(--odn-virtual-list-scrollbar-color) !important;
|
|
57
|
+
border-radius: var(--odn-virtual-list-scrollbar-radius) !important;
|
|
58
|
+
}
|
|
59
|
+
.odn-virtual-list-scrollbar-thumb.odn-virtual-list-scrollbar-thumb-moving {
|
|
60
|
+
background-color: var(--odn-virtual-list-scrollbar-hover-color) !important;
|
|
7
61
|
}
|