shineout 3.10.3-beta.4 → 3.10.3-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.
package/cjs/index.js CHANGED
@@ -545,5 +545,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
545
545
  // 此文件由脚本自动生成,请勿直接修改。
546
546
  // This file was generated automatically by a script. Please do not modify it directly.
547
547
  var _default = exports.default = {
548
- version: '3.10.3-beta.4'
548
+ version: '3.10.3-beta.5'
549
549
  };
package/dist/shineout.js CHANGED
@@ -13736,7 +13736,7 @@ var handleStyle = function handleStyle(style) {
13736
13736
  };
13737
13737
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
13738
13738
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
13739
- /* harmony default export */ var version = ('3.10.3-beta.4');
13739
+ /* harmony default export */ var version = ('3.10.3-beta.5');
13740
13740
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
13741
13741
 
13742
13742
 
@@ -46691,7 +46691,8 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
46691
46691
 
46692
46692
  // TODO: Object.values(props) 作为 deps 是反模式,value/prediction 等变化都会使 datum 引用失效。
46693
46693
  // 精确依赖应为 [props.data](方法均为 usePersistFn,引用稳定)。
46694
- // 待 Tbody/Tr 加 React.memo 后一起改,届时 datum 引用稳定才能真正减少 re-render。
46694
+ // 注意:Table 开启 rowMemo 时 Tbody 会做 memo,非受控勾选时 Table 的 props 不变,
46695
+ // 行的勾选状态只能靠 datum 引用变化刷新。收窄 deps 前需要先给 Tbody 提供其他刷新依据(如 value)。
46695
46696
  var func = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
46696
46697
  return {
46697
46698
  add: add,
@@ -58315,7 +58316,8 @@ var useListSelect = function useListSelect(props) {
58315
58316
  });
58316
58317
 
58317
58318
  // TODO: Object.values(props) 作为 deps 是反模式。精确依赖应为 [datum, multiple]。
58318
- // 待 Tbody/Tr 加 React.memo 后一起改。
58319
+ // 注意:Table 开启 rowMemo 时 Tbody 会做 memo,非受控勾选时行的勾选状态只能靠 result 引用变化刷新,
58320
+ // 收窄 deps 前需要先给 Tbody 提供其他刷新依据(见 use-list-select-multiple)。
58319
58321
  var result = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
