@lobehub/ui 2.15.0 → 2.15.1

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.
@@ -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", "collapsed", "defaultCollapsed", "defaultSize", "footer", "header", "maxWidth", "minWidth", "onCollapsedChange", "onSizeChange", "onSizeDragging", "placement", "resizable", "showBorder", "showHandle", "showHandleWhenCollapsed", "showHandleHighlight", "size", "styles"];
4
+ var _excluded = ["animation", "children", "className", "classNames", "defaultExpand", "defaultWidth", "expand", "expandable", "footer", "header", "maxWidth", "minWidth", "onExpandChange", "onWidthChange", "onWidthDragging", "placement", "resizable", "showBorder", "showHandle", "showHandleWhenCollapsed", "showHandleHighlight", "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 DEFAULT_COLLAPSED = false;
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(collapsed ? 'collapsed' : 'expanded'))
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
- collapsed = _ref2.collapsed,
91
- _ref2$defaultCollapse = _ref2.defaultCollapsed,
92
- defaultCollapsed = _ref2$defaultCollapse === void 0 ? DEFAULT_COLLAPSED : _ref2$defaultCollapse,
93
- defaultSize = _ref2.defaultSize,
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
- onCollapsedChange = _ref2.onCollapsedChange,
100
- onSizeChange = _ref2.onSizeChange,
101
- onSizeDragging = _ref2.onSizeDragging,
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,8 +113,8 @@ 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
- size = _ref2.size,
115
116
  customStyles = _ref2.styles,
117
+ width = _ref2.width,
116
118
  rest = _objectWithoutProperties(_ref2, _excluded);
