shineout 3.9.15-beta.4 → 3.9.15

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.15-beta.4'
525
+ version: '3.9.15'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12326,7 +12326,7 @@ var handleStyle = function handleStyle(style) {
12326
12326
  };
12327
12327
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12328
12328
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12329
- /* harmony default export */ var version = ('3.9.15-beta.4');
12329
+ /* harmony default export */ var version = ('3.9.15');
12330
12330
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12331
12331
 
12332
12332
 
@@ -66311,6 +66311,7 @@ var useTableVirtualExternal = function useTableVirtualExternal(props) {
66311
66311
  var externalStickyRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
66312
66312
  var tableOffsetRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
66313
66313
  var stickyCompensationTimer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
66314
+ var heightSyncTimer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
66314
66315
  var handleExternalScroll = usePersistFn(function () {
66315
66316
  var _props$tableRef, _externalStickyRef$cu;
66316
66317
  if (props.disabled) return;
@@ -66336,19 +66337,42 @@ var useTableVirtualExternal = function useTableVirtualExternal(props) {
66336
66337
  if (rawScrollTop < 0) rawScrollTop = 0;
66337
66338
  var sumHeight = props.getContentHeight(props.dataLength - 1);
66338
66339
  var viewportHeight = ((_externalStickyRef$cu = externalStickyRef.current) === null || _externalStickyRef$cu === void 0 ? void 0 : _externalStickyRef$cu.clientHeight) || container.clientHeight;
66340
+
66341
+ // 物理可滚动范围:基于当前外层 div 高度(滚动中不变)
66342
+ var physicalMax = props.scrollHeight - viewportHeight;
66343
+
66344
+ // 滚动停止后才同步外层 div 高度,防止滚动中 div 变高导致滑块倒退
66345
+ if (sumHeight !== props.scrollHeight) {
66346
+ if (heightSyncTimer.current) clearTimeout(heightSyncTimer.current);
66347
+ heightSyncTimer.current = setTimeout(function () {
66348
+ props.setScrollHeight(sumHeight);
66349
+ }, 200);
66350
+ }
66339
66351
  var scrollTop;
66340
66352
  var max;
66341
66353
  if (props.externalStickyHeader) {
66342
66354
  max = sumHeight - props.tfootHeight - viewportHeight;
66343
- scrollTop = rawScrollTop;
66355
+ if (physicalMax > 0 && max > 0) {
66356
+ var rate = Math.min(rawScrollTop / physicalMax, 1);
66357
+ scrollTop = rate * max;
66358
+ } else {
66359
+ scrollTop = rawScrollTop;
66360
+ }
66344
66361
  } else {
66345
66362
  var newHeaderOffset = Math.min(rawScrollTop, props.theadHeight);
66346
66363
  if (newHeaderOffset !== headerOffset) {
66347
66364
  setHeaderOffset(newHeaderOffset);
66348
66365
  }
66349
66366
  max = sumHeight - props.theadHeight - props.tfootHeight - viewportHeight;
66350
- scrollTop = rawScrollTop - props.theadHeight;
66351
- if (scrollTop < 0) scrollTop = 0;
66367
+ var adjustedRaw = rawScrollTop - props.theadHeight;
66368
+ var physicalMaxBody = physicalMax - props.theadHeight;
66369
+ if (physicalMaxBody > 0 && max > 0) {
66370
+ var _rate = Math.min(Math.max(adjustedRaw, 0) / physicalMaxBody, 1);
66371
+ scrollTop = _rate * max;
66372
+ } else {
66373
+ scrollTop = adjustedRaw;
66374
+ if (scrollTop < 0) scrollTop = 0;
66375
+ }
66352
66376
  }
66353
66377
  if (max > 0 && scrollTop > max) {
66354
66378
  scrollTop = max;
@@ -66383,8 +66407,37 @@ var useTableVirtualExternal = function useTableVirtualExternal(props) {
66383
66407
  handleExternalScroll();
66384
66408
  return function () {
66385
66409
  scrollTarget.removeEventListener('scroll', handleExternalScroll);
66410
+ if (heightSyncTimer.current) clearTimeout(heightSyncTimer.current);
66386
66411
  };
66387
66412
  }, [props.disabled, props.dataLength]);
66413
+
66414
+ // 动态控制 overflowX:当 table 仅因亚像素舍入比容器宽 1px 时隐藏滚动条,
66415
+ // 容器真正变小(如 resize)需要横滚时恢复 auto
66416
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
66417
+ var stickyEl = externalStickyRef.current;
66418
+ if (!stickyEl) return;
66419
+ var checkOverflowX = function checkOverflowX() {
66420
+ var overflow = stickyEl.scrollWidth - stickyEl.clientWidth;
66421
+ var next = overflow <= 1 ? 'hidden' : 'auto';
66422
+ if (stickyEl.style.overflowX !== next) {
66423
+ stickyEl.style.overflowX = next;
66424
+ }
66425
+ };
66426
+ checkOverflowX();
66427
+ var ro = new ResizeObserver(checkOverflowX);
66428
+ ro.observe(stickyEl);
66429
+ var mo = new MutationObserver(checkOverflowX);
66430
+ mo.observe(stickyEl, {
66431
+ childList: true,
66432
+ subtree: true,
66433
+ attributes: true,
66434
+ attributeFilter: ['style']
66435
+ });
66436
+ return function () {
66437
+ ro.disconnect();
66438
+ mo.disconnect();
66439
+ };
66440
+ }, [props.disabled]);
66388
66441
  return {
66389
66442
  externalStickyRef: externalStickyRef,
66390
66443
  headerOffset: headerOffset,
@@ -66534,7 +66587,9 @@ var useTableVirtual = function useTableVirtual(props) {
66534
66587
  var beforeHeight = context.cachedHeight[index];
66535
66588
  if (beforeHeight && beforeHeight === height) return;
66536
66589
  context.cachedHeight[index] = height;
66537
- if (context.shouldUpdateHeight) {
66590
+
66591
+ // 外部滚动模式下不由 setRowHeight 更新高度,由 handleExternalScroll debounce 同步
66592
+ if (context.shouldUpdateHeight && !props.virtualScrollContainer) {
66538
66593
  setHeight(getContentHeight(props.data.length - 1));
66539
66594
  }
66540
66595
  var preIndex = context.preIndex;
@@ -66801,7 +66856,9 @@ var useTableVirtual = function useTableVirtual(props) {
66801
66856
  },
66802
66857
  tableRef: props.tableRef,
66803
66858
  getContentHeight: getContentHeight,
66804
- updateIndexAndTopFromTop: updateIndexAndTopFromTop
66859
+ updateIndexAndTopFromTop: updateIndexAndTopFromTop,
66860
+ scrollHeight: scrollHeight,
66861
+ setScrollHeight: setHeight
66805
66862
  });
66806
66863
  return {
66807
66864
  scrollHeight: scrollHeight,
@@ -69186,14 +69243,12 @@ function Table(props) {
69186
69243
  position: 'relative',
69187
69244
  zIndex: 1,
69188
69245
  marginTop: props.sticky ? 0 : -virtualInfo.headerOffset,
69189
- transform: 'translateY(var(--sticky-compensation, 0px))',
69190
- willChange: 'transform'
69246
+ transform: 'translateY(var(--sticky-compensation, 0px))'
69191
69247
  },
69192
69248
  children: $headTable
69193
69249
  }), !!((_props$data3 = props.data) !== null && _props$data3 !== void 0 && _props$data3.length) && /*#__PURE__*/(0,jsx_runtime.jsxs)("table", {
69194
69250
  style: objectSpread2_default()(objectSpread2_default()({}, tableStyle), {}, {
69195
- transform: virtualInfo.translateStyle,
69196
- willChange: 'transform'
69251
+ transform: virtualInfo.translateStyle
69197
69252
  }),
69198
69253
  ref: tbodyRef,
69199
69254
  children: [Group, /*#__PURE__*/(0,jsx_runtime.jsx)(tbody, objectSpread2_default()(objectSpread2_default()({}, bodyCommonProps), {}, {
@@ -75940,7 +75995,7 @@ var upload_interface = __webpack_require__(8821);
75940
75995
 
75941
75996
 
75942
75997
  /* harmony default export */ var src_0 = ({
75943
- version: '3.9.15-beta.4'
75998
+ version: '3.9.15'
75944
75999
  });
75945
76000
  }();
75946
76001
  /******/ return __webpack_exports__;