@lobehub/ui 2.15.0 → 2.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/DraggablePanel/DraggablePanel.js +6 -0
- package/es/DraggablePanel/style.d.ts +1 -0
- package/es/DraggablePanel/style.js +11 -11
- package/es/DraggablePanel/type.d.ts +1 -0
- package/es/DraggableSideNav/DraggableSideNav.js +137 -109
- package/es/DraggableSideNav/style.d.ts +1 -0
- package/es/DraggableSideNav/style.js +10 -10
- package/es/DraggableSideNav/type.d.ts +33 -26
- package/package.json +1 -1
|
@@ -55,6 +55,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
55
55
|
showHandleHighlight = _ref$showHandleHighli === void 0 ? false : _ref$showHandleHighli,
|
|
56
56
|
_ref$showHandleWideAr = _ref.showHandleWideArea,
|
|
57
57
|
showHandleWideArea = _ref$showHandleWideAr === void 0 ? DEFAULT_SHOW_HANDLE_WIDE_AREA : _ref$showHandleWideAr,
|
|
58
|
+
backgroundColor = _ref.backgroundColor,
|
|
58
59
|
size = _ref.size,
|
|
59
60
|
customizeDefaultSize = _ref.defaultSize,
|
|
60
61
|
minWidth = _ref.minWidth,
|
|
@@ -88,6 +89,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
88
89
|
return direction === 'rtl' && ['left', 'right'].includes(placement) ? placement === 'left' ? 'right' : 'left' : placement;
|
|
89
90
|
}, [direction, placement]);
|
|
90
91
|
var _useStyles = useStyles({
|
|
92
|
+
backgroundColor: backgroundColor,
|
|
91
93
|
headerHeight: headerHeight,
|
|
92
94
|
showBorder: showBorder,
|
|
93
95
|
showHandleWideArea: showHandleWideArea
|
|
@@ -282,6 +284,10 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
282
284
|
icon: Arrow,
|
|
283
285
|
size: 16,
|
|
284
286
|
style: {
|
|
287
|
+
marginBottom: internalPlacement === 'top' ? 4 : 0,
|
|
288
|
+
marginLeft: internalPlacement === 'right' ? 4 : 0,
|
|
289
|
+
marginRight: internalPlacement === 'left' ? 4 : 0,
|
|
290
|
+
marginTop: internalPlacement === 'bottom' ? 4 : 0,
|
|
285
291
|
transform: "rotate(".concat(isExpand ? 180 : 0, "deg)")
|
|
286
292
|
}
|
|
287
293
|
})
|
|
@@ -11,14 +11,14 @@ import { createStyles, css, cx } from 'antd-style';
|
|
|
11
11
|
// Layout constants
|
|
12
12
|
var LAYOUT = {
|
|
13
13
|
offset: 16,
|
|
14
|
-
toggleLength:
|
|
14
|
+
toggleLength: 54,
|
|
15
15
|
toggleShort: 16
|
|
16
16
|
};
|
|
17
17
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
18
18
|
var prefixCls = _ref.prefixCls,
|
|
19
|
-
token = _ref.token
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
token = _ref.token;
|
|
20
|
+
var backgroundColor = _ref2.backgroundColor,
|
|
21
|
+
headerHeight = _ref2.headerHeight,
|
|
22
22
|
showBorder = _ref2.showBorder,
|
|
23
23
|
showHandleWideArea = _ref2.showHandleWideArea;
|
|
24
24
|
var prefix = "".concat(prefixCls, "-draggable-panel");
|
|
@@ -41,7 +41,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// Handle styles
|
|
44
|
-
var handleBaseStyle = css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n\n &::before {\n content: '';\n position: absolute;\n
|
|
44
|
+
var handleBaseStyle = css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n\n &::before {\n content: '';\n position: absolute;\n transition: all 0.2s ", ";\n }\n "])), token.motionEaseOut);
|
|
45
45
|
var handleHighlightStyle = css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n &:hover {\n &::before {\n background: ", ";\n box-shadow: 0 0 8px ", "40;\n }\n }\n\n &:active {\n &::before {\n background: ", " !important;\n }\n }\n "])), token.colorPrimary, token.colorPrimary, token.colorPrimary);
|
|
46
46
|
var handleStyles = {
|
|
47
47
|
handleBottom: cx("".concat(prefix, "-bottom-handle"), css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n &::before {\n inset-block-end: 50%;\n width: 100%;\n height: 2px;\n }\n "])))),
|
|
@@ -52,13 +52,13 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// Toggle styles
|
|
55
|
-
var toggleBaseStyle = cx("".concat(prefix, "-toggle"), css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n pointer-events: ", ";\n\n position: absolute;\n z-index:
|
|
55
|
+
var toggleBaseStyle = cx("".concat(prefix, "-toggle"), css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n pointer-events: ", ";\n\n position: absolute;\n z-index: 50;\n\n opacity: 0;\n\n transition: all 0.2s ", ";\n\n &:hover,\n &:active {\n opacity: 1 !important;\n }\n\n > div {\n pointer-events: all;\n cursor: pointer;\n\n position: absolute;\n\n border: 1px solid ", ";\n\n color: ", ";\n\n background: ", ";\n backdrop-filter: blur(8px);\n\n transition: all 0.2s ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n "])), showHandleWideArea ? 'all' : 'none', token.motionEaseOut, token.colorBorder, token.colorTextTertiary, backgroundColor || token.colorBgLayout, token.motionEaseOut, token.colorTextSecondary, token.colorText));
|
|
56
56
|
var toggleStyles = {
|
|
57
|
-
toggleBottom: cx("".concat(prefix, "-toggle-bottom"), css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n inset-block-end: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n inset-inline-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-inline-start: -
|
|
58
|
-
toggleLeft: cx("".concat(prefix, "-toggle-left"), css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n inset-inline-start: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -
|
|
59
|
-
toggleRight: cx("".concat(prefix, "-toggle-right"), css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n inset-inline-end: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -
|
|
57
|
+
toggleBottom: cx("".concat(prefix, "-toggle-bottom"), css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n inset-block-end: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n inset-inline-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-inline-start: -27px;\n border-block-start-width: 0;\n border-radius: 0 0 ", "px ", "px;\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleLength, LAYOUT.toggleShort, token.borderRadiusLG, token.borderRadiusLG)),
|
|
58
|
+
toggleLeft: cx("".concat(prefix, "-toggle-left"), css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n inset-inline-start: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -27px;\n border-inline-end-width: 0;\n border-radius: ", "px 0 0 ", "px;\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleShort, LAYOUT.toggleLength, token.borderRadiusLG, token.borderRadiusLG)),
|
|
59
|
+
toggleRight: cx("".concat(prefix, "-toggle-right"), css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n inset-inline-end: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -27px;\n border-inline-start-width: 0;\n border-radius: 0 ", "px ", "px 0;\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleShort, LAYOUT.toggleLength, token.borderRadiusLG, token.borderRadiusLG)),
|
|
60
60
|
toggleRoot: toggleBaseStyle,
|
|
61
|
-
toggleTop: cx("".concat(prefix, "-toggle-top"), css(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n inset-block-start: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n inset-inline-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-inline-start: -
|
|
61
|
+
toggleTop: cx("".concat(prefix, "-toggle-top"), css(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n inset-block-start: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n inset-inline-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-inline-start: -27px;\n border-block-end-width: 0;\n border-radius: ", "px ", "px 0 0;\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleLength, LAYOUT.toggleShort, token.borderRadiusLG, token.borderRadiusLG))
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// Additional component styles
|
|
@@ -66,7 +66,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
66
66
|
fixed: css(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n position: relative;\n "]))),
|
|
67
67
|
fullscreen: css(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n position: absolute;\n inset-block: ", "px 0;\n inset-inline: 0;\n\n width: 100%;\n height: calc(100% - ", "px);\n\n background: ", ";\n "])), headerHeight, headerHeight, token.colorBgContainerSecondary),
|
|
68
68
|
handlerIcon: css(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n transition: all 0.2s ", ";\n "])), token.motionEaseOut),
|
|
69
|
-
panel: cx("".concat(prefix, "-fixed"), css(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n overflow: hidden;\n transition: all 0.2s ", ";\n "])), token.motionEaseOut)),
|
|
69
|
+
panel: cx("".concat(prefix, "-fixed"), css(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n overflow: hidden;\n background: ", ";\n transition: all 0.2s ", ";\n "])), backgroundColor || token.colorBgLayout, token.motionEaseOut)),
|
|
70
70
|
root: cx(prefix, css(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n border: 0 solid ", ";\n\n &:hover {\n > .", "-toggle {\n opacity: 1;\n }\n }\n "])), token.colorBorderSecondary, prefix))
|
|
71
71
|
};
|
|
72
72
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, borderStyles), floatPositions), handleStyles), {}, {
|
|
@@ -4,6 +4,7 @@ import type { Props as RndProps } from 'react-rnd';
|
|
|
4
4
|
import type { DivProps } from "../types";
|
|
5
5
|
type PlacementType = 'right' | 'left' | 'top' | 'bottom';
|
|
6
6
|
export interface DraggablePanelProps extends DivProps {
|
|
7
|
+
backgroundColor?: string;
|
|
7
8
|
classNames?: {
|
|
8
9
|
content?: string;
|
|
9
10
|
handle?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
var _excluded = ["animation", "children", "className", "classNames", "
|
|
4
|
+
var _excluded = ["animation", "children", "className", "classNames", "defaultExpand", "defaultWidth", "expand", "expandable", "footer", "header", "maxWidth", "minWidth", "onExpandChange", "onWidthChange", "onWidthDragging", "placement", "resizable", "showBorder", "showHandle", "showHandleWhenCollapsed", "showHandleHighlight", "backgroundColor", "styles", "width"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -27,7 +27,7 @@ import { useStyles } from "./style";
|
|
|
27
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
29
|
var DEFAULT_MIN_WIDTH = 64; // 最小宽度即折叠宽度
|
|
30
|
-
var
|
|
30
|
+
var DEFAULT_EXPAND = true;
|
|
31
31
|
var DEFAULT_EXPANDED_WIDTH = 280;
|
|
32
32
|
|
|
33
33
|
// Animation variants generator based on fade and blur settings
|
|
@@ -62,8 +62,8 @@ var getAnimationVariants = function getAnimationVariants(fade, blur) {
|
|
|
62
62
|
var AnimationWrapper = /*#__PURE__*/memo(function (_ref) {
|
|
63
63
|
var blur = _ref.blur,
|
|
64
64
|
children = _ref.children,
|
|
65
|
-
collapsed = _ref.collapsed,
|
|
66
65
|
enabled = _ref.enabled,
|
|
66
|
+
expand = _ref.expand,
|
|
67
67
|
fade = _ref.fade,
|
|
68
68
|
id = _ref.id;
|
|
69
69
|
if (!enabled) return children;
|
|
@@ -77,7 +77,7 @@ var AnimationWrapper = /*#__PURE__*/memo(function (_ref) {
|
|
|
77
77
|
initial: "exit",
|
|
78
78
|
variants: variants,
|
|
79
79
|
children: children
|
|
80
|
-
}, "".concat(id, "-").concat(
|
|
80
|
+
}, "".concat(id, "-").concat(expand ? 'expanded' : 'collapsed'))
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
AnimationWrapper.displayName = 'AnimationWrapper';
|
|
@@ -87,18 +87,20 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
87
87
|
children = _ref2.children,
|
|
88
88
|
className = _ref2.className,
|
|
89
89
|
classNames = _ref2.classNames,
|
|
90
|
-
|
|
91
|
-
_ref2$
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
_ref2$defaultExpand = _ref2.defaultExpand,
|
|
91
|
+
defaultExpand = _ref2$defaultExpand === void 0 ? DEFAULT_EXPAND : _ref2$defaultExpand,
|
|
92
|
+
defaultWidth = _ref2.defaultWidth,
|
|
93
|
+
expand = _ref2.expand,
|
|
94
|
+
_ref2$expandable = _ref2.expandable,
|
|
95
|
+
expandable = _ref2$expandable === void 0 ? true : _ref2$expandable,
|
|
94
96
|
footer = _ref2.footer,
|
|
95
97
|
header = _ref2.header,
|
|
96
98
|
maxWidth = _ref2.maxWidth,
|
|
97
99
|
_ref2$minWidth = _ref2.minWidth,
|
|
98
100
|
minWidth = _ref2$minWidth === void 0 ? DEFAULT_MIN_WIDTH : _ref2$minWidth,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
onExpandChange = _ref2.onExpandChange,
|
|
102
|
+
onWidthChange = _ref2.onWidthChange,
|
|
103
|
+
onWidthDragging = _ref2.onWidthDragging,
|
|
102
104
|
_ref2$placement = _ref2.placement,
|
|
103
105
|
placement = _ref2$placement === void 0 ? 'left' : _ref2$placement,
|
|
104
106
|
_ref2$resizable = _ref2.resizable,
|
|
@@ -111,23 +113,27 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
111
113
|
showHandleWhenCollapsed = _ref2$showHandleWhenC === void 0 ? false : _ref2$showHandleWhenC,
|
|
112
114
|
_ref2$showHandleHighl = _ref2.showHandleHighlight,
|
|
113
115
|
showHandleHighlight = _ref2$showHandleHighl === void 0 ? false : _ref2$showHandleHighl,
|
|
114
|
-
|
|
116
|
+
backgroundColor = _ref2.backgroundColor,
|
|
115
117
|
customStyles = _ref2.styles,
|
|
118
|
+
width = _ref2.width,
|
|
116
119
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
117
120
|
var _useStyles = useStyles({
|
|
121
|
+
backgroundColor: backgroundColor,
|
|
118
122
|
showBorder: showBorder
|
|
119
123
|
}),
|
|
120
124
|
styles = _useStyles.styles,
|
|
121
125
|
cx = _useStyles.cx;
|
|
122
126
|
var ref = useRef(null);
|
|
123
127
|
var isHovering = useHover(ref);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
|
|
129
|
+
// Expand state management
|
|
130
|
+
var _useControlledState = useControlledState(defaultExpand, {
|
|
131
|
+
onChange: onExpandChange,
|
|
132
|
+
value: expand
|
|
127
133
|
}),
|
|
128
134
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
isExpand = _useControlledState2[0],
|
|
136
|
+
setIsExpand = _useControlledState2[1];
|
|
131
137
|
var _useState = useState(false),
|
|
132
138
|
_useState2 = _slicedToArray(_useState, 2),
|
|
133
139
|
isResizing = _useState2[0],
|
|
@@ -137,33 +143,37 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
137
143
|
isAnimating = _useState4[0],
|
|
138
144
|
setIsAnimating = _useState4[1];
|
|
139
145
|
|
|
146
|
+
// Compute default expanded width
|
|
147
|
+
var computedDefaultExpandedWidth = defaultWidth || DEFAULT_EXPANDED_WIDTH;
|
|
148
|
+
|
|
140
149
|
// 内部宽度状态,用于平滑动画
|
|
141
|
-
var _useState5 = useState(
|
|
150
|
+
var _useState5 = useState(isExpand ? width !== null && width !== void 0 ? width : computedDefaultExpandedWidth : minWidth),
|
|
142
151
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
143
152
|
internalWidth = _useState6[0],
|
|
144
153
|
setInternalWidth = _useState6[1];
|
|
145
154
|
|
|
146
155
|
// 记住展开时的宽度
|
|
147
|
-
var _useState7 = useState(
|
|
156
|
+
var _useState7 = useState(width !== null && width !== void 0 ? width : computedDefaultExpandedWidth),
|
|
148
157
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
149
158
|
expandedWidth = _useState8[0],
|
|
150
159
|
setExpandedWidth = _useState8[1];
|
|
151
160
|
|
|
152
|
-
// 用于渲染的
|
|
153
|
-
var _useState9 = useState(
|
|
161
|
+
// 用于渲染的 expand 状态 - 延迟切换以匹配动画时机
|
|
162
|
+
var _useState9 = useState(isExpand),
|
|
154
163
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
renderExpand = _useState10[0],
|
|
165
|
+
setRenderExpand = _useState10[1];
|
|
157
166
|
|
|
158
167
|
// 计算折叠阈值:展开最小宽度和折叠宽度的中间值
|
|
159
168
|
var collapseThreshold = useMemo(function () {
|
|
160
169
|
return minWidth + (expandedWidth - minWidth) / 3;
|
|
161
170
|
}, [minWidth, expandedWidth]);
|
|
162
171
|
|
|
163
|
-
// Toggle
|
|
164
|
-
var
|
|
172
|
+
// Toggle expand state with smooth animation
|
|
173
|
+
var toggleExpand = function toggleExpand() {
|
|
174
|
+
if (!expandable) return;
|
|
165
175
|
setIsAnimating(true);
|
|
166
|
-
|
|
176
|
+
setIsExpand(!isExpand);
|
|
167
177
|
|
|
168
178
|
// 动画完成后重置状态 - 与宽度动画时长一致
|
|
169
179
|
setTimeout(function () {
|
|
@@ -171,67 +181,78 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
171
181
|
}, 400);
|
|
172
182
|
};
|
|
173
183
|
|
|
174
|
-
//
|
|
184
|
+
// 用于跟踪上一次的 expand 状态,以检测外部变化
|
|
185
|
+
var prevExpandRef = useRef(isExpand);
|
|
186
|
+
|
|
187
|
+
// 监听外部 expand prop 变化,触发动画
|
|
188
|
+
useEffect(function () {
|
|
189
|
+
// 检测到 expand 状态变化,且不在拖拽和动画中
|
|
190
|
+
if (prevExpandRef.current !== isExpand && !isResizing && !isAnimating) {
|
|
191
|
+
setIsAnimating(true);
|
|
192
|
+
setTimeout(function () {
|
|
193
|
+
setIsAnimating(false);
|
|
194
|
+
}, 400);
|
|
195
|
+
}
|
|
196
|
+
prevExpandRef.current = isExpand;
|
|
197
|
+
}, [isExpand, isResizing, isAnimating]);
|
|
198
|
+
|
|
199
|
+
// 处理展开/折叠状态变化时的宽度动画和内容切换时机
|
|
175
200
|
useEffect(function () {
|
|
176
201
|
if (isAnimating) {
|
|
177
202
|
// 使用 requestAnimationFrame 确保动画平滑
|
|
178
203
|
requestAnimationFrame(function () {
|
|
179
|
-
if (
|
|
180
|
-
|
|
204
|
+
if (isExpand) {
|
|
205
|
+
// 展开动画:立即切换内容(先切换内容,再开始宽度动画)
|
|
206
|
+
setRenderExpand(true);
|
|
207
|
+
setInternalWidth(expandedWidth);
|
|
208
|
+
} else {
|
|
181
209
|
// 折叠动画:延迟切换内容,在动画接近结束时才切换(300ms,略早于动画结束)
|
|
210
|
+
setInternalWidth(minWidth);
|
|
182
211
|
setTimeout(function () {
|
|
183
|
-
|
|
212
|
+
setRenderExpand(false);
|
|
184
213
|
}, 300);
|
|
185
|
-
} else {
|
|
186
|
-
// 展开动画:立即切换内容(先切换内容,再开始宽度动画)
|
|
187
|
-
setRenderCollapsed(false);
|
|
188
|
-
setInternalWidth(expandedWidth);
|
|
189
214
|
}
|
|
190
215
|
});
|
|
191
216
|
}
|
|
192
|
-
}, [
|
|
217
|
+
}, [isExpand, isAnimating, minWidth, expandedWidth]);
|
|
193
218
|
|
|
194
|
-
// 同步非动画期间的
|
|
219
|
+
// 同步非动画期间的 renderExpand 状态(如拖拽)
|
|
195
220
|
useEffect(function () {
|
|
196
221
|
if (!isAnimating && !isResizing) {
|
|
197
|
-
|
|
222
|
+
setRenderExpand(isExpand);
|
|
198
223
|
}
|
|
199
|
-
}, [
|
|
224
|
+
}, [isExpand, isAnimating, isResizing]);
|
|
200
225
|
|
|
201
|
-
// 处理外部
|
|
226
|
+
// 处理外部 width prop 变化
|
|
202
227
|
useEffect(function () {
|
|
203
|
-
if (
|
|
204
|
-
var width = typeof size.width === 'string' ? parseInt(size.width) : size.width;
|
|
228
|
+
if (width !== undefined && !isResizing && !isAnimating) {
|
|
205
229
|
setInternalWidth(width);
|
|
206
|
-
if (
|
|
230
|
+
if (isExpand) {
|
|
207
231
|
setExpandedWidth(width);
|
|
208
232
|
}
|
|
209
233
|
}
|
|
210
|
-
}, [
|
|
234
|
+
}, [width, isResizing, isAnimating, isExpand]);
|
|
211
235
|
|
|
212
|
-
// 计算当前的 children(支持函数和静态值)- 使用
|
|
236
|
+
// 计算当前的 children(支持函数和静态值)- 使用 renderExpand
|
|
213
237
|
var currentChildren = useMemo(function () {
|
|
214
|
-
return typeof children === 'function' ? children(
|
|
215
|
-
}, [children,
|
|
238
|
+
return typeof children === 'function' ? children(renderExpand) : children;
|
|
239
|
+
}, [children, renderExpand]);
|
|
216
240
|
|
|
217
|
-
// 计算当前的 header(支持函数和静态值)- 使用
|
|
241
|
+
// 计算当前的 header(支持函数和静态值)- 使用 renderExpand
|
|
218
242
|
var currentHeader = useMemo(function () {
|
|
219
|
-
return typeof header === 'function' ? header(
|
|
220
|
-
}, [header,
|
|
243
|
+
return typeof header === 'function' ? header(renderExpand) : header;
|
|
244
|
+
}, [header, renderExpand]);
|
|
221
245
|
|
|
222
|
-
// 计算当前的 footer(支持函数和静态值)- 使用
|
|
246
|
+
// 计算当前的 footer(支持函数和静态值)- 使用 renderExpand
|
|
223
247
|
var currentFooter = useMemo(function () {
|
|
224
|
-
return typeof footer === 'function' ? footer(
|
|
225
|
-
}, [footer,
|
|
248
|
+
return typeof footer === 'function' ? footer(renderExpand) : footer;
|
|
249
|
+
}, [footer, renderExpand]);
|
|
226
250
|
|
|
227
251
|
// Handle resize
|
|
228
252
|
var handleResize = function handleResize(_, _direction, reference_, delta) {
|
|
229
253
|
var currentWidth = reference_.offsetWidth;
|
|
230
254
|
setInternalWidth(currentWidth);
|
|
231
|
-
|
|
232
|
-
height: reference_.style.height,
|
|
233
|
-
width: reference_.style.width
|
|
234
|
-
});
|
|
255
|
+
onWidthDragging === null || onWidthDragging === void 0 || onWidthDragging(delta, currentWidth);
|
|
235
256
|
};
|
|
236
257
|
var handleResizeStart = function handleResizeStart() {
|
|
237
258
|
setIsResizing(true);
|
|
@@ -241,56 +262,59 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
241
262
|
var currentWidth = reference_.offsetWidth;
|
|
242
263
|
|
|
243
264
|
// 根据拖拽后的宽度决定是折叠还是展开
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
if (expandable) {
|
|
266
|
+
if (currentWidth <= minWidth) {
|
|
267
|
+
// 拖拽到最小宽度,保持折叠
|
|
268
|
+
setIsAnimating(true);
|
|
269
|
+
setIsExpand(false);
|
|
270
|
+
setInternalWidth(minWidth);
|
|
271
|
+
setTimeout(function () {
|
|
272
|
+
return setIsAnimating(false);
|
|
273
|
+
}, 400);
|
|
274
|
+
} else if (currentWidth < collapseThreshold) {
|
|
275
|
+
// 拖拽到阈值以下,自动折叠
|
|
276
|
+
setIsAnimating(true);
|
|
277
|
+
setIsExpand(false);
|
|
278
|
+
setInternalWidth(minWidth);
|
|
279
|
+
setTimeout(function () {
|
|
280
|
+
return setIsAnimating(false);
|
|
281
|
+
}, 400);
|
|
282
|
+
} else if (!isExpand && currentWidth > minWidth) {
|
|
283
|
+
// 从折叠状态拖拽出来,自动展开
|
|
284
|
+
setIsAnimating(true);
|
|
285
|
+
setIsExpand(true);
|
|
286
|
+
setExpandedWidth(currentWidth);
|
|
287
|
+
setInternalWidth(currentWidth);
|
|
288
|
+
setTimeout(function () {
|
|
289
|
+
return setIsAnimating(false);
|
|
290
|
+
}, 400);
|
|
291
|
+
} else if (isExpand) {
|
|
292
|
+
// 展开状态下正常拖拽,记住宽度
|
|
293
|
+
setExpandedWidth(currentWidth);
|
|
294
|
+
setInternalWidth(currentWidth);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
// 如果不可折叠,仅更新宽度
|
|
271
298
|
setExpandedWidth(currentWidth);
|
|
272
299
|
setInternalWidth(currentWidth);
|
|
273
300
|
}
|
|
274
|
-
|
|
275
|
-
height: reference_.style.height,
|
|
276
|
-
width: reference_.style.width
|
|
277
|
-
});
|
|
301
|
+
onWidthChange === null || onWidthChange === void 0 || onWidthChange(delta, currentWidth);
|
|
278
302
|
};
|
|
279
303
|
|
|
280
|
-
// Arrow icon based on placement and
|
|
304
|
+
// Arrow icon based on placement and expand state
|
|
281
305
|
var ArrowIcon = useMemo(function () {
|
|
282
306
|
if (placement === 'left') {
|
|
283
|
-
//
|
|
307
|
+
// 左侧:展开时箭头向左(折叠方向),折叠时箭头向右(展开方向)
|
|
284
308
|
return ChevronLeft;
|
|
285
309
|
}
|
|
286
|
-
//
|
|
310
|
+
// 右侧:展开时箭头向右(折叠方向),折叠时箭头向左(展开方向)
|
|
287
311
|
return ChevronRight;
|
|
288
312
|
}, [placement]);
|
|
289
313
|
|
|
290
314
|
// Toggle handle with smooth transitions
|
|
291
|
-
var handle = showHandle && /*#__PURE__*/_jsx(motion.div, {
|
|
315
|
+
var handle = showHandle && expandable && /*#__PURE__*/_jsx(motion.div, {
|
|
292
316
|
animate: {
|
|
293
|
-
opacity:
|
|
317
|
+
opacity: !isExpand && showHandleWhenCollapsed ? 1 : isHovering ? 1 : 0,
|
|
294
318
|
scale: isHovering ? 1.05 : 1
|
|
295
319
|
},
|
|
296
320
|
className: cx(styles.toggleRoot, placement === 'left' ? styles.toggleLeft : styles.toggleRight),
|
|
@@ -303,14 +327,18 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
303
327
|
},
|
|
304
328
|
children: /*#__PURE__*/_jsx(Center, {
|
|
305
329
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.handle,
|
|
306
|
-
onClick:
|
|
330
|
+
onClick: toggleExpand,
|
|
307
331
|
style: _objectSpread(_objectSpread({}, customStyles === null || customStyles === void 0 ? void 0 : customStyles.handle), {}, {
|
|
308
332
|
cursor: 'pointer',
|
|
309
333
|
transition: 'transform 0.2s ease-out'
|
|
310
334
|
}),
|
|
311
335
|
children: /*#__PURE__*/_jsx(motion.div, {
|
|
312
336
|
animate: {
|
|
313
|
-
rotate:
|
|
337
|
+
rotate: isExpand ? 0 : 180
|
|
338
|
+
},
|
|
339
|
+
style: {
|
|
340
|
+
marginLeft: placement === 'right' ? 4 : 0,
|
|
341
|
+
marginRight: placement === 'left' ? 4 : 0
|
|
314
342
|
},
|
|
315
343
|
transition: {
|
|
316
344
|
duration: 0.3,
|
|
@@ -381,33 +409,33 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
|
|
|
381
409
|
children: [currentHeader && /*#__PURE__*/_jsx("div", {
|
|
382
410
|
className: cx(styles.header, classNames === null || classNames === void 0 ? void 0 : classNames.header),
|
|
383
411
|
style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.header,
|
|
384
|
-
children: /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
385
|
-
blur: (_animation$blur = animation
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
fade: (_animation$fade = animation
|
|
412
|
+
children: animation === false || animation === undefined ? currentHeader : /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
413
|
+
blur: (_animation$blur = animation.blur) !== null && _animation$blur !== void 0 ? _animation$blur : false,
|
|
414
|
+
enabled: animation.header,
|
|
415
|
+
expand: renderExpand,
|
|
416
|
+
fade: (_animation$fade = animation.fade) !== null && _animation$fade !== void 0 ? _animation$fade : true,
|
|
389
417
|
id: "header",
|
|
390
418
|
children: currentHeader
|
|
391
419
|
})
|
|
392
420
|
}), /*#__PURE__*/_jsx("div", {
|
|
393
421
|
className: cx(styles.body, classNames === null || classNames === void 0 ? void 0 : classNames.body),
|
|
394
422
|
style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.body,
|
|
395
|
-
children: /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
396
|
-
blur: (_animation$blur2 = animation
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
fade: (_animation$fade2 = animation
|
|
423
|
+
children: animation === false || animation === undefined ? currentChildren : /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
424
|
+
blur: (_animation$blur2 = animation.blur) !== null && _animation$blur2 !== void 0 ? _animation$blur2 : false,
|
|
425
|
+
enabled: animation.body,
|
|
426
|
+
expand: renderExpand,
|
|
427
|
+
fade: (_animation$fade2 = animation.fade) !== null && _animation$fade2 !== void 0 ? _animation$fade2 : true,
|
|
400
428
|
id: "body",
|
|
401
429
|
children: currentChildren
|
|
402
430
|
})
|
|
403
431
|
}), currentFooter && /*#__PURE__*/_jsx("div", {
|
|
404
432
|
className: cx(styles.footer, classNames === null || classNames === void 0 ? void 0 : classNames.footer),
|
|
405
433
|
style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.footer,
|
|
406
|
-
children: /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
407
|
-
blur: (_animation$blur3 = animation
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
fade: (_animation$fade3 = animation
|
|
434
|
+
children: animation === false || animation === undefined ? currentFooter : /*#__PURE__*/_jsx(AnimationWrapper, {
|
|
435
|
+
blur: (_animation$blur3 = animation.blur) !== null && _animation$blur3 !== void 0 ? _animation$blur3 : false,
|
|
436
|
+
enabled: animation.footer,
|
|
437
|
+
expand: renderExpand,
|
|
438
|
+
fade: (_animation$fade3 = animation.fade) !== null && _animation$fade3 !== void 0 ? _animation$fade3 : true,
|
|
411
439
|
id: "footer",
|
|
412
440
|
children: currentFooter
|
|
413
441
|
})
|
|
@@ -5,29 +5,29 @@ import { createStyles } from 'antd-style';
|
|
|
5
5
|
// Layout constants (aligned with DraggablePanel)
|
|
6
6
|
var LAYOUT = {
|
|
7
7
|
offset: 16,
|
|
8
|
-
toggleLength:
|
|
8
|
+
toggleLength: 54,
|
|
9
9
|
toggleShort: 16
|
|
10
10
|
};
|
|
11
11
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
12
12
|
var css = _ref.css,
|
|
13
13
|
token = _ref.token,
|
|
14
|
-
stylish = _ref.stylish,
|
|
15
14
|
prefixCls = _ref.prefixCls;
|
|
16
|
-
var showBorder = _ref2.showBorder
|
|
15
|
+
var showBorder = _ref2.showBorder,
|
|
16
|
+
backgroundColor = _ref2.backgroundColor;
|
|
17
17
|
return {
|
|
18
|
-
body: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
19
|
-
container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n
|
|
20
|
-
contentContainer: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: flex;\n flex-direction: column;\n\n height: 100%;\n border-inline-end: ", " solid ", ";\n\n background: ", ";\n "])), showBorder ? '1px' : '0', token.colorBorderSecondary, token.colorBgLayout),
|
|
18
|
+
body: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* Smooth scroll behavior */\n scroll-behavior: smooth;\n overflow: hidden auto;\n flex: 1;\n\n /* Better scrollbar styling */\n &::-webkit-scrollbar {\n width: 6px;\n }\n\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n\n &::-webkit-scrollbar-thumb {\n border-radius: 3px;\n background: ", ";\n\n &:hover {\n background: ", ";\n }\n }\n "])), token.colorBorderSecondary, token.colorBorder),
|
|
19
|
+
container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /* Width transition controlled by inline style */\n\n /* Ensure smooth animations */\n will-change: width;\n\n position: relative;\n\n display: flex;\n flex-direction: column;\n\n height: 100%;\n "]))),
|
|
20
|
+
contentContainer: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: flex;\n flex-direction: column;\n\n height: 100%;\n border-inline-end: ", " solid ", ";\n\n background: ", ";\n "])), showBorder ? '1px' : '0', token.colorBorderSecondary, backgroundColor || token.colorBgLayout),
|
|
21
21
|
footer: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n "]))),
|
|
22
22
|
handlerIcon: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n /* Icon transitions are now handled by framer-motion */\n display: flex;\n align-items: center;\n justify-content: center;\n "]))),
|
|
23
23
|
header: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n "]))),
|
|
24
24
|
menuOverride: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .", "-menu {\n .", "-menu-item {\n display: flex;\n gap: 8px;\n align-items: center;\n justify-content: center;\n\n height: unset;\n min-height: 36px;\n padding-block: 4px;\n padding-inline: 8px !important;\n }\n\n .", "-menu-item-group-title {\n overflow: hidden;\n padding-inline: 8px;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .", "-menu-item-icon {\n position: absolute;\n inset-inline-start: 0;\n\n display: flex !important;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: 36px;\n height: 36px;\n }\n\n .", "-menu-title-content {\n overflow: hidden;\n flex: 1;\n\n margin: 0 !important;\n padding-inline-start: 36px;\n\n line-height: 1.5;\n }\n\n &.", "-menu-inline-collapsed {\n .ant-menu-title-content {\n display: none;\n width: 0;\n opacity: 0;\n }\n\n .", "-menu-item {\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 36px !important;\n height: 36px !important;\n }\n }\n }\n "])), prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls),
|
|
25
|
-
resizeHandle: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n cursor: col-resize;\n\n position: absolute;\n
|
|
25
|
+
resizeHandle: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n cursor: col-resize;\n\n position: absolute;\n inset-block: 0 0;\n\n width: 8px;\n\n transition: background-color 0.2s ease;\n\n &::after {\n content: '';\n\n position: absolute;\n inset-block: 0;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n width: 2px;\n\n background: transparent;\n\n transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);\n }\n "]))),
|
|
26
26
|
resizeHandleHighlight: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n &:hover {\n &::after {\n width: 3px;\n background: ", ";\n box-shadow: 0 0 8px ", "40;\n }\n }\n\n &:active {\n &::after {\n background: ", ";\n }\n }\n "])), token.colorPrimary, token.colorPrimary, token.colorPrimaryActive),
|
|
27
27
|
resizeHandleLeft: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n inset-inline-end: -4px;\n "]))),
|
|
28
28
|
resizeHandleRight: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n inset-inline-start: -4px;\n "]))),
|
|
29
|
-
toggleLeft: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n inset-inline-end: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -", "px;\n border-radius: 0
|
|
30
|
-
toggleRight: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n inset-inline-start: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -", "px;\n border-radius:
|
|
31
|
-
toggleRoot: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n pointer-events: none;\n position: absolute;\n\n /* Smooth transitions for all states */\n transition: opacity 0.25s cubic-bezier(0.22, 1, 0.36, 1);\n\n &:has(> div) {\n pointer-events: all;\n }\n\n > div {\n
|
|
29
|
+
toggleLeft: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n inset-inline-end: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -", "px;\n border-inline-start-width: 0;\n border-radius: 0 ", "px ", "px 0;\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleShort, LAYOUT.toggleLength, LAYOUT.toggleLength / 2, token.borderRadiusLG, token.borderRadiusLG),
|
|
30
|
+
toggleRight: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n inset-inline-start: -", "px;\n width: ", "px;\n height: 100%;\n\n > div {\n inset-block-start: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-block-start: -", "px;\n border-inline-end-width: 0;\n border-radius: ", "px 0 0 ", "px; /* \u53F3\u4FA7\u9762\u677F\uFF0Chandle \u5728\u5DE6\u8FB9\uFF0C\u5DE6\u4FA7\u5706\u89D2 */\n }\n "])), LAYOUT.offset, LAYOUT.toggleShort, LAYOUT.toggleShort, LAYOUT.toggleLength, LAYOUT.toggleLength / 2, token.borderRadiusLG, token.borderRadiusLG),
|
|
31
|
+
toggleRoot: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n pointer-events: none;\n position: absolute;\n z-index: 50;\n\n /* Smooth transitions for all states */\n transition: opacity 0.25s cubic-bezier(0.22, 1, 0.36, 1);\n\n &:has(> div) {\n pointer-events: all;\n }\n\n > div {\n pointer-events: all;\n cursor: pointer;\n\n position: absolute;\n\n border: 1px solid ", ";\n\n color: ", ";\n\n background: ", ";\n backdrop-filter: blur(8px);\n\n /* Enhanced transitions with backdrop blur */\n transition:\n color 0.2s ", ",\n transform 0.2s ", ",\n box-shadow 0.2s ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n transform: scale(0.95);\n color: ", ";\n }\n }\n "])), token.colorBorder, token.colorTextTertiary, backgroundColor || token.colorBgLayout, token.motionEaseOut, token.motionEaseOut, token.motionEaseOut, token.colorTextSecondary, token.colorText)
|
|
32
32
|
};
|
|
33
33
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { NumberSize
|
|
1
|
+
import type { NumberSize } from 're-resizable';
|
|
2
2
|
import type { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
import type { DivProps } from "../types";
|
|
4
4
|
export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSelect'> {
|
|
5
5
|
/**
|
|
6
6
|
* Animation configuration for content transitions
|
|
7
|
-
*
|
|
7
|
+
* Set to false to disable all animations
|
|
8
|
+
* @default undefined
|
|
8
9
|
*/
|
|
9
|
-
animation?: {
|
|
10
|
+
animation?: false | {
|
|
10
11
|
/**
|
|
11
12
|
* Enable blur effect during transitions
|
|
12
13
|
* @default false
|
|
@@ -33,11 +34,12 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
|
|
|
33
34
|
*/
|
|
34
35
|
header?: boolean;
|
|
35
36
|
};
|
|
37
|
+
backgroundColor?: string;
|
|
36
38
|
/**
|
|
37
39
|
* Body content (main content area)
|
|
38
|
-
* Can be a static element or a function that receives
|
|
40
|
+
* Can be a static element or a function that receives expand state
|
|
39
41
|
*/
|
|
40
|
-
children: ReactNode | ((
|
|
42
|
+
children: ReactNode | ((expand: boolean) => ReactNode);
|
|
41
43
|
/**
|
|
42
44
|
* Classnames for internal components
|
|
43
45
|
*/
|
|
@@ -50,28 +52,33 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
|
|
|
50
52
|
header?: string;
|
|
51
53
|
};
|
|
52
54
|
/**
|
|
53
|
-
* Whether the panel is
|
|
55
|
+
* Whether the panel is expanded by default
|
|
56
|
+
* @default true
|
|
54
57
|
*/
|
|
55
|
-
|
|
58
|
+
defaultExpand?: boolean;
|
|
56
59
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @default false
|
|
60
|
+
* Default width (number format)
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
defaultWidth?: number;
|
|
61
63
|
/**
|
|
62
|
-
*
|
|
64
|
+
* Whether the panel is expanded (controlled)
|
|
65
|
+
*/
|
|
66
|
+
expand?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the panel can be expanded/collapsed
|
|
69
|
+
* @default true
|
|
63
70
|
*/
|
|
64
|
-
|
|
71
|
+
expandable?: boolean;
|
|
65
72
|
/**
|
|
66
73
|
* Footer content
|
|
67
|
-
* Can be a static element or a function that receives
|
|
74
|
+
* Can be a static element or a function that receives expand state
|
|
68
75
|
*/
|
|
69
|
-
footer?: ReactNode | ((
|
|
76
|
+
footer?: ReactNode | ((expand: boolean) => ReactNode);
|
|
70
77
|
/**
|
|
71
78
|
* Header content
|
|
72
|
-
* Can be a static element or a function that receives
|
|
79
|
+
* Can be a static element or a function that receives expand state
|
|
73
80
|
*/
|
|
74
|
-
header?: ReactNode | ((
|
|
81
|
+
header?: ReactNode | ((expand: boolean) => ReactNode);
|
|
75
82
|
/**
|
|
76
83
|
* Maximum width
|
|
77
84
|
*/
|
|
@@ -82,21 +89,21 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
|
|
|
82
89
|
*/
|
|
83
90
|
minWidth?: number;
|
|
84
91
|
/**
|
|
85
|
-
* Callback when
|
|
92
|
+
* Callback when expand state changes
|
|
86
93
|
*/
|
|
87
|
-
|
|
94
|
+
onExpandChange?: (expand: boolean) => void;
|
|
88
95
|
/**
|
|
89
96
|
* Callback when menu item is selected
|
|
90
97
|
*/
|
|
91
98
|
onSelect?: (key: string) => void;
|
|
92
99
|
/**
|
|
93
|
-
* Callback when
|
|
100
|
+
* Callback when width changes
|
|
94
101
|
*/
|
|
95
|
-
|
|
102
|
+
onWidthChange?: (delta: NumberSize, width: number) => void;
|
|
96
103
|
/**
|
|
97
|
-
* Callback when actively resizing
|
|
104
|
+
* Callback when actively resizing width
|
|
98
105
|
*/
|
|
99
|
-
|
|
106
|
+
onWidthDragging?: (delta: NumberSize, width: number) => void;
|
|
100
107
|
/**
|
|
101
108
|
* Placement of the side nav
|
|
102
109
|
* @default 'left'
|
|
@@ -123,10 +130,6 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
|
|
|
123
130
|
* @default false
|
|
124
131
|
*/
|
|
125
132
|
showHandleWhenCollapsed?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Current size (controlled)
|
|
128
|
-
*/
|
|
129
|
-
size?: Partial<Size>;
|
|
130
133
|
/**
|
|
131
134
|
* Custom styles
|
|
132
135
|
*/
|
|
@@ -138,4 +141,8 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
|
|
|
138
141
|
handle?: CSSProperties;
|
|
139
142
|
header?: CSSProperties;
|
|
140
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Current width (controlled)
|
|
146
|
+
*/
|
|
147
|
+
width?: number;
|
|
141
148
|
}
|