shineout 3.9.3-beta.9 → 3.9.4-beta.1

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.3-beta.9'
525
+ version: '3.9.4-beta.1'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12401,7 +12401,7 @@ var handleStyle = function handleStyle(style) {
12401
12401
  };
12402
12402
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12403
12403
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12404
- /* harmony default export */ var version = ('3.9.3-beta.9');
12404
+ /* harmony default export */ var version = ('3.9.4-beta.1');
12405
12405
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12406
12406
 
12407
12407
 
@@ -41017,13 +41017,32 @@ var useTree = function useTree(props) {
41017
41017
  }
41018
41018
  });
41019
41019
  };
41020
+ var getChildrenFromTiledData = function getChildrenFromTiledData(id) {
41021
+ if (!props.tiledData) return undefined;
41022
+ var findById = function findById(data, targetId) {
41023
+ for (var i = 0; i < data.length; i++) {
41024
+ var current = data[i];
41025
+ var currentId = getKey(current, '', i);
41026
+ if (currentId === targetId) return current;
41027
+ if (current[childrenKey]) {
41028
+ var found = findById(current[childrenKey], targetId);
41029
+ if (found) return found;
41030
+ }
41031
+ }
41032
+ return undefined;
41033
+ };
41034
+ var item = findById(props.tiledData, id);
41035
+ return item === null || item === void 0 ? void 0 : item[childrenKey];
41036
+ };
41020
41037
  var insertFlat = function insertFlat(id) {
41021
41038
  var item = getDataById(id);
41022
41039
  if (isUnMatchedData(item)) return;
41023
41040
  if (!item) return;
41024
41041
  var status = context.dataFlatStatusMap.get(id);
41025
41042
  if (!status) return;
41026
- var childrenData = item[childrenKey];
41043
+
41044
+ // 优先从 tiledData 中获取子节点数据,如果不存在则使用原始数据
41045
+ var childrenData = props.tiledData ? getChildrenFromTiledData(id) || [] : item[childrenKey];
41027
41046
  var insertStartNode = dataFlat.find(function (item) {
41028
41047
  return item.id === id;
41029
41048
  });
@@ -41141,6 +41160,7 @@ var useTree = function useTree(props) {
41141
41160
  if (!props.tiledData) return;
41142
41161
  var tiledFlatData = initFlatData(props.tiledData, [], 1);
41143
41162
  setDataFlat(tiledFlatData);
41163
+ // context.dataFlatStatusMap = new Map();
41144
41164
  }, [props.tiledData]);
