shineout 3.9.0 → 3.9.1-beta.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/cjs/index.js CHANGED
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.9.0'
525
+ version: '3.9.1-beta.2'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12400,7 +12400,7 @@ var handleStyle = function handleStyle(style) {
12400
12400
  };
12401
12401
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12402
12402
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12403
- /* harmony default export */ var version = ('3.9.0');
12403
+ /* harmony default export */ var version = ('3.9.1-beta.2');
12404
12404
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12405
12405
 
12406
12406
 
@@ -60463,6 +60463,108 @@ var useMenuItem = function useMenuItem(props) {
60463
60463
  };
60464
60464
  };
60465
60465
  /* harmony default export */ var use_menu_item = (useMenuItem);
60466
+ ;// CONCATENATED MODULE: ../hooks/src/common/use-collapse-animation/use-collapse-animation.ts
60467
+
60468
+ /**
60469
+ * 为元素添加折叠/展开动画的 Hook
60470
+ *
60471
+ * @example
60472
+ * ```tsx
60473
+ * const ref = useRef<HTMLDivElement>(null);
60474
+ * useCollapseAnimation(ref, { isOpen: true });
60475
+ *
60476
+ * return <div ref={ref}>Content</div>;
60477
+ * ```
60478
+ */
60479
+ function useCollapseAnimation(elementRef, options) {
60480
+ var isOpen = options.isOpen,
60481
+ _options$duration = options.duration,
60482
+ duration = _options$duration === void 0 ? 240 : _options$duration,
60483
+ _options$disabled = options.disabled,
60484
+ disabled = _options$disabled === void 0 ? false : _options$disabled,
60485
+ _options$timingFuncti = options.timingFunction,
60486
+ timingFunction = _options$timingFuncti === void 0 ? 'cubic-bezier(.2,0,0,1)' : _options$timingFuncti;
60487
+ var isFirstRenderRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(true);
60488
+
60489
+ // 当 disabled 状态变化时,重置首次渲染标记
60490
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
60491
+ if (disabled) {
60492
+ isFirstRenderRef.current = true;
60493
+ }
60494
+ }, [disabled]);
60495
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
60496
+ if (!elementRef.current) return;
60497
+ var el = elementRef.current;
60498
+
60499
+ // 如果禁用动画,清除所有样式并返回
60500
+ if (disabled) {
60501
+ el.style.height = '';
60502
+ el.style.overflow = '';
60503
+ el.style.transition = '';
60504
+ el.style.display = '';
60505
+ return;
60506
+ }
60507
+ var timer = null;
60508
+
60509
+ // 设置 display: block,让元素始终可见,由高度控制折叠
60510
+ el.style.display = 'block';
60511
+
60512
+ // 首次渲染时,直接设置初始状态,不做动画
60513
+ if (isFirstRenderRef.current) {
60514
+ isFirstRenderRef.current = false;
60515
+ if (!isOpen) {
60516
+ el.style.height = '0px';
60517
+ el.style.overflow = 'hidden';
60518
+ }
60519
+ return;
60520
+ }
60521
+ if (isOpen) {
60522
+ // 展开动画
60523
+ el.style.height = '0px';
60524
+ el.style.overflow = 'hidden';
60525
+
60526
+ // 强制重绘
60527
+ void el.offsetHeight;
60528
+
60529
+ // 获取实际高度
60530
+ var scrollHeight = el.scrollHeight;
60531
+
60532
+ // 启动动画
60533
+ requestAnimationFrame(function () {
60534
+ el.style.transition = "height ".concat(duration, "ms ").concat(timingFunction);
60535
+ el.style.height = "".concat(scrollHeight, "px");
60536
+
60537
+ // 动画结束后恢复 auto
60538
+ timer = setTimeout(function () {
60539
+ if (el && isOpen) {
60540
+ el.style.height = '';
60541
+ el.style.overflow = '';
60542
+ el.style.transition = '';
60543
+ }
60544
+ }, duration);
60545
+ });
60546
+ } else {
60547
+ // 收起动画
60548
+ var _scrollHeight = el.scrollHeight;
60549
+ el.style.height = "".concat(_scrollHeight, "px");
60550
+ el.style.overflow = 'hidden';
60551
+
60552
+ // 强制重绘
60553
+ void el.offsetHeight;
60554
+ requestAnimationFrame(function () {
60555
+ el.style.transition = "height ".concat(duration, "ms ").concat(timingFunction);
60556
+ el.style.height = '0px';
60557
+ });
60558
+ }
60559
+
60560
+ // 清理函数:组件卸载或依赖变化时清除定时器
60561
+ return function () {
60562
+ if (timer) {
60563
+ clearTimeout(timer);
60564
+ }
60565
+ };
60566
+ }, [isOpen, disabled, duration, timingFunction]);
60567
+ }
60466
60568
  ;// CONCATENATED MODULE: ../base/src/menu/item.tsx
60467
60569
 
60468
60570
 