117
119
  var _useStyles = useStyles({
118
120
  showBorder: showBorder
@@ -121,13 +123,15 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
121
123
  cx = _useStyles.cx;
122
124
  var ref = useRef(null);
123
125
  var isHovering = useHover(ref);
124
- var _useControlledState = useControlledState(defaultCollapsed, {
125
- onChange: onCollapsedChange,
126
- value: collapsed
126
+
127
+ // Expand state management
128
+ var _useControlledState = useControlledState(defaultExpand, {
129
+ onChange: onExpandChange,
130
+ value: expand
127
131
  }),
128
132
  _useControlledState2 = _slicedToArray(_useControlledState, 2),
129
- isCollapsed = _useControlledState2[0],
130
- setIsCollapsed = _useControlledState2[1];
133
+ isExpand = _useControlledState2[0],
134
+ setIsExpand = _useControlledState2[1];
131
135
  var _useState = useState(false),
132
136
  _useState2 = _slicedToArray(_useState, 2),
133
137
  isResizing = _useState2[0],
@@ -137,33 +141,37 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
137
141
  isAnimating = _useState4[0],
138
142
  setIsAnimating = _useState4[1];
139
143
 
144
+ // Compute default expanded width
145
+ var computedDefaultExpandedWidth = defaultWidth || DEFAULT_EXPANDED_WIDTH;
146
+
140
147
  // 内部宽度状态,用于平滑动画
141
- var _useState5 = useState(isCollapsed ? minWidth : (defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.width) || DEFAULT_EXPANDED_WIDTH),
148
+ var _useState5 = useState(isExpand ? width !== null && width !== void 0 ? width : computedDefaultExpandedWidth : minWidth),
142
149
  _useState6 = _slicedToArray(_useState5, 2),
143
150
  internalWidth = _useState6[0],
144
151
  setInternalWidth = _useState6[1];
145
152
 
146
153
  // 记住展开时的宽度
147
- var _useState7 = useState((defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.width) || DEFAULT_EXPANDED_WIDTH),
154
+ var _useState7 = useState(width !== null && width !== void 0 ? width : computedDefaultExpandedWidth),
148
155
  _useState8 = _slicedToArray(_useState7, 2),
149
156
  expandedWidth = _useState8[0],
150
157
  setExpandedWidth = _useState8[1];
151
158
 
152
- // 用于渲染的 collapsed 状态 - 延迟切换以匹配动画时机
153
- var _useState9 = useState(isCollapsed),
159
+ // 用于渲染的 expand 状态 - 延迟切换以匹配动画时机
160
+ var _useState9 = useState(isExpand),
154
161
  _useState10 = _slicedToArray(_useState9, 2),
155
- renderCollapsed = _useState10[0],
156
- setRenderCollapsed = _useState10[1];
162
+ renderExpand = _useState10[0],
163
+ setRenderExpand = _useState10[1];
157
164
 
158
165
  // 计算折叠阈值:展开最小宽度和折叠宽度的中间值
159
166
  var collapseThreshold = useMemo(function () {
160
167
  return minWidth + (expandedWidth - minWidth) / 3;
161
168
  }, [minWidth, expandedWidth]);
162
169
 
163
- // Toggle collapse state with smooth animation
164
- var toggleCollapse = function toggleCollapse() {
170
+ // Toggle expand state with smooth animation
171
+ var toggleExpand = function toggleExpand() {
172
+ if (!expandable) return;
165
173
  setIsAnimating(true);
166
- setIsCollapsed(!isCollapsed);
174
+ setIsExpand(!isExpand);
167
175
 
168
176
  // 动画完成后重置状态 - 与宽度动画时长一致
169
177
  setTimeout(function () {
@@ -171,67 +179,63 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
171
179
  }, 400);
172
180
  };
173
181
 
174
- // 处理折叠状态变化时的宽度动画和内容切换时机
182
+ // 处理展开/折叠状态变化时的宽度动画和内容切换时机
175
183
  useEffect(function () {
176
184
  if (isAnimating) {
177
185
  // 使用 requestAnimationFrame 确保动画平滑
178
186
  requestAnimationFrame(function () {
179
- if (isCollapsed) {
180
- setInternalWidth(minWidth);
187
+ if (isExpand) {
188
+ // 展开动画:立即切换内容(先切换内容,再开始宽度动画)
189
+ setRenderExpand(true);
190
+ setInternalWidth(expandedWidth);
191
+ } else {
181
192
  // 折叠动画:延迟切换内容,在动画接近结束时才切换(300ms,略早于动画结束)
193
+ setInternalWidth(minWidth);
182
194
  setTimeout(function () {
183
- setRenderCollapsed(true);
195
+ setRenderExpand(false);
184
196
  }, 300);
185
- } else {
186
- // 展开动画:立即切换内容(先切换内容,再开始宽度动画)
187
- setRenderCollapsed(false);
188
- setInternalWidth(expandedWidth);
189
197
  }
190
198
  });
191
199
  }
192
- }, [isCollapsed, isAnimating, minWidth, expandedWidth]);
200
+ }, [isExpand, isAnimating, minWidth, expandedWidth]);
193
201
 
194
- // 同步非动画期间的 renderCollapsed 状态(如拖拽)
202
+ // 同步非动画期间的 renderExpand 状态(如拖拽)
195
203
  useEffect(function () {
196
204
  if (!isAnimating && !isResizing) {
197
- setRenderCollapsed(isCollapsed);
205
+ setRenderExpand(isExpand);
198
206
  }
199
- }, [isCollapsed, isAnimating, isResizing]);
207
+ }, [isExpand, isAnimating, isResizing]);
200
208
 
201
- // 处理外部 size prop 变化
209
+ // 处理外部 width prop 变化
202
210
  useEffect(function () {
203
- if (size !== null && size !== void 0 && size.width && !isResizing && !isAnimating) {
204
- var width = typeof size.width === 'string' ? parseInt(size.width) : size.width;
211
+ if (width !== undefined && !isResizing && !isAnimating) {
205
212
  setInternalWidth(width);
206
- if (!isCollapsed) {
213
+ if (isExpand) {
207
214
  setExpandedWidth(width);
208
215
  }
209
216
  }
210
- }, [size === null || size === void 0 ? void 0 : size.width, isResizing, isAnimating, isCollapsed]);
217
+ }, [width, isResizing, isAnimating, isExpand]);
211
218
 
212
- // 计算当前的 children(支持函数和静态值)- 使用 renderCollapsed 而不是 isCollapsed
219
+ // 计算当前的 children(支持函数和静态值)- 使用 renderExpand
213
220
  var currentChildren = useMemo(function () {
214
- return typeof children === 'function' ? children(renderCollapsed) : children;
215
- }, [children, renderCollapsed]);
221
+ return typeof children === 'function' ? children(renderExpand) : children;
222
+ }, [children, renderExpand]);
216
223
 
