@sheinx/base 3.10.2-beta.3 → 3.10.2-beta.5

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 +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,2CA22BxE"}
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,2CA42BxE"}
@@ -157,6 +157,7 @@ function Table(props) {
157
157
  theadRef: theadRef,
158
158
  tbodyRef: tbodyRef,
159
159
  scrollRef: scrollRef,
160
+ tableElRef: tableRef,
160
161
  columns: columns,
161
162
  data: props.data,
162
163
  dataChangeResize: !!props.dataChangeResize,
@@ -170,13 +171,15 @@ function Table(props) {
170
171
  colgroup = _useTableLayout.colgroup,
171
172
  isScrollY = _useTableLayout.isScrollY,
172
173
  isScrollX = _useTableLayout.isScrollX,
173
- floatLeft = _useTableLayout.floatLeft,
174
- floatRight = _useTableLayout.floatRight,
175
174
  width = _useTableLayout.width,
176
175
  shouldLastColAuto = _useTableLayout.shouldLastColAuto,
177
176
  scrollBarWidth = _useTableLayout.scrollBarWidth,
178
177
  scrollWidth = _useTableLayout.scrollWidth,
179
- resizeFlag = _useTableLayout.resizeFlag;
178
+ resizeFlag = _useTableLayout.resizeFlag,
179
+ registerFloatClass = _useTableLayout.registerFloatClass;
180
+
181
+ // 注册 floatLeft/floatRight 的 CSS class 名,供 checkFloat 直接操作 DOM
182
+ registerFloatClass(tableClasses.floatLeft, tableClasses.floatRight);
180
183
  var _useTableFilter = (0, _hooks.useTableFilter)({
181
184
  keygen: props.keygen,
182
185
  data: props.data,
@@ -327,7 +330,7 @@ function Table(props) {
327
330
  var handleBodyScroll = (0, _hooks.usePersistFn)(function (e) {
328
331
  var target = e.currentTarget;
329
332
  if (!target) return;
330
- layoutFunc.checkFloat();
333
+ layoutFunc.scheduleCheckFloat();
331
334
  if (isVirtualColumnEnabled) columnInfo.handleScroll({
332
335
  scrollLeft: target.scrollLeft
333
336
  });
@@ -354,7 +357,7 @@ function Table(props) {
354
357
  var handleVirtualScroll = (0, _hooks.usePersistFn)(function (info) {
355
358
  virtualInfo.handleScroll(info);
356
359
  if (isVirtualColumnEnabled) columnInfo.handleScroll(info);
357
- layoutFunc.checkFloat();
360
+ layoutFunc.scheduleCheckFloat();
358
361
  if (headMirrorScrollRef.current) {
359
362
  headMirrorScrollRef.current.scrollLeft = info.scrollLeft;
360
363
  }
@@ -744,6 +747,7 @@ function Table(props) {
744
747
  };
745
748
 
746
749
  // handle head and foot scroll
750
+ // 使用 passive: true 监听 wheel,不调用 preventDefault,避免阻塞合成器线程(优化 INP)
747
751
  var handleHeaderWheel = (0, _hooks.usePersistFn)(function (e) {
748
752
  var _theadRef$current2;
749
753
  var scrollEl = scrollRef.current;
@@ -754,7 +758,6 @@ function Table(props) {
754
758
  if (scrollLeft === scrollEl.scrollLeft) {
755
759
  return;
756
760
  }
757
- e.preventDefault();
758
761
  var left = Math.min(Math.max(scrollLeft, 0), max);
759
762
  scrollEl.scrollLeft = left;
760
763
  theadRef.current.parentElement.scrollLeft = left;
@@ -766,10 +769,10 @@ function Table(props) {
766
769
  syncHeaderScroll(((_scrollRef$current10 = scrollRef.current) === null || _scrollRef$current10 === void 0 ? void 0 : _scrollRef$current10.scrollLeft) || 0);
767
770
  }, [isScrollX, props.sticky, $empty]);
768
771
  (0, _react.useEffect)(function () {
769
- // 绑定 wheel 事件
772
+ // 绑定 wheel 事件(passive: true 不阻塞合成器线程)
770
773
  if (props.sticky && theadRef.current && theadRef.current.parentElement) {
771
774
  theadRef.current.parentElement.addEventListener('wheel', handleHeaderWheel, {
772
- passive: false
775
+ passive: true
773
776
  });
774
777
  }
775
778
  return function () {
@@ -836,7 +839,7 @@ function Table(props) {
836
839
  });
837
840
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
838
841
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
839
- className: (0, _classnames.default)(tableWrapperClass, _defineProperty(_defineProperty(_defineProperty({}, tableClasses.sticky, props.sticky), tableClasses.floatLeft, floatLeft), tableClasses.floatRight, floatRight)),
842
+ className: (0, _classnames.default)(tableWrapperClass, _defineProperty({}, tableClasses.sticky, props.sticky)),
840
843
  style: tableWrapperStyle
841
844
  }, selection.getTableProps()), {}, {
842
845
  ref: tableRef,
@@ -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,2CA22BxE"}
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,2CA42BxE"}
@@ -150,6 +150,7 @@ export default function Table(props) {
150
150
  theadRef: theadRef,
151
151
  tbodyRef: tbodyRef,
152
152
  scrollRef: scrollRef,
153
+ tableElRef: tableRef,
153
154
  columns: columns,
154
155
  data: props.data,
155
156
  dataChangeResize: !!props.dataChangeResize,
@@ -163,13 +164,15 @@ export default function Table(props) {
163
164
  colgroup = _useTableLayout.colgroup,
164
165
  isScrollY = _useTableLayout.isScrollY,
165
166
  isScrollX = _useTableLayout.isScrollX,
166
- floatLeft = _useTableLayout.floatLeft,
167
- floatRight = _useTableLayout.floatRight,
168
167
  width = _useTableLayout.width,
169
168
  shouldLastColAuto = _useTableLayout.shouldLastColAuto,
170
169
  scrollBarWidth = _useTableLayout.scrollBarWidth,
171
170
  scrollWidth = _useTableLayout.scrollWidth,
172
- resizeFlag = _useTableLayout.resizeFlag;
171
+ resizeFlag = _useTableLayout.resizeFlag,
172
+ registerFloatClass = _useTableLayout.registerFloatClass;
173
+
174
+ // 注册 floatLeft/floatRight 的 CSS class 名,供 checkFloat 直接操作 DOM
175
+ registerFloatClass(tableClasses.floatLeft, tableClasses.floatRight);
173
176
  var _useTableFilter = useTableFilter({
174
177
  keygen: props.keygen,
175
178
  data: props.data,
@@ -320,7 +323,7 @@ export default function Table(props) {
320
323
  var handleBodyScroll = usePersistFn(function (e) {
321
324
  var target = e.currentTarget;
322
325
  if (!target) return;
323
- layoutFunc.checkFloat();
326
+ layoutFunc.scheduleCheckFloat();
324
327
  if (isVirtualColumnEnabled) columnInfo.handleScroll({
325
328
  scrollLeft: target.scrollLeft
326
329
  });
@@ -347,7 +350,7 @@ export default function Table(props) {
347
350
  var handleVirtualScroll = usePersistFn(function (info) {
348
351
  virtualInfo.handleScroll(info);
349
352
  if (isVirtualColumnEnabled) columnInfo.handleScroll(info);
350
- layoutFunc.checkFloat();
353
+ layoutFunc.scheduleCheckFloat();
351
354
  if (headMirrorScrollRef.current) {
352
355
  headMirrorScrollRef.current.scrollLeft = info.scrollLeft;
353
356
  }
@@ -737,6 +740,7 @@ export default function Table(props) {
737
740
  };
738
741
 
739
742
  // handle head and foot scroll
743
+ // 使用 passive: true 监听 wheel,不调用 preventDefault,避免阻塞合成器线程(优化 INP)
740
744
  var handleHeaderWheel = usePersistFn(function (e) {
741
745
  var _theadRef$current2;
742
746
  var scrollEl = scrollRef.current;
@@ -747,7 +751,6 @@ export default function Table(props) {
747
751
  if (scrollLeft === scrollEl.scrollLeft) {
748
752
  return;
749
753
  }
750
- e.preventDefault();
751
754
  var left = Math.min(Math.max(scrollLeft, 0), max);
752
755
  scrollEl.scrollLeft = left;
753
756
  theadRef.current.parentElement.scrollLeft = left;
@@ -759,10 +762,10 @@ export default function Table(props) {
759
762
  syncHeaderScroll(((_scrollRef$current10 = scrollRef.current) === null || _scrollRef$current10 === void 0 ? void 0 : _scrollRef$current10.scrollLeft) || 0);
760
763
  }, [isScrollX, props.sticky, $empty]);
761
764
  useEffect(function () {
762
- // 绑定 wheel 事件
765
+ // 绑定 wheel 事件(passive: true 不阻塞合成器线程)
763
766
  if (props.sticky && theadRef.current && theadRef.current.parentElement) {
764
767
  theadRef.current.parentElement.addEventListener('wheel', handleHeaderWheel, {
765
- passive: false
768
+ passive: true
766
769
  });
767
770
  }
768
771
  return function () {
@@ -829,7 +832,7 @@ export default function Table(props) {
829
832
  });
830
833
  return /*#__PURE__*/_jsxs(_Fragment, {
831
834
  children: [/*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
832
- className: classNames(tableWrapperClass, _defineProperty(_defineProperty(_defineProperty({}, tableClasses.sticky, props.sticky), tableClasses.floatLeft, floatLeft), tableClasses.floatRight, floatRight)),
835
+ className: classNames(tableWrapperClass, _defineProperty({}, tableClasses.sticky, props.sticky)),
833
836
  style: tableWrapperStyle
834
837
  }, selection.getTableProps()), {}, {
835
838
  ref: tableRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.10.2-beta.3",
3
+ "version": "3.10.2-beta.5",
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.3",
13
+ "@sheinx/hooks": "3.10.2-beta.5",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.3.3"