shineout 3.7.5-beta.8 → 3.7.5-beta.9

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.7.5-beta.8'
525
+ version: '3.7.5-beta.9'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12234,7 +12234,7 @@ var handleStyle = function handleStyle(style) {
12234
12234
  };
12235
12235
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12236
12236
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12237
- /* harmony default export */ var version = ('3.7.5-beta.8');
12237
+ /* harmony default export */ var version = ('3.7.5-beta.9');
12238
12238
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12239
12239
 
12240
12240
 
@@ -40070,8 +40070,8 @@ var CascaderNode = function CascaderNode(props) {
40070
40070
  _useState2 = slicedToArray_default()(_useState, 2),
40071
40071
  loading = _useState2[0],
40072
40072
  setLoading = _useState2[1];
40073
- // const [activeState, setActiveState] = useState(false);
40074
40073
  var checkboxRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();
40074
+ var hasHandleSelectRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
40075
40075
  var isDisabled = datum.isDisabled(id);
40076
40076
  var children = data[childrenKey];
40077
40077
  var hasChildren = children && children.length > 0;
@@ -40112,13 +40112,17 @@ var CascaderNode = function CascaderNode(props) {
40112
40112
  }
40113
40113
  if (isHoverAble) {
40114
40114
  events.onMouseEnter = handlePathChange;
40115
- if (multiple) events.onClick = handleSelect;
40115
+ if (multiple) {
40116
+ events.onClick = handleSelect;
40117
+ hasHandleSelectRef.current = true;
40118
+ }
40116
40119
  } else if (isRealLeafNode && multiple) {
40117
40120
  // 非hover模式下: 末级节点支持整个节点区域点击选中checkbox
40118
40121
  events.onClick = function (e) {
40119
40122
  handleClick(e);
40120
40123
  handleSelect(e);
40121
40124
  };
40125
+ hasHandleSelectRef.current = true;
40122
40126
  }
40123
40127
  return events;
40124
40128
  };
@@ -40174,7 +40178,7 @@ var CascaderNode = function CascaderNode(props) {
40174
40178
  className: styles.optionCheckbox,
40175
40179
  checked: datum.getChecked(id),
40176
40180
  disabled: isDisabled,
40177
- onChange: isRealLeafNode && multiple ? undefined : handleChange
40181
+ onChange: hasHandleSelectRef.current ? undefined : handleChange
40178
40182
  }), renderContent(), renderIcon()]
40179
40183
  })
40180
40184
  }));