41145
41165
  var datum = use_latest_obj({
41146
41166
  get: get,
@@ -44172,7 +44192,12 @@ var useFieldSetConsumer = function useFieldSetConsumer(props) {
44172
44192
  path = _React$useContext.path,
44173
44193
  validateFieldSet = _React$useContext.validateFieldSet;
44174
44194
  var bind = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useMemo(function () {
44175
- return path ? (props.bind || []).concat(path) : props.bind;
44195
+ var _bind = path ? (props.bind || []).concat(path) : props.bind;
44196
+ // 只有当路径中包含超过1个索引时才需要去掉最后一个索引
44197
+ return _bind === null || _bind === void 0 ? void 0 : _bind.map(function (b) {
44198
+ var indexCount = (b.match(/\[\d+\]/g) || []).length;
44199
+ return indexCount > 1 ? b.replace(/\[\d+\]$/, '') : b;
44200
+ });
44176
44201
  }, [path, props.bind]);
44177
44202
  var name = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useMemo(function () {
44178
44203
  return extendName(path, props.name);
@@ -47428,15 +47453,24 @@ var useDate = function useDate(props) {
47428
47453
  var getTimeStr = function getTimeStr() {
47429
47454
  var format = props.format,
47430
47455
  type = props.type;
47431
- if (!props.value) return '';
47432
47456
  if (type !== 'datetime' || !format) return '';
47433
- if (/^[X|x]$/.test(format)) {
47457
+ if (/^[X|x]$/.test(util.compatibleFmt(format))) {
47434
47458
  format = 'HH:mm:ss';
47435
47459
  } else {
47436
47460
  var match = format.match(/[H|h].*/);
47437
47461
  // eslint-disable-next-line
47438
47462
  if (match) format = match[0];
47439
47463
  }
47464
+
47465
+ // 当不存在 props.value 时,根据 format 格式返回默认时间字符串
47466
+ if (!props.value) {
47467
+ return format.replace(/[Hh]+/g, '00') // HH/hh -> 00
47468
+ .replace(/m+/g, '00') // mm -> 00
47469
+ .replace(/s+/g, '00') // ss -> 00
47470
+ .replace(/S+/g, '0') // SSS -> 0
47471
+ .replace(/A/g, 'AM') // A -> AM
47472
+ .replace(/a/g, 'am'); // a -> am
47473
+ }
47440
47474
  return util.format(props.value, format, options);
47441
47475
  };
47442
47476
  var isInRange = function isInRange(date) {
@@ -57789,7 +57823,7 @@ var TreeVirtual = function TreeVirtual(props) {
57789
57823
 
57790
57824
 
57791
57825
 
57792
- var tree_excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "virtual", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "rootStyle", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "ignoreSetFlat", "dragHoverExpand", "active", "setActive", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "datum", "rowsInView", "actionOnClick", "tiledData", "height"];
57826
+ var tree_excluded = ["jssStyle", "line", "childrenKey", "data", "value", "mode", "keygen", "virtual", "expanded", "expandIcons", "iconClass", "leafClass", "nodeClass", "contentClass", "rootStyle", "renderItem", "defaultValue", "dataUpdate", "childrenClass", "defaultExpandAll", "defaultExpanded", "parentClickExpand", "doubleClickExpand", "dragImageSelector", "dragImageStyle", "dragSibling", "unmatch", "ignoreSetFlat", "dragHoverExpand", "active", "setActive", "disabled", "inlineNode", "highlight", "className", "onClick", "loader", "getDatum", "onDrop", "onExpand", "onChange", "onDragEnd", "onDragLeave", "onDragOver", "onDragStart", "datum", "rowsInView", "actionOnClick", "tiledData", "height", "leafIcon"];
57793
57827
 
57794
57828
 
57795
57829
 
@@ -57856,6 +57890,7 @@ var Tree = function Tree(props) {
57856
57890
  actionOnClick = props.actionOnClick,
57857
57891
  tiledData = props.tiledData,
57858
57892
  height = props.height,
57893
+ leafIcon = props.leafIcon,
57859
57894
  rest = objectWithoutProperties_default()(props, tree_excluded);
57860
57895
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(propActive),
57861
57896
  _useState2 = slicedToArray_default()(_useState, 2),
@@ -57890,7 +57925,8 @@ var Tree = function Tree(props) {
57890
57925
  keygen: keygen,
57891
57926
  virtual: virtual,
57892
57927
  onExpand: onExpandProp,
57893
- datum: propsDatum
57928
+ datum: propsDatum,
57929
+ tiledData: props.filteredData
57894
57930
  }),
57895
57931
  datum = _useTree.datum,
57896
57932
  expanded = _useTree.expanded,
@@ -58001,7 +58037,7 @@ var Tree = function Tree(props) {
58001
58037
  var realHeight = getHeight();
58002
58038
  if (!realHeight) return null;
58003
58039
  return /*#__PURE__*/(0,jsx_runtime.jsx)(tree_virtual, objectSpread2_default()(objectSpread2_default()({}, props), {}, {
58004
- data: props.filteredData || data,
58040
+ data: data,
58005
58041
  line: line,
58006
58042
  rowsInView: rowsInView,
58007
58043
  expanded: expanded,
@@ -58079,7 +58115,7 @@ var Tree = function Tree(props) {
58079
58115
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(tree_context_Provider, {
58080
58116
  value: objectSpread2_default()(objectSpread2_default()({}, datum), {}, {
58081
58117
  size: props.size,
58082
- leafIcon: props.leafIcon
58118
+ leafIcon: leafIcon
58083
58119
  }),
58084
58120
  children: renderList()
58085
58121
  })
@@ -64516,9 +64552,10 @@ var getHideExpandCol = function getHideExpandCol() {
64516
64552
  }
64517
64553
  return null;
64518
64554
  };
64519
- // 缓冲区列数:左右各2列
64520
- var BUFFER_COUNT = 2;
64555
+ // 默认 overscan 值:可视区域两侧各额外渲染2列
64556
+ var DEFAULT_OVERSCAN = 2;
64521
64557
  var useColumns = function useColumns(props) {
64558
+ var _props$data;
64522
64559
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
64523
64560
  _useState2 = slicedToArray_default()(_useState, 2),
64524
64561
  startIndex = _useState2[0],
@@ -64529,6 +64566,14 @@ var useColumns = function useColumns(props) {
64529
64566
  setRenderedCount = _useState4[1];
64530
64567
  var _props$columns = props.columns,
64531
64568
  propsColumns = _props$columns === void 0 ? [] : _props$columns;
64569
+
64570
+ // 获取 overscan 配置,支持布尔值和对象两种格式
64571
+ var overscan = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
64572
+ var _props$virtualColumn$;
64573
+ if (!props.virtualColumn) return DEFAULT_OVERSCAN;
64574
+ if (typeof props.virtualColumn === 'boolean') return DEFAULT_OVERSCAN;
64575
+ return (_props$virtualColumn$ = props.virtualColumn.overscan) !== null && _props$virtualColumn$ !== void 0 ? _props$virtualColumn$ : DEFAULT_OVERSCAN;
64576
+ }, [props.virtualColumn]);
64532
64577
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
64533
64578
  cachedColumns: null,
64534
64579
  oldColumns: null,
@@ -64608,20 +64653,25 @@ var useColumns = function useColumns(props) {
64608
64653
  sum += curCol.width || 100;
64609
64654
  if (scrollLeft < sum) {
64610
64655
  // 计算可视区域内需要渲染的列数
64611
- for (var j = i + 1; j < len; j++) {
64656
+ for (var j = i + 1; j <= len; j++) {
64612
64657
  var _props$scrollRef$curr;
64613
64658
  var nextCol = middleColumns[j];
64614
64659
  sum += nextCol.width || 100;
64615
64660
  if (props.scrollRef.current && sum - scrollLeft >= ((_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.clientWidth)) {
64616
64661
  // 在原有基础上,右侧增加缓冲列
64617
64662
  var visibleCount = j - i;
64618
- setRenderedCount(Math.min(visibleCount + BUFFER_COUNT * 2, len));
64663
+ setRenderedCount(Math.min(visibleCount + overscan * 2, len));
64664
+ break;
64665
+ } else if (j === len) {
64666
+ // 到达最后一列
64667
+ var _visibleCount = j - i + 1;
64668
+ setRenderedCount(Math.min(_visibleCount + overscan * 2, len));
64619
64669
  break;
64620
64670
  }
64621
64671
  }
64622
64672
 
64623
64673
  // 左侧也增加缓冲列,但不能小于0
64624
- var bufferedStartIndex = Math.max(0, i - BUFFER_COUNT);
64674
+ var bufferedStartIndex = Math.max(0, i - overscan);
64625
64675
  currentIndex = bufferedStartIndex;
64626
64676
  break;
64627
64677
  }
@@ -64634,6 +64684,15 @@ var useColumns = function useColumns(props) {
64634
64684
  scrollLeft: 0
64635
64685
  });
64636
64686
  }, []);
64687
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
64688
+ if (!props.virtualColumn) return;
64689
+ if (props.scrollRef.current) {
64690
+ var _props$scrollRef$curr2;
64691
+ handleScroll({
64692
+ scrollLeft: (_props$scrollRef$curr2 = props.scrollRef.current) === null || _props$scrollRef$curr2 === void 0 ? void 0 : _props$scrollRef$curr2.scrollLeft
64693
+ });
64694
+ }
64695
+ }, [(_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.length, columns]);
64637
64696
  var processedColumns = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
64638
64697
  if (!props.virtualColumn) return columns;
64639
64698
  return columns.map(function (col, index) {
@@ -64642,14 +64701,21 @@ var useColumns = function useColumns(props) {
64642
64701
  }
64643
64702
  if (index < startIndex || index > startIndex + renderedCount) {
64644
64703
  var colSpan;
64704
+ var colSpanWidth;
64645
64705
  if (index > startIndex + renderedCount && index === startIndex + renderedCount + 1) {
64646
64706
  colSpan = function colSpan() {
64647
- return middleColumns.length - (startIndex + renderedCount) + 1;
64707
+ return middleColumns.length - index;
64648
64708
  };
64709
+ colSpanWidth = middleColumns.slice(index).reduce(function (sum, c) {
64710
+ return sum + (c.width || 0);
64711
+ }, 0);
64649
64712
  } else if (index < startIndex && index === leftFixedColumns.length && startIndex > 0) {
64650
64713
  colSpan = function colSpan() {
64651
64714
  return startIndex;
64652
64715
  };
64716
+ colSpanWidth = middleColumns.slice(0, startIndex).reduce(function (sum, c) {
64717
+ return sum + (c.width || 0);
64718
+ }, 0);
64653
64719
  }
64654
64720
  var hiddenTitle = context.groupLevel > 0 ? col.title : null;
64655
64721
  return objectSpread2_default()(objectSpread2_default()({}, col), {}, {
@@ -64657,7 +64723,10 @@ var useColumns = function useColumns(props) {
64657
64723
  render: function render() {
64658
64724
  return null;
64659
64725
  },
64660
- title: hiddenTitle
64726
+ title: hiddenTitle,
64727
+ style: {
64728
+ width: colSpanWidth
64729
+ }
64661
64730
  });
64662
64731
  }
64663
64732
  return col;
@@ -64829,6 +64898,7 @@ var useTableLayout = function useTableLayout(props) {
64829
64898
  });
64830
64899
  };
64831
64900
  var changeColGroup = function changeColGroup(cols, adjust) {
64901
+ if (props.scrolling) return;
64832
64902
  // 修改`Table`被display:none时,表格头样式错乱的问题
64833
64903
  if (cols && cols.every(function (v) {
64834
64904
  return v === 0;
@@ -67463,6 +67533,9 @@ function Table(props) {
67463
67533
  pagination = _props$pagination === void 0 ? {} : _props$pagination;
67464
67534
  var config = useConfig();
67465
67535
  var nestedContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(table_nested_context);
67536
+
67537
+ // 判断是否启用了虚拟列
67538
+ var isVirtualColumnEnabled = !!props.virtualColumn;
67466
67539
  var isRtl = config.direction === 'rtl';
67467
67540
  var tableClasses = props === null || props === void 0 || (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$table = _props$jssStyle.table) === null || _props$jssStyle$table === void 0 ? void 0 : _props$jssStyle$table.call(_props$jssStyle);
67468
67541
  var tbodyRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -67543,6 +67616,7 @@ function Table(props) {
67543
67616
  });
67544
67617
  var _useTableColumns = use_table_columns({
67545
67618
  columns: props.columns,
67619
+ data: props.data,
67546
67620
  virtualColumn: props.virtualColumn,
67547
67621
  scrollRef: scrollRef,
67548
67622
  showCheckbox: typeof props.onRowSelect === 'function'
@@ -67561,7 +67635,8 @@ function Table(props) {
67561
67635
  columnResizable: props.columnResizable,
67562
67636
  onColumnResize: props.onColumnResize,
67563
67637
  width: props.width,
67564
- isRtl: isRtl
67638
+ isRtl: isRtl,
67639
+ scrolling: isVirtualColumnEnabled && scrolling
67565
67640
  }),
67566
67641
  layoutFunc = _useTableLayout.func,
67567
67642
  colgroup = _useTableLayout.colgroup,
@@ -67720,7 +67795,7 @@ function Table(props) {
67720
67795
  var target = e.currentTarget;
67721
67796
  if (!target) return;
67722
67797
  layoutFunc.checkFloat();
67723
- if (props.virtualColumn) columnInfo.handleScroll({
67798
+ if (isVirtualColumnEnabled) columnInfo.handleScroll({
67724
67799
  scrollLeft: target.scrollLeft
67725
67800
  });
67726
67801
  if (headMirrorScrollRef.current) {
@@ -67742,7 +67817,7 @@ function Table(props) {
67742
67817
  // 虚拟表格的滚动事件
67743
67818
  var handleVirtualScroll = usePersistFn(function (info) {
67744
67819
  virtualInfo.handleScroll(info);
67745
- if (props.virtualColumn) columnInfo.handleScroll(info);
67820
+ if (isVirtualColumnEnabled) columnInfo.handleScroll(info);
67746
67821
  layoutFunc.checkFloat();
67747
67822
  if (headMirrorScrollRef.current) {
67748
67823
  headMirrorScrollRef.current.scrollLeft = info.scrollLeft;
@@ -67782,10 +67857,13 @@ function Table(props) {
67782
67857
  return null;
67783
67858
  };
67784
67859
  var $empty = renderEmpty();
67785
- var tableStyle = {
67786
- width: width,
67787
- borderSpacing: 0
67788
- };
67860
+ var tableStyle = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
67861
+ return {
67862
+ width: width,
67863
+ borderSpacing: 0,
67864
+ tableLayout: 'fixed'
67865
+ };
67866
+ }, [width]);
67789
67867
  var renderTable = function renderTable() {
67790
67868
  var _props$summary, _sticky$top, _props$data2;
67791
67869
  var Group = /*#__PURE__*/(0,jsx_runtime.jsx)(table_colgroup, {
@@ -68147,7 +68225,6 @@ function Table(props) {
68147
68225
  })), renderPagination()]
68148
68226
  });
68149
68227
  }
68150
- ;
68151
68228
  ;// CONCATENATED MODULE: ./src/table/table.tsx
68152
68229
 
68153
68230
 
@@ -70341,7 +70418,8 @@ var TreeSelect = function TreeSelect(props0) {
70341
70418
  onExpand = props.onExpand,
70342
70419
  beforeChange = props.beforeChange,
70343
70420
  filterSameChange = props.filterSameChange,
70344
- checkOnFiltered = props.checkOnFiltered;
70421
+ checkOnFiltered = props.checkOnFiltered,
70422
+ renderOptionList = props.renderOptionList;
70345
70423
  var styles = jssStyle === null || jssStyle === void 0 || (_jssStyle$treeSelect = jssStyle.treeSelect) === null || _jssStyle$treeSelect === void 0 ? void 0 : _jssStyle$treeSelect.call(jssStyle);
70346
70424
  var rootStyle = Object.assign({
70347
70425
  width: width
@@ -70795,6 +70873,7 @@ var TreeSelect = function TreeSelect(props0) {
70795
70873
  });
70796
70874
  };
70797
70875
  var renderEmpty = function renderEmpty() {
70876
+ if (props.emptyText === false) return null;
70798
70877
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
70799
70878
  className: styles === null || styles === void 0 ? void 0 : styles.option,
70800
70879
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
@@ -70809,7 +70888,6 @@ var TreeSelect = function TreeSelect(props0) {
70809
70888
  var renderList = function renderList() {
70810
70889
  if (props.loading) return renderLoading();
70811
70890
  var isEmpty = !(filterData !== null && filterData !== void 0 && filterData.length);
70812
- if (isEmpty) return renderEmpty();
70813
70891
  var treeProps = {};
70814
70892
  if (multiple) {
70815
70893
  treeProps.onChange = handleTreeChange;
@@ -70838,7 +70916,7 @@ var TreeSelect = function TreeSelect(props0) {
70838
70916
  };
70839
70917
  }
70840
70918
  }
70841
- return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
70919
+ var tree = /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
70842
70920
  className: classnames_default()(styles.tree, styles.treeWrapper),
70843
70921
  style: style,
70844
70922
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(src_tree_tree, objectSpread2_default()(objectSpread2_default()({
@@ -70871,6 +70949,11 @@ var TreeSelect = function TreeSelect(props0) {
70871
70949
  size: size
70872
70950
  }))
70873
70951
  });
70952
+ if (renderOptionList) {
70953
+ return renderOptionList(isEmpty ? renderEmpty() : tree);
70954
+ }
70955
+ if (isEmpty) return renderEmpty();
70956
+ return tree;
70874
70957
  };
70875
70958
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
70876
70959
  if (getComponentRef && datum) {
@@ -74669,7 +74752,7 @@ var upload_interface = __webpack_require__(8821);
74669
74752
 
74670
74753
 
74671
74754
  /* harmony default export */ var src_0 = ({
74672
- version: '3.9.3-beta.9'
74755
+ version: '3.9.4-beta.1'
74673
74756
  });
74674
74757
  }();
74675
74758
  /******/ return __webpack_exports__;