@@ -60496,7 +60598,8 @@ var MenuItem = function MenuItem(props) {
60496
60598
  _useState2 = slicedToArray_default()(_useState, 2),
60497
60599
  popOpen = _useState2[0],
60498
60600
  setOpen = _useState2[1];
60499
- var liRef = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);
60601
+ var liRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
60602
+ var childrenRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
60500
60603
  var hasExpandAbleChildren = children.some(function (item) {
60501
60604
  return item && item.children && (props.looseChildren || item.children.length);
60502
60605
  });
@@ -60532,6 +60635,12 @@ var MenuItem = function MenuItem(props) {
60532
60635
  handleItemClick = _useMenuItem.handleItemClick,
60533
60636
  handleMouseEnter = _useMenuItem.handleMouseEnter,
60534
60637
  handleMouseLeave = _useMenuItem.handleMouseLeave;
60638
+
60639
+ // 为 inline 模式添加折叠动画(仅当 inlineAnimate 为 true 时启用)
60640
+ useCollapseAnimation(childrenRef, {
60641
+ isOpen: isOpen,
60642
+ disabled: !props.inlineAnimate || shoudPop || !children.length
60643
+ });
60535
60644
  var renderChildren = function renderChildren() {
60536
60645
  var _items;
60537
60646
  var items = children;
@@ -60546,6 +60655,7 @@ var MenuItem = function MenuItem(props) {
60546
60655
  }
60547
60656
  var content = function content(close) {
60548
60657
  return /*#__PURE__*/(0,jsx_runtime.jsx)("ul", {
60658
+ ref: !shoudPop && props.inlineAnimate ? childrenRef : undefined,
60549
60659
  className: classnames_default()(shoudPop && (classes === null || classes === void 0 ? void 0 : classes.childrenShow), classes === null || classes === void 0 ? void 0 : classes.children, isUp && (classes === null || classes === void 0 ? void 0 : classes.childrenUp), hasExpandAbleChildren && (classes === null || classes === void 0 ? void 0 : classes.childrenHasExpand))
60550
60660
  // 子菜单点击弹出
60551
60661
  ,
@@ -60604,6 +60714,8 @@ var MenuItem = function MenuItem(props) {
60604
60714
  }
60605
60715
  });
60606
60716
  }
60717
+
60718
+ // inline 模式
60607
60719
  return content();
60608
60720
  };
60609
60721
  var renderItem = function renderItem() {
@@ -60816,6 +60928,7 @@ var Menu = function Menu(props) {
60816
60928
  frontCaretType: props.frontCaretType,
60817
60929
  caretColor: props.caretColor,
60818
60930
  inlineIndent: props.inlineIndent,
60931
+ inlineAnimate: props.inlineAnimate,
60819
60932
  scrollRef: scrollRef,
60820
60933
  theme: theme,
60821
60934
  renderIcon: props.renderIcon,
@@ -63936,7 +64049,8 @@ var scroll_table_Scroll = function Scroll(props) {
63936
64049
  var wrapperRef = useForkRef(scrollRef, props.wrapperRef);
63937
64050
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
63938
64051
  isMouseDown: false,
63939
- lastTableHeight: 0
64052
+ lastTableHeight: 0,
64053
+ prevTableHeight: 0
63940
64054
  }),
63941
64055
  context = _useRef.current;
63942
64056
  var _props$scrollHeight = props.scrollHeight,
@@ -64048,16 +64162,16 @@ var scroll_table_Scroll = function Scroll(props) {
64048
64162
  if (!props.tableRef.current) return;
64049
64163
  var isVisible = props.tableRef.current.offsetParent !== null;
64050
64164
  var wasHidden = props.tableRef.current.getAttribute('data-was-hidden') === 'true';
64051
- var h = context.lastTableHeight || props.tableRef.current.clientHeight;
64165
+ var h = context.prevTableHeight || props.tableRef.current.clientHeight;
64052
64166
  if (h > 0) {
64053
- context.lastTableHeight = h;
64167
+ context.prevTableHeight = h;
64054
64168
  }
64055
64169
  if (isVisible && wasHidden) {
64056
64170
  props.tableRef.current.style.height = '100%';
64057
64171
  props.tableRef.current.removeAttribute('data-was-hidden');
64058
- } else if (!isVisible && props.tableRef.current.style.height === '100%') {
64172
+ } else if (!isVisible && props.tableRef.current.style.height === '100%' && context.prevTableHeight > 0) {
64059
64173
  // 加height === '100%'判断是因为:多层父级flex嵌套才有这个问题
64060
- props.tableRef.current.style.height = "".concat(context.lastTableHeight, "px");
64174
+ props.tableRef.current.style.height = "".concat(context.prevTableHeight, "px");
64061
64175
  props.tableRef.current.setAttribute('data-was-hidden', 'true');
64062
64176
  }
64063
64177
  }, [paddingTop]);
@@ -74296,7 +74410,7 @@ var upload_interface = __webpack_require__(8821);
74296
74410
 
74297
74411
 
74298
74412
  /* harmony default export */ var src_0 = ({
74299
- version: '3.9.0'
74413
+ version: '3.9.1-beta.2'
74300
74414
  });
74301
74415
  }();
74302
74416
  /******/ return __webpack_exports__;