58320
58322
  if (!multiple) {
58321
58323
  return objectSpread2_default()(objectSpread2_default()({}, datum), {}, {
@@ -70048,6 +70050,65 @@ function Td(props) {
70048
70050
  children: renderContent(props.col, props.data)
70049
70051
  }, col.key);
70050
70052
  }
70053
+ ;// CONCATENATED MODULE: ../base/src/table/fixed-style.ts
70054
+
70055
+
70056
+ var fixed_style_toNum = toNum;
70057
+
70058
+ // 表体固定列的 sticky 偏移以 CSS 变量的形式写在 tbody 所在的 table 上,单元格只引用变量。
70059
+ // 列宽测量、横向滚动状态变化时只需更新 table 的 style,单元格的 style 不变,行无需重渲染。
70060
+ // 每个 Table 都会在自己的 table 上重新声明变量,嵌套表格不会继承到外层的值。
70061
+ // position: sticky 必须内联:样式中 `table td { position: relative }` 的优先级高于 cellFixedRight 类名。
70062
+ // 未出现横向滚动时偏移为 auto,sticky 不会吸附,效果与原先不输出固定样式一致。
70063
+ var getLeftVar = function getLeftVar(index) {
70064
+ return "--soui-table-fixed-left-".concat(index);
70065
+ };
70066
+ // right 偏移取决于单元格的结束列(index + colSpan),按结束列声明
70067
+ var getRightVar = function getRightVar(end) {
70068
+ return "--soui-table-fixed-right-".concat(end);
70069
+ };
70070
+ var cellStyleCache = new Map();
70071
+ var getCellFixedStyle = function getCellFixedStyle(fixed, index, colSpan, columnCount, isRtl) {
70072
+ if (fixed !== 'left' && fixed !== 'right') return undefined;
70073
+ var end = Math.min(index + (colSpan || 1), columnCount);
70074
+ var varName = fixed === 'left' ? getLeftVar(index) : getRightVar(end);
70075
+ var key = "".concat(varName, "-").concat(isRtl ? 'rtl' : 'ltr');
70076
+ var style = cellStyleCache.get(key);
70077
+ if (!style) {
70078
+ var side = fixed === 'left' !== isRtl ? 'left' : 'right';
70079
+ style = defineProperty_default()({
70080
+ position: 'sticky'
70081
+ }, side, "var(".concat(varName, ")"));
70082
+ cellStyleCache.set(key, style);
70083
+ }
70084
+ return style;
70085
+ };
70086
+ var getFixedVarsStyle = function getFixedVarsStyle(columns, colgroup, isScrollX) {
70087
+ var rightStart = -1;
70088
+ var leftIndexes = [];
70089
+ columns.forEach(function (col) {
70090
+ if (col.fixed === 'left') leftIndexes.push(col.index);
70091
+ if (col.fixed === 'right' && (rightStart === -1 || col.index < rightStart)) {
70092
+ rightStart = col.index;
70093
+ }
70094
+ });
70095
+ if (!leftIndexes.length && rightStart === -1) return undefined;
70096
+ var style = {};
70097
+ var sum = function sum(start, end) {
70098
+ return colgroup.slice(start, end).reduce(function (a, b) {
70099
+ return a + fixed_style_toNum(b);
70100
+ }, 0);
70101
+ };
70102
+ leftIndexes.forEach(function (index) {
70103
+ style[getLeftVar(index)] = isScrollX ? "".concat(sum(0, index), "px") : 'auto';
70104
+ });
70105
+ if (rightStart > -1) {
70106
+ for (var end = rightStart + 1; end <= columns.length; end++) {
70107
+ style[getRightVar(end)] = isScrollX ? "".concat(sum(end, colgroup.length), "px") : 'auto';
70108
+ }
70109
+ }
70110
+ return style;
70111
+ };
70051
70112
  ;// CONCATENATED MODULE: ../base/src/table/tr.tsx
70052
70113
 
70053
70114
 
@@ -70067,8 +70128,6 @@ function Td(props) {
70067
70128
 
70068
70129
 
70069
70130
 
70070
-
70071
- var tr_toNum = toNum;
70072
70131
  var Tr = function Tr(props) {
70073
70132
  var _props$rowClassName;
70074
70133
  var treeFunc = props.treeFunc,
@@ -70078,29 +70137,9 @@ var Tr = function Tr(props) {
70078
70137
  var expandRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
70079
70138
  var config = useConfig();
70080
70139
  var isRtl = config.direction === 'rtl';
70081
- var getFixedStyle = function getFixedStyle(fixed, index, colSpan) {
70082
- if (!props.isScrollX) return;
70083
- if (fixed === 'left') {
70084
- var left = props.colgroup.slice(0, index).reduce(function (a, b) {
70085
- return tr_toNum(a) + tr_toNum(b);
70086
- }, 0);
70087
- return defineProperty_default()({
70088
- position: 'sticky'
70089
- }, isRtl ? 'right' : 'left', left);
70090
- }
70091
- if (fixed === 'right') {
70092
- var right = props.colgroup.slice(index + colSpan).reduce(function (a, b) {
70093
- return tr_toNum(a) + tr_toNum(b);
70094
- }, 0);
70095
- return defineProperty_default()({
70096
- position: 'sticky'
70097
- }, isRtl ? 'left' : 'right', right);
70098
- }
70099
- return undefined;
70100
- };
70101
70140
  var getTdStyle = function getTdStyle(column, colSpan) {
70102
- var index = column.index;
70103
- var fixedStyle = getFixedStyle(column.fixed, index, colSpan);
70141
+ // 固定列偏移引用 table 上的 CSS 变量,列宽/横向滚动状态变化时行无需重渲染
70142
+ var fixedStyle = getCellFixedStyle(column.fixed, column.index, colSpan, props.columns.length, isRtl);
70104
70143
  if (!fixedStyle && !column.style) return;
70105
70144
  return objectSpread2_default()(objectSpread2_default()({}, column.style), fixedStyle);
70106
70145
  };
@@ -70140,40 +70179,23 @@ var Tr = function Tr(props) {
70140
70179
  _useState2 = slicedToArray_default()(_useState, 2),
70141
70180
  isExpandLoading = _useState2[0],
70142
70181
  setIsExpandLoading = _useState2[1];
70143
- var innerExpandClick = usePersistFn( /*#__PURE__*/function () {
70144
- var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(showLoader) {
70145
- return regeneratorRuntime_default()().wrap(function _callee$(_context) {
70146
- while (1) switch (_context.prev = _context.next) {
70147
- case 0:
70148
- if (!(showLoader && props.loader && typeof props.loader === 'function')) {
70149
- _context.next = 11;
70150
- break;
70151
- }
70152
- setIsExpandLoading(true);
70153
- _context.prev = 2;
70154
- _context.next = 5;
70155
- return props.loader(props.rawData, props.rowIndex);
70156
- case 5:
70157
- treeFunc.handleTreeExpand(props.rawData, props.rowIndex);
70158
- case 6:
70159
- _context.prev = 6;
70160
- setIsExpandLoading(false);
70161
- return _context.finish(6);
70162
- case 9:
70163
- _context.next = 12;
70164
- break;
70165
- case 11:
70166
- treeFunc.handleTreeExpand(props.rawData, props.rowIndex);
70167
- case 12:
70168
- case "end":
70169
- return _context.stop();
70170
- }
70171
- }, _callee, null, [[2,, 6, 9]]);
70172
- }));
70173
- return function (_x) {
70174
- return _ref3.apply(this, arguments);
70175
- };
70176
- }());
70182
+
70183
+ // 不使用 async 函数:编译产物会在每次渲染时为每一行创建 regenerator 状态机,大数据量下开销可观
70184
+ var innerExpandClick = usePersistFn(function (showLoader) {
70185
+ var loader = props.loader;
70186
+ if (showLoader && loader && typeof loader === 'function') {
70187
+ setIsExpandLoading(true);
70188
+ // new Promise 包裹:loader 同步抛错或返回非 Promise 时,与原 await 写法行为一致
70189
+ return new Promise(function (resolve) {
70190
+ resolve(loader(props.rawData, props.rowIndex));
70191
+ }).then(function () {
70192
+ treeFunc.handleTreeExpand(props.rawData, props.rowIndex);
70193
+ }).finally(function () {
70194
+ setIsExpandLoading(false);
70195
+ });
70196
+ }
70197
+ treeFunc.handleTreeExpand(props.rawData, props.rowIndex);
70198
+ });
70177
70199
  var renderTreeExpand = function renderTreeExpand(content) {
70178
70200
  var treeIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 22;
70179
70201
  var level = props.treeExpandLevel.get(props.originKey) || 0;
@@ -70515,7 +70537,19 @@ var isTrPropsEqual = function isTrPropsEqual(prev, next) {
70515
70537
 
70516
70538
 
70517
70539
 
70518
- /* harmony default export */ var tbody = (function (props) {
70540
+ var hasExpandColumn = function hasExpandColumn(props) {
70541
+ return !!props.expandHideCol || (props.columns || []).some(function (col) {
70542
+ return col.type === 'expand' || col.type === 'row-expand';
70543
+ });
70544
+ };
70545
+
70546
+ // bodyScrollWidth / resizeFlag 在行内只用于虚拟列表上报行高;
70547
+ // 展开行渲染时会读取容器宽度下发给嵌套表格,有展开列时也需要随之重渲染。
70548
+ // 其余场景不再下发,Table 布局状态变化时 Tbody / Tr 都可以跳过渲染
70549
+ var needLayoutProps = function needLayoutProps(props) {
70550
+ return !!props.virtual || hasExpandColumn(props);
70551
+ };
70552
+ var Tbody = function Tbody(props) {
70519
70553
  var _jssStyle$table, _jssStyle$input, _jssStyle$select, _jssStyle$datePicker, _jssStyle$treeSelect, _jssStyle$switch, _jssStyle$checkbox, _jssStyle$radio, _jssStyle$cascader;
70520
70554
  var _props$columns = props.columns,
70521
70555
  columns = _props$columns === void 0 ? [] : _props$columns,
@@ -70524,6 +70558,7 @@ var isTrPropsEqual = function isTrPropsEqual(prev, next) {
70524
70558
  currentColIndex = props.currentColIndex,
70525
70559
  _props$hover = props.hover,
70526
70560
  hover = _props$hover === void 0 ? true : _props$hover;
70561
+ var passLayout = needLayoutProps(props);
70527
70562
  var _useTableExpand = use_table_expand({
70528
70563
  columns: props.columns,
70529
70564
  expandKeys: props.expandKeys,
@@ -70572,11 +70607,9 @@ var isTrPropsEqual = function isTrPropsEqual(prev, next) {
70572
70607
  originKey: originKey,
70573
70608
  row: rowData[index],
70574
70609
  columns: columns,
70575
- isScrollX: props.isScrollX,
70576
70610
  jssStyle: props.jssStyle,
70577
70611
  tableClasses: tableClasses,
70578
70612
  preventClasses: preventClasses,
70579
- colgroup: props.colgroup,
70580
70613
  rowClassName: props.rowClassName,
70581
70614
  rawData: item,
70582
70615
  rowIndex: rowIndex,
@@ -70605,9 +70638,9 @@ var isTrPropsEqual = function isTrPropsEqual(prev, next) {
70605
70638
  onRowClick: props.onRowClick,
70606
70639
  rowEvents: props.rowEvents,
70607
70640
  disabled: props.datum.disabledCheck(item),
70608
- bodyScrollWidth: props.bodyScrollWidth,
70641
+ bodyScrollWidth: passLayout ? props.bodyScrollWidth : undefined,
70609
70642
  scrollRef: props.scrollRef,
70610
- resizeFlag: props.resizeFlag,
70643
+ resizeFlag: passLayout ? props.resizeFlag : undefined,
70611
70644
  treeCheckAll: props.treeCheckAll,
70612
70645
  onCellClick: props.onCellClick,
70613
70646
  virtual: props.virtual,
@@ -70625,17 +70658,32 @@ var isTrPropsEqual = function isTrPropsEqual(prev, next) {
70625
70658
  return renderRow(item, index);
70626
70659
  })
70627
70660
  });
70628
- if (props.virtual === 'lazy') {
70629
- return useComponentMemo(function () {
70630
- return $tbody;
70631
- }, [currentRowIndex, currentColIndex, props.data], function (prev, next) {
70632
- return prev.some(function (_, index) {
70633
- return !shallow_equal_shallowEqual(prev === null || prev === void 0 ? void 0 : prev[index], next === null || next === void 0 ? void 0 : next[index]);
70634
- }) || !props.scrolling;
70635
- });
70636
- }
70637
- return $tbody;
70638
- });
70661
+
70662
+ // 未传 shouldUpdate 时直接返回最新结果,非 lazy 模式下行为与不做缓存一致
70663
+ return useComponentMemo(function () {
70664
+ return $tbody;
70665
+ }, [currentRowIndex, currentColIndex, props.data], props.virtual === 'lazy' ? function (prev, next) {
70666
+ return prev.some(function (_, index) {
70667
+ return !shallow_equal_shallowEqual(prev === null || prev === void 0 ? void 0 : prev[index], next === null || next === void 0 ? void 0 : next[index]);
70668
+ }) || !props.scrolling;
70669
+ } : undefined);
70670
+ };
70671
+
70672
+ // 语义化样式每次渲染都会生成新对象,按内容比较
70673
+ var SEM_STYLE_KEYS = ['bodyRowSemStyle', 'bodyCellSemStyle'];
70674
+ var LAYOUT_KEYS = ['bodyScrollWidth', 'resizeFlag'];
70675
+
70676
+ // 仅在开启 rowMemo 时生效,未开启时始终返回 false,行为与不做 memo 完全一致。
70677
+ // rowMemo 下 Tbody 的 props 不变时,下发给每一行的 props 也不变,行本来就会被 Tr 的 memo 跳过;
70678
+ // 在 Tbody 这层直接跳过,省去 Table 自身布局状态(列宽测量、横向滚动、滚动阴影等)变化时逐行生成元素和比较 props 的开销
70679
+ var isTbodyPropsEqual = function isTbodyPropsEqual(prev, next) {
70680
+ if (!prev.rowMemo || !next.rowMemo) return false;
70681
+ var skip = needLayoutProps(next) ? SEM_STYLE_KEYS : [].concat(SEM_STYLE_KEYS, LAYOUT_KEYS);
70682
+ return shallow_equal_shallowEqual(prev, next, {
70683
+ skip: skip
70684
+ }) && shallow_equal_shallowEqual(prev.bodyRowSemStyle, next.bodyRowSemStyle) && shallow_equal_shallowEqual(prev.bodyCellSemStyle, next.bodyCellSemStyle);
70685
+ };
70686
+ /* harmony default export */ var tbody = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().memo(Tbody, isTbodyPropsEqual));
70639
70687
  ;// CONCATENATED MODULE: ../base/src/table/tfoot.tsx
70640
70688
 
70641
70689
 
@@ -70776,6 +70824,7 @@ var table_excluded = ["data"];
70776
70824
 
70777
70825
 
70778
70826
 
70827
+
70779
70828
 
70780
70829
  var table_devUseWarning = devUseWarning;
70781
70830
  var table_emptyArr = [];
@@ -71132,6 +71181,10 @@ function Table(props) {
71132
71181
  tableLayout: 'fixed'
71133
71182
  };
71134
71183
  }, [width]);
71184
+ // 表体所在的 table 额外声明固定列偏移的 CSS 变量,单元格只引用变量
71185
+ var bodyTableStyle = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
71186
+ return objectSpread2_default()(objectSpread2_default()({}, tableStyle), getFixedVarsStyle(columns, colgroup, isScrollX));
71187
+ }, [tableStyle, columns, colgroup, isScrollX]);
71135
71188
  var renderTable = function renderTable() {
71136
71189
  var _props$summary, _sticky$top, _props$data2;
71137
71190
  var Group = /*#__PURE__*/(0,jsx_runtime.jsx)(table_colgroup, {
@@ -71149,8 +71202,6 @@ function Table(props) {
71149
71202
  data: treeData,
71150
71203
  treeExpandLevel: treeExpandLevel,
71151
71204
  treeFunc: treeFunc,
71152
- colgroup: colgroup,
71153
- isScrollX: isScrollX,
71154
71205
  expandHideCol: expandHideCol,
71155
71206
  keygen: props.keygen,
71156
71207
  rowClassName: props.rowClassName,
@@ -71358,7 +71409,7 @@ function Table(props) {
71358
71409
  },
71359
71410
  children: $headTable
71360
71411
  }), !!((_props$data3 = props.data) !== null && _props$data3 !== void 0 && _props$data3.length) && /*#__PURE__*/(0,jsx_runtime.jsxs)("table", {
71361
- style: objectSpread2_default()(objectSpread2_default()({}, tableStyle), {}, {
71412
+ style: objectSpread2_default()(objectSpread2_default()({}, bodyTableStyle), {}, {
71362
71413
  transform: virtualInfo.translateStyle
71363
71414
  }),
71364
71415
  ref: tbodyRef,
@@ -71388,7 +71439,7 @@ function Table(props) {
71388
71439
  className: tableClasses === null || tableClasses === void 0 ? void 0 : tableClasses.bodyWrapper,
71389
71440
  onScroll: handleBodyScroll,
71390
71441
  children: /*#__PURE__*/(0,jsx_runtime.jsxs)("table", {
71391
- style: tableStyle,
71442
+ style: bodyTableStyle,
71392
71443
  ref: tbodyRef,
71393
71444
  children: [Group, /*#__PURE__*/(0,jsx_runtime.jsx)(tbody, objectSpread2_default()({}, bodyCommonProps)), showFoot && /*#__PURE__*/(0,jsx_runtime.jsx)(tfoot, objectSpread2_default()({}, footCommonProps))]
71394
71445
  })
@@ -71419,7 +71470,7 @@ function Table(props) {
71419
71470
  tableRef: tableRef,
71420
71471
  setFakeVirtual: scrollAble ? undefined : setFakeVirtual,
71421
71472
  children: [!props.hideHeader && !props.sticky && $headTable, !!((_props$data5 = props.data) !== null && _props$data5 !== void 0 && _props$data5.length) && /*#__PURE__*/(0,jsx_runtime.jsxs)("table", {
71422
- style: objectSpread2_default()(objectSpread2_default()({}, tableStyle), {}, {
71473
+ style: objectSpread2_default()(objectSpread2_default()({}, bodyTableStyle), {}, {
71423
71474
  transform: virtualInfo.translateStyle
71424
71475
  }),
71425
71476
  ref: tbodyRef,
@@ -71450,7 +71501,7 @@ function Table(props) {
71450
71501
  className: tableClasses === null || tableClasses === void 0 ? void 0 : tableClasses.bodyWrapper,
71451
71502
  onScroll: handleBodyScroll,
71452
71503
  children: /*#__PURE__*/(0,jsx_runtime.jsxs)("table", {
71453
- style: objectSpread2_default()({}, tableStyle),
71504
+ style: bodyTableStyle,
71454
71505
  ref: tbodyRef,
71455
71506
  children: [Group, !props.hideHeader && /*#__PURE__*/(0,jsx_runtime.jsx)(thead, objectSpread2_default()({}, headCommonProps)), bodyCommonProps.data.length === 0 ? /*#__PURE__*/(0,jsx_runtime.jsx)(TbodyEmpty, {
71456
71507
  columns: columns,
@@ -80292,7 +80343,7 @@ var watermark_interface = __webpack_require__(6640);
80292
80343
 
80293
80344
 
80294
80345
  /* harmony default export */ var src_0 = ({
80295
- version: '3.10.3-beta.4'
80346
+ version: '3.10.3-beta.5'
80296
80347
  });
80297
80348
  }();
80298
80349
  /******/ return __webpack_exports__;