@@ -41097,44 +41101,25 @@ function getResetMore(onFilter, container, doms) {
41097
41101
  var hideMargin = parsePxToNumber(hideElStyle.marginLeft) + parsePxToNumber(hideElStyle.marginRight);
41098
41102
  var num = 0;
41099
41103
  var sumWidth = 0;
41100
- var itemWidthArr = items.map(function (item) {
41101
- var itemStyle = getComputedStyle(item);
41102
- var itemLen = item.offsetWidth + parsePxToNumber(itemStyle.marginLeft) + parsePxToNumber(itemStyle.marginRight);
41103
- sumWidth += itemLen;
41104
- return itemLen;
41105
- });
41106
- if (sumWidth <= contentWidth) {
41107
- num = -1;
41108
- } else {
41109
- var len = 0;
41110
- for (var i = 0; i < itemWidthArr.length; i++) {
41111
- var itemLen = itemWidthArr[i];
41112
- // number length
41113
- var resetNum = items.length - 1 - i;
41114
- var moreWidth = void 0;
41115
- if (resetNum <= 0) {
41116
- moreWidth = 0;
41117
- } else {
41118
- var reset = "+".concat(resetNum);
41119
- hideEl.childNodes[0].innerText = reset;
41120
- // (+num) width
41121
- moreWidth = hideEl.offsetWidth + hideMargin;
41122
- }
41123
- len += itemLen;
41124
- if (len > contentWidth - moreWidth) {
41125
- break;
41126
- }
41127
- num += 1;
41128
- if (i === items.length - 1) {
41129
- // not show more
41130
- num = -1;
41131
- }
41104
+ for (var i = 0; i < doms.length; i++) {
41105
+ var _item2 = doms[i];
41106
+ var itemStyle = getComputedStyle(_item2);
41107
+ var itemWidth = _item2.offsetWidth + parsePxToNumber(itemStyle.marginLeft) + parsePxToNumber(itemStyle.marginRight);
41108
+ sumWidth += itemWidth;
41109
+ var moreWidth = 0;
41110
+ var resetNum = items.length - 1 - i;
41111
+ if (resetNum > 0) {
41112
+ var reset = "+".concat(resetNum);
41113
+ hideEl.childNodes[0].innerText = reset;
41114
+ moreWidth = hideEl.offsetWidth + hideMargin;
41115
+ }
41116
+ if (sumWidth > contentWidth - moreWidth) {
41117
+ num = i;
41118
+ break;
41132
41119
  }
41120
+ num = -1;
41133
41121
  }
41134
- // at least show one
41135
- if (num === 0 && itemWidthArr[0]) {
41136
- num = 1;
41137
- }
41122
+ ;
41138
41123
  return num;
41139
41124
  }
41140
41125
  var More = function More(props) {
@@ -41156,16 +41141,7 @@ var More = function More(props) {
41156
41141
  var shouldShowMore = showNum < 0 || showNum >= data.length;
41157
41142
  var before = [];
41158
41143
  var after = [];
41159
- var itemsLength = 0;
41160
- var tagStyle = shouldShowMore ? {
41161
- position: 'absolute',
41162
- zIndex: -100,
41163
- userSelect: 'none',
41164
- msUserSelect: 'none',
41165
- contain: 'layout',
41166
- opacity: 0,
41167
- pointerEvents: 'none'
41168
- } : {};
41144
+ var afterLength = 0;
41169
41145
  if (!shouldShowMore) {
41170
41146
  before = new Array(showNum).fill(undefined).map(function (_item, index) {
41171
41147
  return data[index];
@@ -41173,9 +41149,9 @@ var More = function More(props) {
41173
41149
  after = new Array(data.length - showNum).fill(undefined).map(function (_item, index) {
41174
41150
  return data[showNum + index];
41175
41151
  });
41176
- itemsLength = after.length;
41152
+ afterLength = after.length;
41177
41153
  }
41178
- if (showNum < 0 || showNum >= data.length) {
41154
+ if (shouldShowMore) {
41179
41155
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
41180
41156
  children: [data, /*#__PURE__*/(0,jsx_runtime.jsx)(src_tag_tag, {
41181
41157
  className: styles.tag,
@@ -41202,10 +41178,9 @@ var More = function More(props) {
41202
41178
  className: styles.tag,
41203
41179
  jssStyle: jssStyle,
41204
41180
  size: size,
41205
- style: tagStyle,
41206
41181
  mode: visible ? 'fill' : 'bright',
41207
41182
  color: visible ? 'info' : 'default',
41208
- children: shouldShowMore ? '+' : "+".concat(itemsLength)
41183
+ children: shouldShowMore ? '+' : "+".concat(afterLength)
41209
41184
  }, 'more'), compressed !== 'hide-popover' && /*#__PURE__*/(0,jsx_runtime.jsx)(src_popover_popover, {
41210
41185
  jssStyle: jssStyle,
41211
41186
  className: compressedClassName,
@@ -41303,7 +41278,11 @@ var result_Result = function Result(props) {
41303
41278
  setShouldResetMore = _useState4[1];
41304
41279
  var render = useRender();
41305
41280
  var resultRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
41306
- var prevMore = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(more);
41281
+ var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
41282
+ prevMore: more,
41283
+ maxMore: 0
41284
+ }),
41285
+ context = _useRef.current;
41307
41286
  var removeLock = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
41308
41287
  var showInput = allowOnFilter;
41309
41288
  var mounted = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
@@ -41506,7 +41485,6 @@ var result_Result = function Result(props) {
41506
41485
  data: result,
41507
41486
  datas: renderMultipleResult.datas,
41508
41487
  size: size,
41509
- more: moreNumber,
41510
41488
  compressed: compressed,
41511
41489
  renderCompressed: renderCompressed,
41512
41490
  compressedClassName: compressedClassName,
@@ -41536,13 +41514,22 @@ var result_Result = function Result(props) {
41536
41514
  }
41537
41515
  return result;
41538
41516
  };
41539
- var handleResetMore = function handleResetMore() {
41517
+ var handleResetMore = function handleResetMore(valueLength) {
41540
41518
  if (!compressed) return;
41541
41519
  if (isCompressedBound()) return;
41542
41520
  if (removeLock.current) {
41543
41521
  removeLock.current = false;
41544
41522
  return;
41545
41523
  }
41524
+
41525
+ // 性能优化:当选项数量远超容器承载能力时,跳过昂贵的DOM计算
41526
+ // 在1000+选项时,重新计算会导致INP超过1000ms
41527
+ var hasExistingCompression = context.prevMore > 0;
41528
+ var hasValidEstimate = context.maxMore > 0;
41529
+ var exceedsCapacity = valueLength && valueLength > context.maxMore;
41530
+ if (hasExistingCompression && hasValidEstimate && exceedsCapacity) {
41531
+ return; // 跳过重新计算,保持现有的压缩状态
41532
+ }
41546
41533
  setMore(-1);
41547
41534
  setShouldResetMore(true);
41548
41535
  };
@@ -41599,7 +41586,7 @@ var result_Result = function Result(props) {
41599
41586
  }
41600
41587
  }, [focus, multiple]);
41601
41588
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useLayoutEffect)(function () {
41602
- handleResetMore();
41589
+ handleResetMore((valueProp === null || valueProp === void 0 ? void 0 : valueProp.length) || 0);
41603
41590
  }, [valueProp, data]);
41604
41591
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
41605
41592
  // datum.getDataByValues(value); 需要等待 useTree useEffect 执行完毕 才能获取到
@@ -41610,7 +41597,7 @@ var result_Result = function Result(props) {
41610
41597
  var tagClassName = ".".concat(styles.tag.split(' ')[0]);
41611
41598
  if (shouldResetMore && result_isArray(value) && (value || []).length) {
41612
41599
  var newMore = getResetMore(showInput, resultRef.current, resultRef.current.querySelectorAll(tagClassName));
41613
- prevMore.current = newMore;
41600
+ context.prevMore = newMore;
41614
41601
  setMore(newMore);
41615
41602
  setShouldResetMore(false);
41616
41603
  } else {
@@ -41624,6 +41611,7 @@ var result_Result = function Result(props) {
41624
41611
  if (!resultRef.current) return;
41625
41612
  if (!compressed) return;
41626
41613
  if (isCompressedBound()) return;
41614
+ context.maxMore = Math.floor(resultRef.current.clientWidth / 20);
41627
41615
  var cancelObserver = addResizeObserver(resultRef.current, handleResetMore, {
41628
41616
  direction: 'x'
41629
41617
  });
@@ -71659,7 +71647,7 @@ var upload_interface = __webpack_require__(8821);
71659
71647
 
71660
71648
 
71661
71649
  /* harmony default export */ var src_0 = ({
71662
- version: '3.7.5-beta.8'
71650
+ version: '3.7.5-beta.9'
71663
71651
  });
71664
71652
  }();
71665
71653
  /******/ return __webpack_exports__;