shineout 3.9.3-beta.8 → 3.9.3

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.8'
525
+ version: '3.9.3'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12401,17 +12401,21 @@ 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.8');
12404
+ /* harmony default export */ var version = ('3.9.3');
12405
12405
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12406
12406
 
12407
12407
 
12408
12408
 
12409
12409
 
12410
+
12410
12411
  var jss_style_prefix = 'soui';
12411
12412
  var jss_style_config = {};
12412
12413
  var setJssConfig = function setJssConfig(newConfig) {
12413
12414
  Object.assign(jss_style_config, newConfig);
12414
12415
  };
12416
+ var getJssConfig = function getJssConfig() {
12417
+ return jss_style_config;
12418
+ };
12415
12419
  var stringToHash = function stringToHash(str) {
12416
12420
  var hash = 0;
12417
12421
  if (str.length === 0) return '';
@@ -12445,12 +12449,27 @@ var createClassname = function createClassname(rule, sheet) {
12445
12449
  // };
12446
12450
 
12447
12451
  var styled = function styled(style, ns) {
12452
+ var styleElement = typeof window !== 'undefined' ? document.createElement('style') : undefined;
12448
12453
  var hoc = createUseStyles(jss_style_handleStyle(style), {
12449
12454
  name: ns,
12450
- generateId: createClassname
12455
+ generateId: createClassname,
12456
+ element: styleElement
12451
12457
  });
12452
12458
  var styledCacheMap = {};
12459
+ var attributesApplied = false;
12453
12460
  var getClassName = function getClassName() {
12461
+ if (!attributesApplied && styleElement) {
12462
+ var jssConfig = getJssConfig();
12463
+ if (jssConfig.styleAttributes) {
12464
+ Object.entries(jssConfig.styleAttributes).forEach(function (_ref) {
12465
+ var _ref2 = slicedToArray_default()(_ref, 2),
12466
+ key = _ref2[0],
12467
+ value = _ref2[1];
12468
+ styleElement.setAttribute(key, value);
12469
+ });
12470
+ }
12471
+ attributesApplied = true;
12472
+ }
12454
12473
  var classes = hoc();
12455
12474
  if (styledCacheMap[ns]) {
12456
12475
  return styledCacheMap[ns];
@@ -40998,13 +41017,32 @@ var useTree = function useTree(props) {
40998
41017
  }
40999
41018
  });
41000
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
+ };
41001
41037
  var insertFlat = function insertFlat(id) {
41002
41038
  var item = getDataById(id);
41003
41039
  if (isUnMatchedData(item)) return;
41004
41040
  if (!item) return;
41005
41041
  var status = context.dataFlatStatusMap.get(id);
41006
41042
  if (!status) return;
41007
- var childrenData = item[childrenKey];
41043
+
41044
+ // 优先从 tiledData 中获取子节点数据,如果不存在则使用原始数据
41045
+ var childrenData = props.tiledData ? getChildrenFromTiledData(id) || [] : item[childrenKey];
41008
41046
  var insertStartNode = dataFlat.find(function (item) {
41009
41047
  return item.id === id;
41010
41048
  });
@@ -41122,6 +41160,7 @@ var useTree = function useTree(props) {
41122
41160
  if (!props.tiledData) return;
41123
41161
  var tiledFlatData = initFlatData(props.tiledData, [], 1);
41124
41162
  setDataFlat(tiledFlatData);
41163
+ // context.dataFlatStatusMap = new Map();
41125
41164
  }, [props.tiledData]);
41126
41165
  var datum = use_latest_obj({
41127
41166
  get: get,
@@ -44153,7 +44192,12 @@ var useFieldSetConsumer = function useFieldSetConsumer(props) {
44153
44192
  path = _React$useContext.path,
44154
44193
  validateFieldSet = _React$useContext.validateFieldSet;
44155
44194
  var bind = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useMemo(function () {
44156
- 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
+ });
44157
44201
  }, [path, props.bind]);
44158
44202
  var name = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useMemo(function () {
44159
44203
  return extendName(path, props.name);
@@ -47409,15 +47453,24 @@ var useDate = function useDate(props) {
47409
47453
  var getTimeStr = function getTimeStr() {
47410
47454
  var format = props.format,
47411
47455
  type = props.type;
47412
- if (!props.value) return '';
47413
47456
  if (type !== 'datetime' || !format) return '';
47414
- if (/^[X|x]$/.test(format)) {
47457
+ if (/^[X|x]$/.test(util.compatibleFmt(format))) {
47415
47458
  format = 'HH:mm:ss';
47416
47459
  } else {
47417
47460
  var match = format.match(/[H|h].*/);
47418
47461
  // eslint-disable-next-line
47419
47462
  if (match) format = match[0];
47420
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
+ }
47421
47474
  return util.format(props.value, format, options);
47422
47475
  };
47423
47476
  var isInRange = function isInRange(date) {
@@ -57770,7 +57823,7 @@ var TreeVirtual = function TreeVirtual(props) {
57770
57823
 
57771
57824
 
57772
57825
 
57773
- 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"];
57774
57827
 
57775
57828
 
57776
57829
 
@@ -57837,6 +57890,7 @@ var Tree = function Tree(props) {
57837
57890
  actionOnClick = props.actionOnClick,
57838
57891
  tiledData = props.tiledData,
57839
57892
  height = props.height,
57893
+ leafIcon = props.leafIcon,
57840
57894
  rest = objectWithoutProperties_default()(props, tree_excluded);
57841
57895
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(propActive),
57842
57896
  _useState2 = slicedToArray_default()(_useState, 2),
@@ -57871,7 +57925,8 @@ var Tree = function Tree(props) {
57871
57925
  keygen: keygen,
57872
57926
  virtual: virtual,
57873
57927
  onExpand: onExpandProp,
57874
- datum: propsDatum
57928
+ datum: propsDatum,
57929
+ tiledData: props.filteredData
57875
57930
  }),
57876
57931
  datum = _useTree.datum,
57877
57932
  expanded = _useTree.expanded,
@@ -57982,7 +58037,7 @@ var Tree = function Tree(props) {
57982
58037
  var realHeight = getHeight();
57983
58038
  if (!realHeight) return null;
57984
58039
  return /*#__PURE__*/(0,jsx_runtime.jsx)(tree_virtual, objectSpread2_default()(objectSpread2_default()({}, props), {}, {
57985
- data: props.filteredData || data,
58040
+ data: data,
57986
58041
  line: line,
57987
58042
  rowsInView: rowsInView,
57988
58043
  expanded: expanded,
@@ -58060,7 +58115,7 @@ var Tree = function Tree(props) {
58060
58115
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(tree_context_Provider, {
58061
58116
  value: objectSpread2_default()(objectSpread2_default()({}, datum), {}, {
58062
58117
  size: props.size,
58063
- leafIcon: props.leafIcon
58118
+ leafIcon: leafIcon
58064
58119
  }),
58065
58120
  children: renderList()
58066
58121
  })
@@ -64497,9 +64552,10 @@ var getHideExpandCol = function getHideExpandCol() {
64497
64552
  }
64498
64553
  return null;
64499
64554
  };
64500
- // 缓冲区列数:左右各2列
64501
- var BUFFER_COUNT = 2;
64555
+ // 默认 overscan 值:可视区域两侧各额外渲染2列
64556
+ var DEFAULT_OVERSCAN = 2;
64502
64557
  var useColumns = function useColumns(props) {
64558
+ var _props$data;
64503
64559
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
64504
64560
  _useState2 = slicedToArray_default()(_useState, 2),
64505
64561
  startIndex = _useState2[0],
@@ -64510,6 +64566,14 @@ var useColumns = function useColumns(props) {
64510
64566
  setRenderedCount = _useState4[1];
64511
64567
  var _props$columns = props.columns,
64512
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]);
64513
64577
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
64514
64578
  cachedColumns: null,
64515
64579
  oldColumns: null,
@@ -64589,20 +64653,25 @@ var useColumns = function useColumns(props) {
64589
64653
  sum += curCol.width || 100;
64590
64654
  if (scrollLeft < sum) {
64591
64655
  // 计算可视区域内需要渲染的列数
64592
- for (var j = i + 1; j < len; j++) {
64656
+ for (var j = i + 1; j <= len; j++) {
64593
64657
  var _props$scrollRef$curr;
64594
64658
  var nextCol = middleColumns[j];
64595
64659
  sum += nextCol.width || 100;
64596
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)) {
64597
64661
  // 在原有基础上,右侧增加缓冲列
64598
64662
  var visibleCount = j - i;
64599
- 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));
64600
64669
  break;
64601
64670
  }
64602
64671
  }
64603
64672
 
64604
64673
  // 左侧也增加缓冲列,但不能小于0
64605
- var bufferedStartIndex = Math.max(0, i - BUFFER_COUNT);
64674
+ var bufferedStartIndex = Math.max(0, i - overscan);
64606
64675
  currentIndex = bufferedStartIndex;
64607
64676
  break;
64608
64677
  }
@@ -64615,6 +64684,15 @@ var useColumns = function useColumns(props) {
64615
64684
  scrollLeft: 0
64616
64685
  });
64617
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]);
64618
64696
  var processedColumns = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
64619
64697
  if (!props.virtualColumn) return columns;
64620
64698
  return columns.map(function (col, index) {
@@ -64623,14 +64701,21 @@ var useColumns = function useColumns(props) {
64623
64701
  }
64624
64702
  if (index < startIndex || index > startIndex + renderedCount) {
64625
64703
  var colSpan;
64704
+ var colSpanWidth;
64626
64705
  if (index > startIndex + renderedCount && index === startIndex + renderedCount + 1) {
64627
64706
  colSpan = function colSpan() {
64628
- return middleColumns.length - (startIndex + renderedCount) + 1;
64707
+ return middleColumns.length - index;
64629
64708
  };
64709
+ colSpanWidth = middleColumns.slice(index).reduce(function (sum, c) {
64710
+ return sum + (c.width || 0);
64711
+ }, 0);
64630
64712
  } else if (index < startIndex && index === leftFixedColumns.length && startIndex > 0) {
64631
64713
  colSpan = function colSpan() {
64632
64714
  return startIndex;
64633
64715
  };
64716
+ colSpanWidth = middleColumns.slice(0, startIndex).reduce(function (sum, c) {
64717
+ return sum + (c.width || 0);
64718
+ }, 0);
64634
64719
  }
64635
64720
  var hiddenTitle = context.groupLevel > 0 ? col.title : null;
64636
64721
  return objectSpread2_default()(objectSpread2_default()({}, col), {}, {
@@ -64638,7 +64723,10 @@ var useColumns = function useColumns(props) {
64638
64723
  render: function render() {
64639
64724
  return null;
64640
64725
  },
64641
- title: hiddenTitle
64726
+ title: hiddenTitle,
64727
+ style: {
64728
+ width: colSpanWidth
64729
+ }
64642
64730
  });
64643
64731
  }
64644
64732
  return col;
@@ -64810,6 +64898,7 @@ var useTableLayout = function useTableLayout(props) {
64810
64898
  });
64811
64899
  };
64812
64900
  var changeColGroup = function changeColGroup(cols, adjust) {
64901
+ if (props.scrolling) return;
64813
64902
  // 修改`Table`被display:none时,表格头样式错乱的问题
64814
64903
  if (cols && cols.every(function (v) {
64815
64904
  return v === 0;
@@ -67444,6 +67533,9 @@ function Table(props) {
67444
67533
  pagination = _props$pagination === void 0 ? {} : _props$pagination;
67445
67534
  var config = useConfig();
67446
67535
  var nestedContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(table_nested_context);
67536
+
67537
+ // 判断是否启用了虚拟列
67538
+ var isVirtualColumnEnabled = !!props.virtualColumn;
67447
67539
  var isRtl = config.direction === 'rtl';
67448
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);
67449
67541
  var tbodyRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -67524,6 +67616,7 @@ function Table(props) {
67524
67616
  });
67525
67617
  var _useTableColumns = use_table_columns({
67526
67618
  columns: props.columns,
67619
+ data: props.data,
67527
67620
  virtualColumn: props.virtualColumn,
67528
67621
  scrollRef: scrollRef,
67529
67622
  showCheckbox: typeof props.onRowSelect === 'function'
@@ -67542,7 +67635,8 @@ function Table(props) {
67542
67635
  columnResizable: props.columnResizable,
67543
67636
  onColumnResize: props.onColumnResize,
67544
67637
  width: props.width,
67545
- isRtl: isRtl
67638
+ isRtl: isRtl,
67639
+ scrolling: isVirtualColumnEnabled && scrolling
67546
67640
  }),
67547
67641
  layoutFunc = _useTableLayout.func,
67548
67642
  colgroup = _useTableLayout.colgroup,
@@ -67701,7 +67795,7 @@ function Table(props) {
67701
67795
  var target = e.currentTarget;
67702
67796
  if (!target) return;
67703
67797
  layoutFunc.checkFloat();
67704
- if (props.virtualColumn) columnInfo.handleScroll({
67798
+ if (isVirtualColumnEnabled) columnInfo.handleScroll({
67705
67799
  scrollLeft: target.scrollLeft
67706
67800
  });
67707
67801
  if (headMirrorScrollRef.current) {
@@ -67723,7 +67817,7 @@ function Table(props) {
67723
67817
  // 虚拟表格的滚动事件
67724
67818
  var handleVirtualScroll = usePersistFn(function (info) {
67725
67819
  virtualInfo.handleScroll(info);
67726
- if (props.virtualColumn) columnInfo.handleScroll(info);
67820
+ if (isVirtualColumnEnabled) columnInfo.handleScroll(info);
67727
67821
  layoutFunc.checkFloat();
67728
67822
  if (headMirrorScrollRef.current) {
67729
67823
  headMirrorScrollRef.current.scrollLeft = info.scrollLeft;
@@ -67763,10 +67857,13 @@ function Table(props) {
67763
67857
  return null;
67764
67858
  };
67765
67859
  var $empty = renderEmpty();
67766
- var tableStyle = {
67767
- width: width,
67768
- borderSpacing: 0
67769
- };
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]);
67770
67867
  var renderTable = function renderTable() {
67771
67868
  var _props$summary, _sticky$top, _props$data2;
67772
67869
  var Group = /*#__PURE__*/(0,jsx_runtime.jsx)(table_colgroup, {
@@ -68128,7 +68225,6 @@ function Table(props) {
68128
68225
  })), renderPagination()]
68129
68226
  });
68130
68227
  }
68131
- ;
68132
68228
  ;// CONCATENATED MODULE: ./src/table/table.tsx
68133
68229
 
68134
68230
 
@@ -74650,7 +74746,7 @@ var upload_interface = __webpack_require__(8821);
74650
74746
 
74651
74747
 
74652
74748
  /* harmony default export */ var src_0 = ({
74653
- version: '3.9.3-beta.8'
74749
+ version: '3.9.3'
74654
74750
  });
74655
74751
  }();
74656
74752
  /******/ return __webpack_exports__;