217
- // 计算当前的 header(支持函数和静态值)- 使用 renderCollapsed 而不是 isCollapsed
224
+ // 计算当前的 header(支持函数和静态值)- 使用 renderExpand
218
225
  var currentHeader = useMemo(function () {
219
- return typeof header === 'function' ? header(renderCollapsed) : header;
220
- }, [header, renderCollapsed]);
226
+ return typeof header === 'function' ? header(renderExpand) : header;
227
+ }, [header, renderExpand]);
221
228
 
222
- // 计算当前的 footer(支持函数和静态值)- 使用 renderCollapsed 而不是 isCollapsed
229
+ // 计算当前的 footer(支持函数和静态值)- 使用 renderExpand
223
230
  var currentFooter = useMemo(function () {
224
- return typeof footer === 'function' ? footer(renderCollapsed) : footer;
225
- }, [footer, renderCollapsed]);
231
+ return typeof footer === 'function' ? footer(renderExpand) : footer;
232
+ }, [footer, renderExpand]);
226
233
 
227
234
  // Handle resize
228
235
  var handleResize = function handleResize(_, _direction, reference_, delta) {
229
236
  var currentWidth = reference_.offsetWidth;
230
237
  setInternalWidth(currentWidth);
231
- onSizeDragging === null || onSizeDragging === void 0 || onSizeDragging(delta, {
232
- height: reference_.style.height,
233
- width: reference_.style.width
234
- });
238
+ onWidthDragging === null || onWidthDragging === void 0 || onWidthDragging(delta, currentWidth);
235
239
  };
