@sheinx/base 3.10.2-beta.2 → 3.10.2-beta.4
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/table/table.d.ts.map +1 -1
- package/cjs/table/table.js +25 -5
- package/esm/table/table.d.ts.map +1 -1
- package/esm/table/table.js +25 -5
- package/package.json +2 -2
package/cjs/table/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["table.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAgB,UAAU,EAAoB,MAAM,cAAc,CAAC;AAgB1E,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["table.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAgB,UAAU,EAAoB,MAAM,cAAc,CAAC;AAgB1E,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,2CA22BxE"}
|
package/cjs/table/table.js
CHANGED
|
@@ -593,7 +593,7 @@ function Table(props) {
|
|
|
593
593
|
})
|
|
594
594
|
}));
|
|
595
595
|
if (isRenderVirtualTable) {
|
|
596
|
-
var _props$data4, _virtualInfo$rowSpanI2;
|
|
596
|
+
var _props$data4, _props$data5, _virtualInfo$rowSpanI2;
|
|
597
597
|
var showStickyHeader = !props.hideHeader && props.sticky;
|
|
598
598
|
if (virtualInfo.isExternalScroll) {
|
|
599
599
|
var _props$sticky$top, _props$virtualScrollC, _props$data3, _virtualInfo$rowSpanI;
|
|
@@ -642,6 +642,26 @@ function Table(props) {
|
|
|
642
642
|
})
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
|
+
|
|
646
|
+
// sticky-only:有 sticky 但不需要 virtual 的轻量路径
|
|
647
|
+
// 避免 Scroll 组件和虚拟滚动的额外开销
|
|
648
|
+
var isStickyOnly = !virtual && !!((_props$data4 = props.data) !== null && _props$data4 !== void 0 && _props$data4.length);
|
|
649
|
+
if (isStickyOnly) {
|
|
650
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
651
|
+
children: [renderHeadMirrorScroller(), showStickyHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)(StickyWrapper, _objectSpread(_objectSpread({}, stickyProps), {}, {
|
|
652
|
+
children: $headTable
|
|
653
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
654
|
+
ref: scrollRef,
|
|
655
|
+
className: tableClasses === null || tableClasses === void 0 ? void 0 : tableClasses.bodyWrapper,
|
|
656
|
+
onScroll: handleBodyScroll,
|
|
657
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("table", {
|
|
658
|
+
style: tableStyle,
|
|
659
|
+
ref: tbodyRef,
|
|
660
|
+
children: [Group, /*#__PURE__*/(0, _jsxRuntime.jsx)(_tbody.default, _objectSpread({}, bodyCommonProps)), showFoot && /*#__PURE__*/(0, _jsxRuntime.jsx)(_tfoot.default, _objectSpread({}, footCommonProps))]
|
|
661
|
+
})
|
|
662
|
+
}), renderBottomMirrorScroller()]
|
|
663
|
+
});
|
|
664
|
+
}
|
|
645
665
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
646
666
|
children: [renderHeadMirrorScroller(), showStickyHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)(StickyWrapper, _objectSpread(_objectSpread({}, stickyProps), {}, {
|
|
647
667
|
children: $headTable
|
|
@@ -662,7 +682,7 @@ function Table(props) {
|
|
|
662
682
|
isEmpty: !!$empty,
|
|
663
683
|
tableRef: tableRef,
|
|
664
684
|
setFakeVirtual: scrollAble ? undefined : setFakeVirtual,
|
|
665
|
-
children: [!props.hideHeader && !props.sticky && $headTable, !!((_props$
|
|
685
|
+
children: [!props.hideHeader && !props.sticky && $headTable, !!((_props$data5 = props.data) !== null && _props$data5 !== void 0 && _props$data5.length) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("table", {
|
|
666
686
|
style: _objectSpread(_objectSpread({}, tableStyle), {}, {
|
|
667
687
|
transform: virtualInfo.translateStyle
|
|
668
688
|
}),
|
|
@@ -724,6 +744,7 @@ function Table(props) {
|
|
|
724
744
|
};
|
|
725
745
|
|
|
726
746
|
// handle head and foot scroll
|
|
747
|
+
// 使用 passive: true 监听 wheel,不调用 preventDefault,避免阻塞合成器线程(优化 INP)
|
|
727
748
|
var handleHeaderWheel = (0, _hooks.usePersistFn)(function (e) {
|
|
728
749
|
var _theadRef$current2;
|
|
729
750
|
var scrollEl = scrollRef.current;
|
|
@@ -734,7 +755,6 @@ function Table(props) {
|
|
|
734
755
|
if (scrollLeft === scrollEl.scrollLeft) {
|
|
735
756
|
return;
|
|
736
757
|
}
|
|
737
|
-
e.preventDefault();
|
|
738
758
|
var left = Math.min(Math.max(scrollLeft, 0), max);
|
|
739
759
|
scrollEl.scrollLeft = left;
|
|
740
760
|
theadRef.current.parentElement.scrollLeft = left;
|
|
@@ -746,10 +766,10 @@ function Table(props) {
|
|
|
746
766
|
syncHeaderScroll(((_scrollRef$current10 = scrollRef.current) === null || _scrollRef$current10 === void 0 ? void 0 : _scrollRef$current10.scrollLeft) || 0);
|
|
747
767
|
}, [isScrollX, props.sticky, $empty]);
|
|
748
768
|
(0, _react.useEffect)(function () {
|
|
749
|
-
// 绑定 wheel
|
|
769
|
+
// 绑定 wheel 事件(passive: true 不阻塞合成器线程)
|
|
750
770
|
if (props.sticky && theadRef.current && theadRef.current.parentElement) {
|
|
751
771
|
theadRef.current.parentElement.addEventListener('wheel', handleHeaderWheel, {
|
|
752
|
-
passive:
|
|
772
|
+
passive: true
|
|
753
773
|
});
|
|
754
774
|
}
|
|
755
775
|
return function () {
|
package/esm/table/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["table.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAgB,UAAU,EAAoB,MAAM,cAAc,CAAC;AAgB1E,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["table.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAgB,UAAU,EAAoB,MAAM,cAAc,CAAC;AAgB1E,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,2CA22BxE"}
|
package/esm/table/table.js
CHANGED
|
@@ -586,7 +586,7 @@ export default function Table(props) {
|
|
|
586
586
|
})
|
|
587
587
|
}));
|
|
588
588
|
if (isRenderVirtualTable) {
|
|
589
|
-
var _props$data4, _virtualInfo$rowSpanI2;
|
|
589
|
+
var _props$data4, _props$data5, _virtualInfo$rowSpanI2;
|
|
590
590
|
var showStickyHeader = !props.hideHeader && props.sticky;
|
|
591
591
|
if (virtualInfo.isExternalScroll) {
|
|
592
592
|
var _props$sticky$top, _props$virtualScrollC, _props$data3, _virtualInfo$rowSpanI;
|
|
@@ -635,6 +635,26 @@ export default function Table(props) {
|
|
|
635
635
|
})
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
|
+
|
|
639
|
+
// sticky-only:有 sticky 但不需要 virtual 的轻量路径
|
|
640
|
+
// 避免 Scroll 组件和虚拟滚动的额外开销
|
|
641
|
+
var isStickyOnly = !virtual && !!((_props$data4 = props.data) !== null && _props$data4 !== void 0 && _props$data4.length);
|
|
642
|
+
if (isStickyOnly) {
|
|
643
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
644
|
+
children: [renderHeadMirrorScroller(), showStickyHeader && /*#__PURE__*/_jsx(StickyWrapper, _objectSpread(_objectSpread({}, stickyProps), {}, {
|
|
645
|
+
children: $headTable
|
|
646
|
+
})), /*#__PURE__*/_jsx("div", {
|
|
647
|
+
ref: scrollRef,
|
|
648
|
+
className: tableClasses === null || tableClasses === void 0 ? void 0 : tableClasses.bodyWrapper,
|
|
649
|
+
onScroll: handleBodyScroll,
|
|
650
|
+
children: /*#__PURE__*/_jsxs("table", {
|
|
651
|
+
style: tableStyle,
|
|
652
|
+
ref: tbodyRef,
|
|
653
|
+
children: [Group, /*#__PURE__*/_jsx(Tbody, _objectSpread({}, bodyCommonProps)), showFoot && /*#__PURE__*/_jsx(Tfoot, _objectSpread({}, footCommonProps))]
|
|
654
|
+
})
|
|
655
|
+
}), renderBottomMirrorScroller()]
|
|
656
|
+
});
|
|
657
|
+
}
|
|
638
658
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
639
659
|
children: [renderHeadMirrorScroller(), showStickyHeader && /*#__PURE__*/_jsx(StickyWrapper, _objectSpread(_objectSpread({}, stickyProps), {}, {
|
|
640
660
|
children: $headTable
|
|
@@ -655,7 +675,7 @@ export default function Table(props) {
|
|
|
655
675
|
isEmpty: !!$empty,
|
|
656
676
|
tableRef: tableRef,
|
|
657
677
|
setFakeVirtual: scrollAble ? undefined : setFakeVirtual,
|
|
658
|
-
children: [!props.hideHeader && !props.sticky && $headTable, !!((_props$
|
|
678
|
+
children: [!props.hideHeader && !props.sticky && $headTable, !!((_props$data5 = props.data) !== null && _props$data5 !== void 0 && _props$data5.length) && /*#__PURE__*/_jsxs("table", {
|
|
659
679
|
style: _objectSpread(_objectSpread({}, tableStyle), {}, {
|
|
660
680
|
transform: virtualInfo.translateStyle
|
|
661
681
|
}),
|
|
@@ -717,6 +737,7 @@ export default function Table(props) {
|
|
|
717
737
|
};
|
|
718
738
|
|
|
719
739
|
// handle head and foot scroll
|
|
740
|
+
// 使用 passive: true 监听 wheel,不调用 preventDefault,避免阻塞合成器线程(优化 INP)
|
|
720
741
|
var handleHeaderWheel = usePersistFn(function (e) {
|
|
721
742
|
var _theadRef$current2;
|
|
722
743
|
var scrollEl = scrollRef.current;
|
|
@@ -727,7 +748,6 @@ export default function Table(props) {
|
|
|
727
748
|
if (scrollLeft === scrollEl.scrollLeft) {
|
|
728
749
|
return;
|
|
729
750
|
}
|
|
730
|
-
e.preventDefault();
|
|
731
751
|
var left = Math.min(Math.max(scrollLeft, 0), max);
|
|
732
752
|
scrollEl.scrollLeft = left;
|
|
733
753
|
theadRef.current.parentElement.scrollLeft = left;
|
|
@@ -739,10 +759,10 @@ export default function Table(props) {
|
|
|
739
759
|
syncHeaderScroll(((_scrollRef$current10 = scrollRef.current) === null || _scrollRef$current10 === void 0 ? void 0 : _scrollRef$current10.scrollLeft) || 0);
|
|
740
760
|
}, [isScrollX, props.sticky, $empty]);
|
|
741
761
|
useEffect(function () {
|
|
742
|
-
// 绑定 wheel
|
|
762
|
+
// 绑定 wheel 事件(passive: true 不阻塞合成器线程)
|
|
743
763
|
if (props.sticky && theadRef.current && theadRef.current.parentElement) {
|
|
744
764
|
theadRef.current.parentElement.addEventListener('wheel', handleHeaderWheel, {
|
|
745
|
-
passive:
|
|
765
|
+
passive: true
|
|
746
766
|
});
|
|
747
767
|
}
|
|
748
768
|
return function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/base",
|
|
3
|
-
"version": "3.10.2-beta.
|
|
3
|
+
"version": "3.10.2-beta.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"module": "./esm/index.js",
|
|
11
11
|
"typings": "./cjs/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sheinx/hooks": "3.10.2-beta.
|
|
13
|
+
"@sheinx/hooks": "3.10.2-beta.4",
|
|
14
14
|
"immer": "^10.0.0",
|
|
15
15
|
"classnames": "^2.0.0",
|
|
16
16
|
"@shined/reactive": "^0.3.3"
|