@zhenliang/sheet 0.1.7 → 0.1.8-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.
Files changed (102) hide show
  1. package/dist/assets/arrow-mac-down.svg +19 -0
  2. package/dist/assets/arrow-mac-right.svg +17 -0
  3. package/dist/assets/arrow-windows-down.svg +17 -0
  4. package/dist/assets/arrow-windows-right.svg +17 -0
  5. package/dist/core/config.d.ts +3 -0
  6. package/dist/core/config.js +4 -1
  7. package/dist/core/editor/cascaderEditor/index.d.ts +1 -1
  8. package/dist/core/editor/cascaderEditor/index.js +10 -9
  9. package/dist/core/editor/cascaderEditor/index.less +14 -10
  10. package/dist/core/editor/dateEditor/index.js +29 -6
  11. package/dist/core/editor/dateEditor/index.less +9 -2
  12. package/dist/core/editor/numberEditor/index.d.ts +3 -1
  13. package/dist/core/editor/numberEditor/index.js +60 -25
  14. package/dist/core/editor/numberEditor/index.less +3 -2
  15. package/dist/core/editor/selectEditor/index.d.ts +1 -1
  16. package/dist/core/editor/selectEditor/index.js +17 -15
  17. package/dist/core/editor/selectEditor/index.less +15 -6
  18. package/dist/core/reducers/index.d.ts +2 -2
  19. package/dist/core/reducers/index.js +8 -1
  20. package/dist/core/reducers/keyboardReducer.js +40 -9
  21. package/dist/core/reducers/mouseReducer.js +123 -14
  22. package/dist/core/reducers/sideEffectReducer.d.ts +1 -1
  23. package/dist/core/reducers/sideEffectReducer.js +155 -49
  24. package/dist/core/reducers/stateReducer.d.ts +1 -0
  25. package/dist/core/reducers/stateReducer.js +126 -31
  26. package/dist/core/sheet/Cell.js +30 -21
  27. package/dist/core/sheet/Control.d.ts +21 -0
  28. package/dist/core/sheet/Control.js +83 -0
  29. package/dist/core/sheet/DataEditor.js +1 -1
  30. package/dist/core/sheet/DefaultCell.d.ts +8 -3
  31. package/dist/core/sheet/DefaultCell.js +11 -7
  32. package/dist/core/sheet/DefaultRow.js +1 -7
  33. package/dist/core/sheet/DefaultRowMapper.d.ts +3 -0
  34. package/dist/core/sheet/DefaultRowMapper.js +19 -3
  35. package/dist/core/sheet/Menu.d.ts +6 -0
  36. package/dist/core/sheet/Menu.js +21 -0
  37. package/dist/core/sheet/Remark.d.ts +9 -0
  38. package/dist/core/sheet/Remark.js +32 -0
  39. package/dist/core/sheet/index.js +328 -87
  40. package/dist/core/sheet/index.less +243 -107
  41. package/dist/core/sheet/searchInput.d.ts +16 -0
  42. package/dist/core/sheet/searchInput.js +105 -0
  43. package/dist/core/sheet/useContextMenu.d.ts +1 -1
  44. package/dist/core/sheet/useContextMenu.js +15 -12
  45. package/dist/core/sheet/useKeyBoardEvent.js +31 -7
  46. package/dist/core/sheet/useMouseEvent.js +37 -18
  47. package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
  48. package/dist/core/sheet/useRemarkContainer.js +144 -0
  49. package/dist/core/sheet/useSearchInput.d.ts +11 -0
  50. package/dist/core/sheet/useSearchInput.js +75 -0
  51. package/dist/core/sheet/useSelectVisible.d.ts +1 -1
  52. package/dist/core/sheet/useSelectVisible.js +16 -6
  53. package/dist/core/sheet/useVirtualList.d.ts +10 -1
  54. package/dist/core/sheet/useVirtualList.js +44 -28
  55. package/dist/core/sheet/var.less +41 -34
  56. package/dist/core/shell/draggableShell/index.d.ts +3 -1
  57. package/dist/core/shell/draggableShell/index.js +136 -46
  58. package/dist/core/shell/tableShell.d.ts +4 -2
  59. package/dist/core/shell/tableShell.js +11 -107
  60. package/dist/core/table/addButton.d.ts +5 -0
  61. package/dist/core/table/addButton.js +102 -0
  62. package/dist/core/table/events.d.ts +0 -2
  63. package/dist/core/table/events.js +30 -32
  64. package/dist/core/table/index.d.ts +1 -0
  65. package/dist/core/table/index.js +266 -192
  66. package/dist/core/table/index.less +31 -0
  67. package/dist/core/table/remarkEvent.d.ts +5 -0
  68. package/dist/core/table/remarkEvent.js +9 -0
  69. package/dist/core/table/useGroupConfig.d.ts +4 -1
  70. package/dist/core/table/useGroupConfig.js +141 -10
  71. package/dist/core/table/useRowSelection.d.ts +3 -0
  72. package/dist/core/table/useRowSelection.js +71 -1
  73. package/dist/core/util.d.ts +16 -3
  74. package/dist/core/util.js +156 -64
  75. package/dist/core/viewer/cascaderViewer/index.js +6 -1
  76. package/dist/core/viewer/groupViewer/index.js +24 -8
  77. package/dist/core/viewer/switchViewer/index.js +8 -2
  78. package/dist/example/antComponent.js +72 -44
  79. package/dist/example/basic.js +15 -10
  80. package/dist/example/group.js +38 -15
  81. package/dist/example/selection.js +6 -6
  82. package/dist/example/sheet.js +18 -19
  83. package/dist/example/valuationAnalyze.d.ts +1 -0
  84. package/dist/example/valuationAnalyze.js +356 -14
  85. package/dist/hooks/index.d.ts +1 -1
  86. package/dist/hooks/index.js +1 -1
  87. package/dist/hooks/useEventBus.js +1 -1
  88. package/dist/hooks/useGroupConfig.d.ts +4 -0
  89. package/dist/hooks/useGroupConfig.js +5 -0
  90. package/dist/hooks/useKeyboard.d.ts +5 -2
  91. package/dist/hooks/useKeyboard.js +33 -9
  92. package/dist/hooks/useMiddlewareReducer.d.ts +5 -5
  93. package/dist/hooks/useMiddlewareReducer.js +2 -2
  94. package/dist/hooks/useMouse.d.ts +1 -1
  95. package/dist/hooks/useMouse.js +6 -6
  96. package/dist/hooks/useSetState.js +6 -6
  97. package/dist/hooks/useWidthConfig.d.ts +3 -3
  98. package/dist/standardUtils/index.d.ts +1 -1
  99. package/dist/standardUtils/index.js +1 -1
  100. package/dist/type/sheet.d.ts +89 -33
  101. package/dist/type/sheetTable.d.ts +38 -14
  102. package/package.json +11 -5