236
240
  var handleResizeStart = function handleResizeStart() {
237
241
  setIsResizing(true);
@@ -241,56 +245,59 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
241
245
  var currentWidth = reference_.offsetWidth;
242
246
 
243
247
  // 根据拖拽后的宽度决定是折叠还是展开
244
- if (currentWidth <= minWidth) {
245
- // 拖拽到最小宽度,保持折叠
246
- setIsAnimating(true);
247
- setIsCollapsed(true);
248
- setInternalWidth(minWidth);
249
- setTimeout(function () {
250
- return setIsAnimating(false);
251
- }, 400);
252
- } else if (currentWidth < collapseThreshold) {
253
- // 拖拽到阈值以下,自动折叠
254
- setIsAnimating(true);
255
- setIsCollapsed(true);
256
- setInternalWidth(minWidth);
257
- setTimeout(function () {
258
- return setIsAnimating(false);
259
- }, 400);
260
- } else if (isCollapsed && currentWidth > minWidth) {
261
- // 从折叠状态拖拽出来,自动展开
262
- setIsAnimating(true);
263
- setIsCollapsed(false);
264
- setExpandedWidth(currentWidth);
265
- setInternalWidth(currentWidth);
266
- setTimeout(function () {
267
- return setIsAnimating(false);
268
- }, 400);
269
- } else if (!isCollapsed) {
270
- // 展开状态下正常拖拽,记住宽度
248
+ if (expandable) {
249
+ if (currentWidth <= minWidth) {
250
+ // 拖拽到最小宽度,保持折叠
251
+ setIsAnimating(true);
252
+ setIsExpand(false);
253
+ setInternalWidth(minWidth);
254
+ setTimeout(function () {
255
+ return setIsAnimating(false);
256
+ }, 400);
257
+ } else if (currentWidth < collapseThreshold) {
258
+ // 拖拽到阈值以下,自动折叠
259
+ setIsAnimating(true);
260
+ setIsExpand(false);
261
+ setInternalWidth(minWidth);
262
+ setTimeout(function () {
263
+ return setIsAnimating(false);
264
+ }, 400);
265
+ } else if (!isExpand && currentWidth > minWidth) {
266
+ // 从折叠状态拖拽出来,自动展开
267
+ setIsAnimating(true);
268
+ setIsExpand(true);
269
+ setExpandedWidth(currentWidth);
270
+ setInternalWidth(currentWidth);
271
+ setTimeout(function () {
272
+ return setIsAnimating(false);
273
+ }, 400);
274
+ } else if (isExpand) {
275
+ // 展开状态下正常拖拽,记住宽度
276
+ setExpandedWidth(currentWidth);
277
+ setInternalWidth(currentWidth);
278
+ }
279
+ } else {
280
+ // 如果不可折叠,仅更新宽度
271
281
  setExpandedWidth(currentWidth);
272
282
  setInternalWidth(currentWidth);
273
283
  }
274
- onSizeChange === null || onSizeChange === void 0 || onSizeChange(delta, {
275
- height: reference_.style.height,
276
- width: reference_.style.width
277
- });
284
+ onWidthChange === null || onWidthChange === void 0 || onWidthChange(delta, currentWidth);
278
285
  };
279
286
 
280
- // Arrow icon based on placement and collapse state
287
+ // Arrow icon based on placement and expand state
281
288
  var ArrowIcon = useMemo(function () {
282
289
  if (placement === 'left') {
283
- // 左侧:折叠时箭头向右(展开方向),展开时箭头向左(折叠方向)
290
+ // 左侧:展开时箭头向左(折叠方向),折叠时箭头向右(展开方向)
284
291
  return ChevronLeft;
285
292
  }
286
- // 右侧:折叠时箭头向左(展开方向),展开时箭头向右(折叠方向)
293
+ // 右侧:展开时箭头向右(折叠方向),折叠时箭头向左(展开方向)
287
294
  return ChevronRight;
288
295
  }, [placement]);
289
296
 
290
297
  // Toggle handle with smooth transitions
291
- var handle = showHandle && /*#__PURE__*/_jsx(motion.div, {
298
+ var handle = showHandle && expandable && /*#__PURE__*/_jsx(motion.div, {
292
299
  animate: {
293
- opacity: isCollapsed && showHandleWhenCollapsed ? 1 : isHovering ? 1 : 0,
300
+ opacity: !isExpand && showHandleWhenCollapsed ? 1 : isHovering ? 1 : 0,
294
301
  scale: isHovering ? 1.05 : 1
295
302
  },
296
303
  className: cx(styles.toggleRoot, placement === 'left' ? styles.toggleLeft : styles.toggleRight),
@@ -303,14 +310,14 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
303
310
  },
304
311
  children: /*#__PURE__*/_jsx(Center, {
305
312
  className: classNames === null || classNames === void 0 ? void 0 : classNames.handle,
306
- onClick: toggleCollapse,
313
+ onClick: toggleExpand,
307
314
  style: _objectSpread(_objectSpread({}, customStyles === null || customStyles === void 0 ? void 0 : customStyles.handle), {}, {
308
315
  cursor: 'pointer',
309
316
  transition: 'transform 0.2s ease-out'
310
317
  }),
311
318
  children: /*#__PURE__*/_jsx(motion.div, {
312
319
  animate: {
313
- rotate: isCollapsed ? 180 : 0
320
+ rotate: isExpand ? 0 : 180
314
321
  },
315
322
  transition: {
316
323
  duration: 0.3,
@@ -381,33 +388,33 @@ var DraggableSideNav = /*#__PURE__*/memo(function (_ref2) {
381
388
  children: [currentHeader && /*#__PURE__*/_jsx("div", {
382
389
  className: cx(styles.header, classNames === null || classNames === void 0 ? void 0 : classNames.header),
383
390
  style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.header,
384
- children: /*#__PURE__*/_jsx(AnimationWrapper, {
385
- blur: (_animation$blur = animation === null || animation === void 0 ? void 0 : animation.blur) !== null && _animation$blur !== void 0 ? _animation$blur : false,
386
- collapsed: renderCollapsed,
387
- enabled: animation === null || animation === void 0 ? void 0 : animation.header,
388
- fade: (_animation$fade = animation === null || animation === void 0 ? void 0 : animation.fade) !== null && _animation$fade !== void 0 ? _animation$fade : true,
391
+ children: animation === false || animation === undefined ? currentHeader : /*#__PURE__*/_jsx(AnimationWrapper, {
392
+ blur: (_animation$blur = animation.blur) !== null && _animation$blur !== void 0 ? _animation$blur : false,
393
+ enabled: animation.header,
394
+ expand: renderExpand,
395
+ fade: (_animation$fade = animation.fade) !== null && _animation$fade !== void 0 ? _animation$fade : true,
389
396
  id: "header",
390
397
  children: currentHeader
391
398
  })
392
399
  }), /*#__PURE__*/_jsx("div", {
393
400
  className: cx(styles.body, classNames === null || classNames === void 0 ? void 0 : classNames.body),
394
401
  style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.body,
395
- children: /*#__PURE__*/_jsx(AnimationWrapper, {
396
- blur: (_animation$blur2 = animation === null || animation === void 0 ? void 0 : animation.blur) !== null && _animation$blur2 !== void 0 ? _animation$blur2 : false,
397
- collapsed: renderCollapsed,
398
- enabled: animation === null || animation === void 0 ? void 0 : animation.body,
399
- fade: (_animation$fade2 = animation === null || animation === void 0 ? void 0 : animation.fade) !== null && _animation$fade2 !== void 0 ? _animation$fade2 : true,
402
+ children: animation === false || animation === undefined ? currentChildren : /*#__PURE__*/_jsx(AnimationWrapper, {
403
+ blur: (_animation$blur2 = animation.blur) !== null && _animation$blur2 !== void 0 ? _animation$blur2 : false,
404
+ enabled: animation.body,
405
+ expand: renderExpand,
406
+ fade: (_animation$fade2 = animation.fade) !== null && _animation$fade2 !== void 0 ? _animation$fade2 : true,
400
407
  id: "body",
401
408
  children: currentChildren
402
409
  })
403
410
  }), currentFooter && /*#__PURE__*/_jsx("div", {
404
411
  className: cx(styles.footer, classNames === null || classNames === void 0 ? void 0 : classNames.footer),
405
412
  style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.footer,
406
- children: /*#__PURE__*/_jsx(AnimationWrapper, {
407
- blur: (_animation$blur3 = animation === null || animation === void 0 ? void 0 : animation.blur) !== null && _animation$blur3 !== void 0 ? _animation$blur3 : false,
408
- collapsed: renderCollapsed,
409
- enabled: animation === null || animation === void 0 ? void 0 : animation.footer,
410
- fade: (_animation$fade3 = animation === null || animation === void 0 ? void 0 : animation.fade) !== null && _animation$fade3 !== void 0 ? _animation$fade3 : true,
413
+ children: animation === false || animation === undefined ? currentFooter : /*#__PURE__*/_jsx(AnimationWrapper, {
414
+ blur: (_animation$blur3 = animation.blur) !== null && _animation$blur3 !== void 0 ? _animation$blur3 : false,
415
+ enabled: animation.footer,
416
+ expand: renderExpand,
417
+ fade: (_animation$fade3 = animation.fade) !== null && _animation$fade3 !== void 0 ? _animation$fade3 : true,
411
418
  id: "footer",
412
419
  children: currentFooter
413
420
  })
@@ -15,14 +15,14 @@ export var useStyles = createStyles(function (_ref, _ref2) {
15
15
  prefixCls = _ref.prefixCls;
16
16
  var showBorder = _ref2.showBorder;
17
17
  return {
18
- body: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\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\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 "]))),
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
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),
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 z-index: 1;\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 "]))),
25
+ resizeHandle: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n cursor: col-resize;\n\n position: absolute;\n z-index: 50;\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 "]))),
@@ -1,12 +1,13 @@
1
- import type { NumberSize, Size } from 're-resizable';
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
- * @default { fade: true, blur: false, header: false, body: false, footer: false }
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
@@ -35,9 +36,9 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
35
36
  };
36
37
  /**
37
38
  * Body content (main content area)
38
- * Can be a static element or a function that receives collapsed state
39
+ * Can be a static element or a function that receives expand state
39
40
  */
40
- children: ReactNode | ((collapsed: boolean) => ReactNode);
41
+ children: ReactNode | ((expand: boolean) => ReactNode);
41
42
  /**
42
43
  * Classnames for internal components
43
44
  */
@@ -50,28 +51,33 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
50
51
  header?: string;
51
52
  };
52
53
  /**
53
- * Whether the panel is collapsed (controlled)
54
+ * Whether the panel is expanded by default
55
+ * @default true
54
56
  */
55
- collapsed?: boolean;
57
+ defaultExpand?: boolean;
56
58
  /**
57
- * Whether the panel is collapsed by default
58
- * @default false
59
+ * Default width (number format)
59
60
  */
60
- defaultCollapsed?: boolean;
61
+ defaultWidth?: number;
61
62
  /**
62
- * Default width when expanded
63
+ * Whether the panel is expanded (controlled)
64
+ */
65
+ expand?: boolean;
66
+ /**
67
+ * Whether the panel can be expanded/collapsed
68
+ * @default true
63
69
  */
64
- defaultSize?: Partial<Size>;
70
+ expandable?: boolean;
65
71
  /**
66
72
  * Footer content
67
- * Can be a static element or a function that receives collapsed state
73
+ * Can be a static element or a function that receives expand state
68
74
  */
69
- footer?: ReactNode | ((collapsed: boolean) => ReactNode);
75
+ footer?: ReactNode | ((expand: boolean) => ReactNode);
70
76
  /**
71
77
  * Header content
72
- * Can be a static element or a function that receives collapsed state
78
+ * Can be a static element or a function that receives expand state
73
79
  */
74
- header?: ReactNode | ((collapsed: boolean) => ReactNode);
80
+ header?: ReactNode | ((expand: boolean) => ReactNode);
75
81
  /**
76
82
  * Maximum width
77
83
  */
@@ -82,21 +88,21 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
82
88
  */
83
89
  minWidth?: number;
84
90
  /**
85
- * Callback when collapse state changes
91
+ * Callback when expand state changes
86
92
  */
87
- onCollapsedChange?: (collapsed: boolean) => void;
93
+ onExpandChange?: (expand: boolean) => void;
88
94
  /**
89
95
  * Callback when menu item is selected
90
96
  */
91
97
  onSelect?: (key: string) => void;
92
98
  /**
93
- * Callback when size changes
99
+ * Callback when width changes
94
100
  */
95
- onSizeChange?: (delta: NumberSize, size?: Size) => void;
101
+ onWidthChange?: (delta: NumberSize, width: number) => void;
96
102
  /**
97
- * Callback when actively resizing
103
+ * Callback when actively resizing width
98
104
  */
99
- onSizeDragging?: (delta: NumberSize, size?: Size) => void;
105
+ onWidthDragging?: (delta: NumberSize, width: number) => void;
100
106
  /**
101
107
  * Placement of the side nav
102
108
  * @default 'left'
@@ -123,10 +129,6 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
123
129
  * @default false
124
130
  */
125
131
  showHandleWhenCollapsed?: boolean;
126
- /**
127
- * Current size (controlled)
128
- */
129
- size?: Partial<Size>;
130
132
  /**
131
133
  * Custom styles
132
134
  */
@@ -138,4 +140,8 @@ export interface DraggableSideNavProps extends Omit<DivProps, 'children' | 'onSe
138
140
  handle?: CSSProperties;
139
141
  header?: CSSProperties;
140
142
  };
143
+ /**
144
+ * Current width (controlled)
145
+ */
146
+ width?: number;
141
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",