@@ -1,11 +1,23 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
12
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { flatten } from 'lodash';
17
+ import { flatten, isNil } from 'lodash';
8
18
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
+ import { classNames, groupConfigToGroupMap } from "../util";
20
+ import { GroupViewer } from "../viewer";
9
21
  import { dataSourceToRowConfig } from "./util";
10
22
  export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig, hasChildren) {
11
23
  var _useState = useState(),
@@ -26,23 +38,142 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
26
38
  }, [dataSource]);
27
39
  useEffect(function () {
28
40
  if (!hasChildren) return;
29
- var rowConfig = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
41
+ var computedRowGroup = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
42
+ var rowConfig = computedRowGroup;
43
+ var _ref = tableGroupConfig || {},
44
+ rowGroup = _ref.rowGroup;
45
+ if (rowGroup) {
46
+ var notEqual = rowGroup.groups.length !== computedRowGroup.groups.length;
47
+ var notSameGroup = notEqual || rowGroup.groups.some(function (group, index) {
48
+ return computedRowGroup.groups[index].groupStart !== group.groupStart || computedRowGroup.groups[index].groupEnd !== group.groupEnd;
49
+ });
50
+ if (!notSameGroup) {
51
+ rowConfig = rowGroup;
52
+ } else {
53
+ var _tableGroupConfig$onC;
54
+ tableGroupConfig === null || tableGroupConfig === void 0 || (_tableGroupConfig$onC = tableGroupConfig.onChange) === null || _tableGroupConfig$onC === void 0 || _tableGroupConfig$onC.call(tableGroupConfig, computedRowGroup);
55
+ }
56
+ }
30
57
  if (groupConfigRef.current) {
31
- groupConfigRef.current.groups.forEach(function (_ref, index) {
32
- var _groupConfigRef$curre;
33
- var groupName = _ref.groupName;
34
- var rowIndex = rowConfig.groups.findIndex(function (item) {
58
+ rowConfig.groups.forEach(function (_ref2, index) {
59
+ var _groupConfigRef$curre, _groupConfigRef$curre2;
60
+ var groupName = _ref2.groupName,
61
+ newGroupStart = _ref2.groupStart,
62
+ newGroupEnd = _ref2.groupEnd;
63
+ var rowIndex = (_groupConfigRef$curre = (_groupConfigRef$curre2 = groupConfigRef.current) === null || _groupConfigRef$curre2 === void 0 ? void 0 : _groupConfigRef$curre2.groups.findIndex(function (item) {
35
64
  return item.groupName === groupName;
36
- });
37
- rowConfig.groupOpen[rowIndex] = ((_groupConfigRef$curre = groupConfigRef.current) === null || _groupConfigRef$curre === void 0 ? void 0 : _groupConfigRef$curre.groupOpen[index]) || rowConfig.groupOpen[rowIndex];
65
+ })) !== null && _groupConfigRef$curre !== void 0 ? _groupConfigRef$curre : -1;
66
+ if (rowIndex >= 0) {
67
+ var _groupConfigRef$curre3, _groupConfigRef$curre4;
68
+ var hasNewLine = false;
69
+ var currentOld = (_groupConfigRef$curre3 = groupConfigRef.current) === null || _groupConfigRef$curre3 === void 0 ? void 0 : _groupConfigRef$curre3.groups[rowIndex];
70
+ if (currentOld && !isNil(currentOld.groupEnd) && !isNil(currentOld.groupStart)) {
71
+ var oldLength = currentOld.groupEnd - currentOld.groupStart;
72
+ var newLength = newGroupEnd - newGroupStart;
73
+ hasNewLine = newLength > oldLength;
74
+ } else {
75
+ hasNewLine = true;
76
+ }
77
+ rowConfig.groupOpen[index] = hasNewLine ? true : (_groupConfigRef$curre4 = groupConfigRef.current) === null || _groupConfigRef$curre4 === void 0 ? void 0 : _groupConfigRef$curre4.groupOpen[rowIndex];
78
+ } else {
79
+ // 新子行
80
+ rowConfig.groupOpen[index] = true;
81
+ }
38
82
  });
39
83
  }
40
84
  setGroupConfig(rowConfig);
41
85
  groupConfigRef.current = rowConfig;
42
86
  }, [dataSource.length, childrenLength, hasChildren]);
43
87
  var handleGroupChange = useCallback(function (value) {
88
+ var _tableGroupConfig$onC2;
44
89
  setGroupConfig(value);
90
+ tableGroupConfig === null || tableGroupConfig === void 0 || (_tableGroupConfig$onC2 = tableGroupConfig.onChange) === null || _tableGroupConfig$onC2 === void 0 || _tableGroupConfig$onC2.call(tableGroupConfig, value);
45
91
  groupConfigRef.current = value;
46
92
  }, [setGroupConfig]);
47
- return [groupConfig, handleGroupChange];
93
+ var memoConfig = useMemo(function () {
94
+ var configMap = groupConfigToGroupMap({
95
+ groups: groupConfig === null || groupConfig === void 0 ? void 0 : groupConfig.groups,
96
+ groupOpen: groupConfig === null || groupConfig === void 0 ? void 0 : groupConfig.groupOpen
97
+ });
98
+ return _objectSpread(_objectSpread({}, groupConfig), {}, {
99
+ configMap: configMap
100
+ });
101
+ }, [groupConfig]);
102
+ return [memoConfig, handleGroupChange];
103
+ };
104
+ export var formatGroupData = function formatGroupData(param) {
105
+ var dataSource = param.dataSource,
106
+ columns = param.columns,
107
+ rowKey = param.rowKey,
108
+ showRemark = param.showRemark;
109
+ var data = [];
110
+ var currentIndex = 0;
111
+ dataSource.forEach(function (item, row) {
112
+ var groupList = [item];
113
+ if (item.children) {
114
+ groupList = [item].concat(_toConsumableArray(item.children));
115
+ }
116
+ groupList.forEach(function (itemRow) {
117
+ var _columns$, _columns$2, _columns$3, _columns$4;
118
+ var dataRow = [];
119
+ var rowId = itemRow.id || itemRow.key || String(currentIndex);
120
+ if (rowKey) {
121
+ if (rowKey instanceof Function) {
122
+ rowId = rowKey(itemRow, row);
123
+ } else {
124
+ rowId = itemRow[rowKey];
125
+ }
126
+ }
127
+ dataRow.push({
128
+ id: rowId,
129
+ row: currentIndex,
130
+ col: -2,
131
+ editable: false,
132
+ readonly: true,
133
+ fixed: 'left',
134
+ valueViewer: function valueViewer() {
135
+ return null;
136
+ },
137
+ className: 'sheet-control sheet-row-cursor'
138
+ });
139
+ dataRow.push({
140
+ id: rowId,
141
+ row: currentIndex,
142
+ col: -1,
143
+ editable: !((columns === null || columns === void 0 ? void 0 : columns[0].editable) instanceof Function) ? columns === null || columns === void 0 || (_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.editable : columns === null || columns === void 0 || (_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.editable('', itemRow, currentIndex),
144
+ readonly: !((columns === null || columns === void 0 ? void 0 : columns[0].readonly) instanceof Function) ? columns === null || columns === void 0 || (_columns$3 = columns[0]) === null || _columns$3 === void 0 ? void 0 : _columns$3.readonly : columns === null || columns === void 0 || (_columns$4 = columns[0]) === null || _columns$4 === void 0 ? void 0 : _columns$4.readonly('', itemRow, currentIndex),
145
+ align: 'center',
146
+ // fixed: 'unset',
147
+ valueViewer: GroupViewer,
148
+ className: 'sheet-control'
149
+ });
150
+ columns.forEach(function (colInfo, col) {
151
+ var _itemRow$remarks, _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
152
+ var value = itemRow[colInfo.dataIndex || ''];
153
+ var hasRemark = showRemark && (itemRow === null || itemRow === void 0 || (_itemRow$remarks = itemRow.remarks) === null || _itemRow$remarks === void 0 ? void 0 : _itemRow$remarks.includes(colInfo.dataIndex));
154
+ dataRow.push({
155
+ id: rowId,
156
+ value: value,
157
+ record: itemRow,
158
+ readonly: !(colInfo.readonly instanceof Function) ? (_colInfo$readonly = colInfo.readonly) !== null && _colInfo$readonly !== void 0 ? _colInfo$readonly : false : colInfo.readonly(value, itemRow, currentIndex, col),
159
+ align: colInfo.align,
160
+ fixed: colInfo.fixed,
161
+ editable: !(colInfo.editable instanceof Function) ? (_colInfo$editable = colInfo.editable) !== null && _colInfo$editable !== void 0 ? _colInfo$editable : true : colInfo.editable(value, itemRow, currentIndex, col),
162
+ valueViewer: colInfo.render ? colInfo.render : undefined,
163
+ dataEditor: colInfo.editor ? colInfo.editor : undefined,
164
+ searchKey: colInfo.searchKey,
165
+ row: currentIndex,
166
+ className: classNames(!(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, itemRow, currentIndex), hasRemark ? 'remark-cell' : null),
167
+ dataIndex: colInfo.dataIndex,
168
+ key: colInfo.key,
169
+ allowClear: colInfo.allowClear,
170
+ fixedAllowSelect: colInfo.fixedAllowSelect,
171
+ col: col
172
+ });
173
+ });
174
+ data.push(dataRow);
175
+ currentIndex++;
176
+ });
177
+ });
178
+ return data;
48
179
  };
@@ -1,2 +1,5 @@
1
1
  import { SheetTableType } from "../..";
2
2
  export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: SheetTableType.TableRowSelection, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
3
+ export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "dataSource" | "rowKey" | "showRemark" | "rowSelection"> & {
4
+ checked: boolean[];
5
+ }) => any[][];
@@ -2,9 +2,11 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
2
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { CheckViewer } from "../..";
7
8
  import { useEffect, useRef, useState } from 'react';
9
+ import { classNames } from "../util";
8
10
  export var useRowSelection = function useRowSelection(dataSource, rowSelection, hasChildren) {
9
11
  var _dataSource$length;
10
12
  var _useState = useState(Array((_dataSource$length = dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) !== null && _dataSource$length !== void 0 ? _dataSource$length : 0).fill(false)),
@@ -21,4 +23,72 @@ export var useRowSelection = function useRowSelection(dataSource, rowSelection,
21
23
  checkedRowRef.current = currentEmpty;
22
24
  }, [dataSource.length, hasChildren, rowSelection]);
23
25
  return [checkedRow, setCheckedRow];
26
+ };
27
+ export var formatSelectionData = function formatSelectionData(param) {
28
+ var dataSource = param.dataSource,
29
+ columns = param.columns,
30
+ checked = param.checked,
31
+ rowKey = param.rowKey,
32
+ rowSelection = param.rowSelection,
33
+ showRemark = param.showRemark;
34
+ return dataSource.map(function (item, row) {
35
+ var rowId = item.id || item.key || String(row);
36
+ if (rowKey) {
37
+ if (rowKey instanceof Function) {
38
+ rowId = rowKey(item, row);
39
+ } else {
40
+ rowId = item[rowKey];
41
+ }
42
+ }
43
+ var rows = [];
44
+ rows.push({
45
+ id: rowId,
46
+ row: row,
47
+ col: -2,
48
+ editable: false,
49
+ readonly: true,
50
+ fixed: 'left',
51
+ valueViewer: function valueViewer() {
52
+ return null;
53
+ },
54
+ className: 'sheet-control sheet-row-cursor'
55
+ });
56
+ if (rowSelection) {
57
+ rows.push({
58
+ id: rowId,
59
+ row: row,
60
+ col: -1,
61
+ readonly: true,
62
+ align: 'center',
63
+ value: checked[row],
64
+ valueViewer: CheckViewer,
65
+ className: 'sheet-control'
66
+ });
67
+ }
68
+ columns.forEach(function (colInfo, col) {
69
+ var _item$remarks, _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
70
+ var value = item[colInfo.dataIndex || ''];
71
+ var hasRemark = showRemark && (item === null || item === void 0 || (_item$remarks = item.remarks) === null || _item$remarks === void 0 ? void 0 : _item$remarks.includes(colInfo.dataIndex));
72
+ rows.push({
73
+ id: rowId,
74
+ value: value,
75
+ record: item,
76
+ readonly: !(colInfo.readonly instanceof Function) ? (_colInfo$readonly = colInfo.readonly) !== null && _colInfo$readonly !== void 0 ? _colInfo$readonly : false : colInfo.readonly(value, item, row, col),
77
+ align: colInfo.align,
78
+ fixed: colInfo.fixed,
79
+ editable: !(colInfo.editable instanceof Function) ? (_colInfo$editable = colInfo.editable) !== null && _colInfo$editable !== void 0 ? _colInfo$editable : true : colInfo.editable(value, item, row),
80
+ valueViewer: colInfo.render ? colInfo.render : undefined,
81
+ dataEditor: colInfo.editor ? colInfo.editor : undefined,
82
+ searchKey: colInfo.searchKey,
83
+ className: classNames(!(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, item, row), hasRemark ? 'remark-cell' : null),
84
+ row: row,
85
+ col: col,
86
+ dataIndex: colInfo.dataIndex,
87
+ allowClear: colInfo.allowClear,
88
+ fixedAllowSelect: colInfo.fixedAllowSelect,
89
+ key: colInfo.key
90
+ });
91
+ });
92
+ return rows;
93
+ });
24
94
  };
@@ -1,4 +1,5 @@
1
1
  import type { SheetType } from "../type";
2
+ import { Cell } from '../type/sheet';
2
3
  export declare function findParentTd(el: HTMLElement): HTMLElement | null;
3
4
  export declare function extractDataRowAndCol(el: HTMLElement): {
4
5
  row: number;
@@ -31,9 +32,8 @@ export declare const defaultValueRenderer: (cell: SheetType.Cell) => string | nu
31
32
  export declare function renderValue(cell: SheetType.Cell): string | number;
32
33
  export declare const optionsToValuesFromLabelOrValue: (options: SheetType.OptionsType[], val: string) => string[];
33
34
  export declare const optionsTransferToValue: (options: SheetType.OptionsType[], val: string, key?: string) => string[];
34
- export declare const optionsTransferToValue2: (options?: SheetType.OptionsType[], value?: string, path?: string[]) => string[];
35
35
  export declare const valuesTransferToLabel: (options?: SheetType.OptionsType[], value?: string) => string | null;
36
- export declare const groupConfigToGroupMap: (rowGroupConfig?: SheetType.RowGroupConfig) => Map<number, SheetType.RowGroup & {
36
+ export declare const groupConfigToGroupMap: (rowGroupConfig?: Partial<SheetType.RowGroupConfig>) => Map<number, SheetType.RowGroup & {
37
37
  isStart: boolean;
38
38
  isOpen: boolean;
39
39
  }>;
@@ -41,7 +41,8 @@ export declare const changeGroupConfig: (rowGroupConfig: SheetType.RowGroupConfi
41
41
  add?: number | undefined;
42
42
  remove?: number | undefined;
43
43
  }) => SheetType.RowGroupConfig;
44
- export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig) => number;
44
+ export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig, max?: number) => number;
45
+ export declare const rowToCountRow: (row: number, groupConfig: SheetType.RowGroupConfig, max: number) => number;
45
46
  export declare const getRowHeight: (container: HTMLSpanElement) => number;
46
47
  export declare const getNextVisibleRow: (row: number, maxRow: number, groupMap?: Map<number, SheetType.RowGroup & {
47
48
  isStart: boolean;
@@ -56,3 +57,15 @@ export declare const calcMenuPosition: ({ tableElement, menuElement, x, y, }: {
56
57
  top: number;
57
58
  left: number;
58
59
  };
60
+ export declare const isFreezedCell: (row: number, col: number, data?: SheetType.Cell[][]) => boolean;
61
+ export declare const stripRowIndex: (data: SheetType.Cell[][]) => {
62
+ startIndex: number;
63
+ endIndex: number;
64
+ };
65
+ export declare const ensureFocus: (container?: HTMLElement | null) => void;
66
+ export declare const isSiblingControl: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
67
+ export declare const isAnotationElement: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
68
+ export declare const isSearchElement: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
69
+ export declare const noramlizeSearch: (target: string) => string;
70
+ export declare const searchInclude: (search: string, compare: string) => boolean;
71
+ export declare const getTextWidth: (text: any) => number;