ronds-metadata 1.2.38 → 1.2.39

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 (134) hide show
  1. package/es/api/index.js +83 -131
  2. package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
  3. package/es/comps/DynamicPorts/comps/DragNode.js +2 -7
  4. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
  5. package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
  6. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
  7. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
  8. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
  9. package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
  10. package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
  11. package/es/comps/DynamicPorts/constant/index.js +2 -5
  12. package/es/comps/DynamicPorts/graph.d.ts +2 -2
  13. package/es/comps/DynamicPorts/graph.js +228 -312
  14. package/es/comps/DynamicPorts/index.js +39 -58
  15. package/es/comps/DynamicPorts/utils.js +21 -25
  16. package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
  17. package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
  18. package/es/comps/Editable/DataCell/Input.js +5 -14
  19. package/es/comps/Editable/DataCell/Number.js +3 -10
  20. package/es/comps/Editable/DataCell/Select.js +7 -14
  21. package/es/comps/Editable/DataCell/Switch.js +2 -7
  22. package/es/comps/Editable/comps/EditableAction.js +8 -12
  23. package/es/comps/Editable/comps/EditableCell.js +16 -26
  24. package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
  25. package/es/comps/Editable/comps/EditableRow.js +49 -59
  26. package/es/comps/Editable/comps/Texty.js +36 -72
  27. package/es/comps/Editable/index.js +67 -112
  28. package/es/comps/Editable/interface.d.ts +1 -1
  29. package/es/comps/Editable/utils.js +0 -1
  30. package/es/comps/FileView/index.js +65 -101
  31. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
  32. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
  33. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
  34. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
  35. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
  36. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
  37. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
  38. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
  39. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
  40. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
  48. package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
  49. package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
  50. package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
  51. package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
  52. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
  53. package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
  54. package/es/comps/FormGenerator/index.js +3 -9
  55. package/es/comps/FormGenerator/interface.d.ts +1 -1
  56. package/es/comps/FormGenerator/settings/index.js +12 -11
  57. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
  58. package/es/comps/FormGenerator/transformer.js +40 -105
  59. package/es/comps/Icons/index.js +4 -7
  60. package/es/comps/JsonEdit/index.js +25 -50
  61. package/es/comps/JsonView/index.js +7 -21
  62. package/es/comps/JsonView/index.less +41 -41
  63. package/es/comps/MdEdit/index.js +7 -10
  64. package/es/comps/MdEdit/index.less +6 -6
  65. package/es/comps/MdEditPro/index.d.ts +10 -0
  66. package/es/comps/MdEditPro/index.js +22 -0
  67. package/es/comps/MdEditPro/index.less +74 -0
  68. package/es/comps/MdNavbar/index.js +17 -40
  69. package/es/comps/MdNavbar/utils.js +0 -4
  70. package/es/comps/MdView/index.js +7 -11
  71. package/es/comps/MdView/index.less +353 -353
  72. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
  73. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
  74. package/es/comps/MetadataEdit/hooks/index.js +3 -11
  75. package/es/comps/MetadataEdit/index.js +25 -58
  76. package/es/comps/MetadataEdit/index.less +10 -10
  77. package/es/comps/MetadataEdit/type.d.ts +20 -20
  78. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
  79. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
  80. package/es/comps/MetadataEditV2/hooks/index.js +5 -12
  81. package/es/comps/MetadataEditV2/index.js +30 -65
  82. package/es/comps/MetadataForm/DataCell/Array.js +12 -23
  83. package/es/comps/MetadataForm/DataCell/Input.js +12 -32
  84. package/es/comps/MetadataForm/DataCell/Number.js +10 -21
  85. package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
  86. package/es/comps/MetadataForm/DataCell/Select.js +127 -222
  87. package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
  88. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +93 -164
  89. package/es/comps/MetadataForm/HOC/index.js +20 -37
  90. package/es/comps/MetadataForm/HOC/index.less +41 -41
  91. package/es/comps/MetadataForm/hooks/index.js +12 -38
  92. package/es/comps/MetadataForm/index.js +37 -72
  93. package/es/comps/MetadataForm/interface.d.ts +3 -3
  94. package/es/comps/MetadataForm/utils.js +0 -14
  95. package/es/comps/Split/index.js +20 -22
  96. package/es/config.js +0 -4
  97. package/es/framework/RxStore/demo/index.js +9 -10
  98. package/es/framework/RxStore/hooks.d.ts +9 -9
  99. package/es/framework/RxStore/hooks.js +10 -35
  100. package/es/framework/RxStore/store.d.ts +4 -4
  101. package/es/framework/RxStore/store.js +0 -10
  102. package/es/framework/fg/index.js +18 -80
  103. package/es/framework/fg/interface.d.ts +2 -2
  104. package/es/framework/fg/utils.js +0 -10
  105. package/es/framework/graph/index.d.ts +2 -2
  106. package/es/framework/graph/index.js +55 -110
  107. package/es/framework/hooks/use-async-memo.js +3 -7
  108. package/es/framework/hooks/use-sync-scroll.js +2 -15
  109. package/es/framework/http/cache.js +25 -32
  110. package/es/framework/http/cancel.js +1 -7
  111. package/es/framework/http/index.js +22 -82
  112. package/es/framework/http/msgpack.js +0 -4
  113. package/es/framework/http/msgpack5/index.js +2 -12
  114. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
  115. package/es/framework/http/msgpack5/lib/decoder.js +10 -68
  116. package/es/framework/http/msgpack5/lib/encoder.js +8 -36
  117. package/es/framework/http/msgpack5/lib/helpers.js +3 -2
  118. package/es/framework/http/msgpack5/lib/streams.js +0 -18
  119. package/es/framework/libs/jquery.min.js +1009 -1696
  120. package/es/framework/locale/dil8/di18n.js +4 -15
  121. package/es/framework/locale/dil8/translate.js +0 -14
  122. package/es/framework/locale/dil8/util.js +0 -3
  123. package/es/framework/locale/index.js +2 -3
  124. package/es/framework/metadata/MetadataService.js +39 -78
  125. package/es/framework/metadata/index.js +4 -70
  126. package/es/framework/metadata/types.d.ts +98 -98
  127. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
  128. package/es/framework/rxjs-hooks/useObservable.js +2 -4
  129. package/es/framework/rxjs-hooks/useObservableState.js +8 -14
  130. package/es/index.d.ts +1 -0
  131. package/es/index.js +2 -1
  132. package/es/theme.less +79 -79
  133. package/es/utils.js +58 -97
  134. package/package.json +104 -102
@@ -8,6 +8,11 @@ import _message from "antd/es/message";
8
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
9
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
10
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
+ /*
12
+ * @Author: wangxain
13
+ * @Date: 2022-03-04 08:53:04
14
+ * @LastEditTime: 2023-02-25 11:11:58
15
+ */
11
16
  import React from 'react';
12
17
  import { pick, isArray } from 'lodash';
13
18
  import { DndProvider } from 'react-dnd';
@@ -22,80 +27,72 @@ import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
22
27
  import useObservable from '../../framework/rxjs-hooks/useObservable';
23
28
  import { tr } from '../../framework/locale';
24
29
  import './index.less';
25
-
26
30
  var Editable = function Editable(props) {
27
31
  var _props$type = props.type,
28
- type = _props$type === void 0 ? 'single' : _props$type,
29
- readonly = props.readonly,
30
- columns = props.columns,
31
- dataSource = props.dataSource,
32
- defaultValue = props.defaultValue,
33
- _props$addPosition = props.addPosition,
34
- addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
35
- _props$isAddColumn = props.isAddColumn,
36
- isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
37
- _props$isAddRow = props.isAddRow,
38
- isAddRow = _props$isAddRow === void 0 ? true : _props$isAddRow,
39
- _props$isAction = props.isAction,
40
- isAction = _props$isAction === void 0 ? true : _props$isAction,
41
- tableProps = props.tableProps,
42
- onMove = props.onMove,
43
- onRowClick = props.onRowClick,
44
- onButtonCellClick = props.onButtonCellClick,
45
- onRowConfirm = props.onRowConfirm,
46
- onRowDelete = props.onRowDelete,
47
- onMulChange = props.onMulChange,
48
- getStreamInstance = props.getStreamInstance;
49
-
32
+ type = _props$type === void 0 ? 'single' : _props$type,
33
+ readonly = props.readonly,
34
+ columns = props.columns,
35
+ dataSource = props.dataSource,
36
+ defaultValue = props.defaultValue,
37
+ _props$addPosition = props.addPosition,
38
+ addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
39
+ _props$isAddColumn = props.isAddColumn,
40
+ isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
41
+ _props$isAddRow = props.isAddRow,
42
+ isAddRow = _props$isAddRow === void 0 ? true : _props$isAddRow,
43
+ _props$isAction = props.isAction,
44
+ isAction = _props$isAction === void 0 ? true : _props$isAction,
45
+ tableProps = props.tableProps,
46
+ onMove = props.onMove,
47
+ onRowClick = props.onRowClick,
48
+ onButtonCellClick = props.onButtonCellClick,
49
+ onRowConfirm = props.onRowConfirm,
50
+ onRowDelete = props.onRowDelete,
51
+ onMulChange = props.onMulChange,
52
+ getStreamInstance = props.getStreamInstance;
50
53
  var _React$useState = React.useState([]),
51
- _React$useState2 = _slicedToArray(_React$useState, 2),
52
- records = _React$useState2[0],
53
- setRecords = _React$useState2[1];
54
-
55
- var recordsRef = React.useRef([]); // 当type为single的时候 只能编辑该行数据
56
-
54
+ _React$useState2 = _slicedToArray(_React$useState, 2),
55
+ records = _React$useState2[0],
56
+ setRecords = _React$useState2[1];
57
+ var recordsRef = React.useRef([]);
58
+ // 当type为single的时候 只能编辑该行数据
57
59
  var _React$useState3 = React.useState(),
58
- _React$useState4 = _slicedToArray(_React$useState3, 2),
59
- editRowKey = _React$useState4[0],
60
- setEditRowkey = _React$useState4[1];
61
-
60
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
61
+ editRowKey = _React$useState4[0],
62
+ setEditRowkey = _React$useState4[1];
62
63
  var _React$useState5 = React.useState('add'),
63
- _React$useState6 = _slicedToArray(_React$useState5, 2),
64
- editType = _React$useState6[0],
65
- setEditType = _React$useState6[1];
66
-
67
- var editRowKeyRef = React.useRef(); // 当type为freedom的时候可以编辑指定cell
68
-
64
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
65
+ editType = _React$useState6[0],
66
+ setEditType = _React$useState6[1];
67
+ var editRowKeyRef = React.useRef();
68
+ // 当type为freedom的时候可以编辑指定cell
69
69
  var _React$useState7 = React.useState(),
70
- _React$useState8 = _slicedToArray(_React$useState7, 2),
71
- editCellKey = _React$useState8[0],
72
- setEditCellkey = _React$useState8[1]; // 添加一列表头
73
-
74
-
70
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
71
+ editCellKey = _React$useState8[0],
72
+ setEditCellkey = _React$useState8[1];
73
+ // 添加一列表头
75
74
  var _React$useState9 = React.useState(),
76
- _React$useState10 = _slicedToArray(_React$useState9, 2),
77
- editHeardCellKey = _React$useState10[0],
78
- setEditHeardCellkey = _React$useState10[1]; // 记录上一次发生改变的行值
79
-
80
-
81
- var lastValueRef = React.useRef(); // 记录上一次的datasource
82
-
75
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
76
+ editHeardCellKey = _React$useState10[0],
77
+ setEditHeardCellkey = _React$useState10[1];
78
+ // 记录上一次发生改变的行值
79
+ var lastValueRef = React.useRef();
80
+ // 记录上一次的datasource
83
81
  var lastDataSourceRef = React.useRef();
84
- var firstLoadRef = React.useRef(true); // 定义处理编辑表格的数据流
85
-
82
+ var firstLoadRef = React.useRef(true);
83
+ // 定义处理编辑表格的数据流
86
84
  var editableStream = useMemoSubject();
87
85
  var processStreamFactory = React.useCallback(function (data) {
88
86
  switch (data === null || data === void 0 ? void 0 : data.type) {
89
87
  case 'onValuesChange':
90
- lastValueRef.current = data.payload; // type为multiple时候处理records
91
-
88
+ lastValueRef.current = data.payload;
89
+ // type为multiple时候处理records
92
90
  if (type === 'multiple') {
93
91
  var _records = recordsRef.current;
94
92
  _records[data.payload.rowIdx] = _objectSpread(_objectSpread({}, _records[data.payload.rowIdx]), data.payload.allValues);
95
93
  onMulChange && onMulChange(_records);
96
- } // type为freedom时候处理records
97
-
98
-
94
+ }
95
+ // type为freedom时候处理records
99
96
  if (type === 'freedom') {
100
97
  var _records2 = recordsRef.current;
101
98
  _records2[data.payload.rowIdx] = _objectSpread(_objectSpread({}, _records2[data.payload.rowIdx]), data.payload.allValues);
@@ -104,39 +101,31 @@ var Editable = function Editable(props) {
104
101
  records: _records2
105
102
  }));
106
103
  }
107
-
108
104
  break;
109
-
110
105
  case 'editRowKey':
111
106
  if (Object.keys(data.payload).length > 1) {
112
107
  setEditType('edit');
113
108
  } else {
114
109
  setEditType('add');
115
110
  }
116
-
117
111
  setEditRowkey(data.payload._rowKey_);
118
112
  editRowKeyRef.current = data.payload._rowKey_;
119
113
  break;
120
-
121
114
  case 'editCellKey':
122
115
  setEditCellkey({
123
116
  dataIndex: data.payload.dataIndex,
124
117
  rowIndex: data.payload.rowIndex
125
118
  });
126
119
  break;
127
-
128
120
  case 'editHeardCellKey':
129
121
  setEditHeardCellkey(data.payload);
130
122
  break;
131
-
132
123
  case 'onRowClick':
133
124
  onRowClick && onRowClick(data.payload);
134
125
  break;
135
-
136
126
  case 'onButtonCellClick':
137
127
  onButtonCellClick && onButtonCellClick(data.payload);
138
128
  break;
139
-
140
129
  case 'onSingleSave':
141
130
  if (lastValueRef.current && lastValueRef.current.rowIdx === data.payload._rowKey_) {
142
131
  onRowConfirm && onRowConfirm({
@@ -149,9 +138,7 @@ var Editable = function Editable(props) {
149
138
  } else {
150
139
  _message.warn(tr('当前值无修改'));
151
140
  }
152
-
153
141
  break;
154
-
155
142
  case 'onDelete':
156
143
  if (type === 'single') {
157
144
  // 如果删除的 是正在编辑的 重置状态
@@ -159,32 +146,24 @@ var Editable = function Editable(props) {
159
146
  setEditRowkey(undefined);
160
147
  editRowKeyRef.current = undefined;
161
148
  }
162
-
163
149
  onRowDelete && onRowDelete(data.payload);
164
150
  }
165
-
166
151
  if (type === 'multiple') {
167
152
  var _records3 = recordsRef.current;
168
-
169
153
  _records3.splice(data.payload._rowKey_, 1);
170
-
171
154
  setRecords(_toConsumableArray(_records3));
172
155
  recordsRef.current = _records3;
173
156
  onMulChange && onMulChange(_records3);
174
157
  }
175
-
176
158
  if (type === 'freedom') {
177
159
  // 正在全行编辑的直接删除,不需要回调
178
160
  if (isFreeEditRow(editRowKeyRef.current, data.payload._rowKey_)) {
179
161
  var _records4 = recordsRef.current;
180
-
181
162
  _records4.splice(data.payload._rowKey_, 1);
182
-
183
163
  setRecords(_toConsumableArray(_records4));
184
- recordsRef.current = _records4; // 移除当前的行的编辑状态
185
-
164
+ recordsRef.current = _records4;
165
+ // 移除当前的行的编辑状态
186
166
  var _editRowKey = removeCurKeyFromEditRow(editRowKeyRef.current, data.payload._rowKey_);
187
-
188
167
  setEditRowkey(_editRowKey);
189
168
  editRowKeyRef.current = _editRowKey;
190
169
  editableStream.next({
@@ -195,23 +174,21 @@ var Editable = function Editable(props) {
195
174
  });
196
175
  return;
197
176
  }
198
-
199
177
  onRowDelete && onRowDelete(data.payload);
200
178
  }
201
-
202
179
  break;
203
180
  }
204
- }, [type]); // 集中处理数据流
205
-
206
- useObservable(processStreamFactory, [editableStream]); // 返回stream的实例
207
-
181
+ }, [type]);
182
+ // 集中处理数据流
183
+ useObservable(processStreamFactory, [editableStream]);
184
+ // 返回stream的实例
208
185
  React.useEffect(function () {
209
186
  if (firstLoadRef && editableStream) {
210
187
  getStreamInstance && getStreamInstance(editableStream);
211
188
  firstLoadRef.current = false;
212
189
  }
213
- }, [editableStream]); // 定义内部的record
214
-
190
+ }, [editableStream]);
191
+ // 定义内部的record
215
192
  React.useEffect(function () {
216
193
  if (dataSource) {
217
194
  setRecords(_toConsumableArray(dataSource));
@@ -222,7 +199,6 @@ var Editable = function Editable(props) {
222
199
  var _column = _objectSpread(_objectSpread({}, column), {}, {
223
200
  children: isArray(column === null || column === void 0 ? void 0 : column.children) ? column.children.map(getEditColumn) : undefined
224
201
  });
225
-
226
202
  if (column.editable && !readonly) {
227
203
  _column.onCell = function (record, rowIndex) {
228
204
  return _objectSpread(_objectSpread({
@@ -233,7 +209,6 @@ var Editable = function Editable(props) {
233
209
  rowIndex: rowIndex
234
210
  });
235
211
  };
236
-
237
212
  _column.onHeaderCell = function (col) {
238
213
  return _objectSpread({
239
214
  width: col.width,
@@ -241,15 +216,12 @@ var Editable = function Editable(props) {
241
216
  }, pick(column, ['title', 'dataIndex']));
242
217
  };
243
218
  }
244
-
245
219
  return _column;
246
- }, [readonly, type]); // 处理一下编辑表格的数据
247
-
220
+ }, [readonly, type]);
221
+ // 处理一下编辑表格的数据
248
222
  var _columns = React.useMemo(function () {
249
223
  var __columns__ = columns;
250
-
251
224
  var res = __columns__.map(getEditColumn);
252
-
253
225
  if (!readonly && isAction) {
254
226
  var _aciton_ = {
255
227
  dataKey: '_aciton_',
@@ -264,67 +236,51 @@ var Editable = function Editable(props) {
264
236
  }));
265
237
  }
266
238
  };
267
-
268
239
  if (type === 'single') {
269
240
  res.push(_aciton_);
270
241
  } else if (defaultValue) {
271
242
  res.push(_aciton_);
272
243
  }
273
244
  }
274
-
275
245
  return res;
276
- }, [columns, readonly, type]); // 主要是自己加一层rowkey
277
-
278
-
246
+ }, [columns, readonly, type]);
247
+ // 主要是自己加一层rowkey
279
248
  var _dataSource = React.useMemo(function () {
280
249
  var res = records.map(function (it, idx) {
281
250
  return _objectSpread({
282
251
  _rowKey_: idx
283
252
  }, it);
284
253
  });
285
-
286
254
  if (res.length > 0) {
287
255
  firstLoadRef.current = false;
288
256
  }
289
-
290
257
  lastDataSourceRef.current = res;
291
258
  return res;
292
259
  }, [records, type]);
293
-
294
260
  var onAddRow = function onAddRow() {
295
261
  if (defaultValue) {
296
262
  if (type === 'freedom' && editRowKey) {
297
263
  _message.warn(tr('请先保存正在编辑的行'));
298
-
299
264
  return;
300
265
  }
301
-
302
266
  var _records = recordsRef.current;
303
-
304
267
  if (addPosition === 'top') {
305
268
  _records.unshift(defaultValue);
306
269
  } else {
307
270
  _records.push(defaultValue);
308
271
  }
309
-
310
272
  if (type === 'freedom') {
311
273
  var _editRowKeyRef$curren;
312
-
313
274
  var _editRowKeyArr = ((_editRowKeyRef$curren = editRowKeyRef.current) === null || _editRowKeyRef$curren === void 0 ? void 0 : _editRowKeyRef$curren.toString().split(',')) || ['undefined'];
314
-
315
275
  var _curKey = addPosition === 'top' ? _editRowKeyArr.length - 1 : _records.length - 1;
316
-
317
276
  var _editRowKey = "".concat(editRowKeyRef.current, ",").concat(_curKey);
318
-
319
277
  setEditRowkey(_editRowKey);
320
278
  editRowKeyRef.current = _editRowKey;
321
279
  }
322
-
323
280
  setRecords(_toConsumableArray(_records));
324
281
  recordsRef.current = _records;
325
282
  }
326
283
  };
327
-
328
284
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableContext.Provider, {
329
285
  value: {
330
286
  editableStream: editableStream,
@@ -382,5 +338,4 @@ var Editable = function Editable(props) {
382
338
  onClick: onAddRow
383
339
  }, tr('添加一行'))));
384
340
  };
385
-
386
341
  export default Editable;
@@ -32,7 +32,7 @@ export interface EditableRowProps extends React.HTMLAttributes<HTMLElement> {
32
32
  index?: any;
33
33
  onMove?: (data: any) => void;
34
34
  }
35
- export declare type InputType = 'bool' | 'number' | 'text' | 'enum' | string;
35
+ export type InputType = 'bool' | 'number' | 'text' | 'enum' | string;
36
36
  export interface EditColumnsType extends ColumnsType<any> {
37
37
  type?: InputType;
38
38
  enum?: {
@@ -23,7 +23,6 @@ export function getDataCell(item) {
23
23
  var Comm = DataCellMap[item.type];
24
24
  return /*#__PURE__*/React.createElement(Comm, item);
25
25
  }
26
-
27
26
  return null;
28
27
  }
29
28
  export function isFreeEditRow(curRow, rowIndex) {
@@ -1,34 +1,29 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import React from 'react';
6
6
  import { ReactJexcel } from 'react-jexcel';
7
7
  import * as XLSX from 'xlsx';
8
-
9
8
  var FileView = function FileView(props) {
10
9
  var path = props.path,
11
- data = props.data,
12
- file = props.file,
13
- _props$limit = props.limit,
14
- limit = _props$limit === void 0 ? 1000 : _props$limit;
10
+ data = props.data,
11
+ file = props.file,
12
+ _props$limit = props.limit,
13
+ limit = _props$limit === void 0 ? 1000 : _props$limit;
15
14
  var ref = React.useRef(null);
16
15
  var firstLoadRef = React.useRef(true);
17
-
18
16
  var _React$useState = React.useState(),
19
- _React$useState2 = _slicedToArray(_React$useState, 2),
20
- title = _React$useState2[0],
21
- setTitle = _React$useState2[1];
22
-
17
+ _React$useState2 = _slicedToArray(_React$useState, 2),
18
+ title = _React$useState2[0],
19
+ setTitle = _React$useState2[1];
23
20
  var _React$useState3 = React.useState(),
24
- _React$useState4 = _slicedToArray(_React$useState3, 2),
25
- value = _React$useState4[0],
26
- setValue = _React$useState4[1];
27
-
21
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
22
+ value = _React$useState4[0],
23
+ setValue = _React$useState4[1];
28
24
  var processDataToExcel = React.useCallback(function (data) {
29
25
  var _title = [];
30
26
  var _value = [];
31
-
32
27
  if (data && data.length > 0) {
33
28
  var p = data[0];
34
29
  var f = Object.keys(p);
@@ -40,114 +35,89 @@ var FileView = function FileView(props) {
40
35
  };
41
36
  });
42
37
  setTitle(_toConsumableArray(_title));
43
-
44
38
  var _loop = function _loop(i) {
45
39
  var arr = f.map(function (it) {
46
40
  return data[i][it];
47
41
  });
48
-
49
42
  _value.push(arr);
50
-
51
43
  if (i === limit - 1) return "break";
52
44
  };
53
-
54
45
  for (var i = 0; i < data.length; i++) {
55
46
  var _ret = _loop(i);
56
-
57
47
  if (_ret === "break") break;
58
48
  }
59
-
60
49
  setValue([].concat(_value));
61
50
  firstLoadRef.current = false;
62
51
  }
63
- }, []); // 文件流转 base64
64
-
52
+ }, []);
53
+ // 文件流转 base64
65
54
  var fixdata = function fixdata(data) {
66
55
  var o = '',
67
- l = 0,
68
- w = 10240;
69
-
70
- for (; l < data.byteLength / w; ++l) {
71
- o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
72
- }
73
-
56
+ l = 0,
57
+ w = 10240;
58
+ for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
74
59
  o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
75
60
  return o;
76
61
  };
77
-
78
62
  var getFileData = React.useCallback( /*#__PURE__*/function () {
79
63
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_file) {
80
64
  var blob, res, fileReader;
81
65
  return _regeneratorRuntime.wrap(function _callee$(_context) {
82
- while (1) {
83
- switch (_context.prev = _context.next) {
84
- case 0:
85
- if (!firstLoadRef.current) {
86
- _context.next = 14;
87
- break;
88
- }
89
-
90
- if (!path) {
91
- _context.next = 10;
92
- break;
93
- }
94
-
95
- _context.next = 4;
96
- return fetch(path);
97
-
98
- case 4:
99
- res = _context.sent;
100
- _context.next = 7;
101
- return res.blob();
102
-
103
- case 7:
104
- blob = _context.sent;
105
- _context.next = 11;
66
+ while (1) switch (_context.prev = _context.next) {
67
+ case 0:
68
+ if (!firstLoadRef.current) {
69
+ _context.next = 14;
70
+ break;
71
+ }
72
+ if (!path) {
73
+ _context.next = 10;
106
74
  break;
107
-
108
- case 10:
109
- blob = _file;
110
-
111
- case 11:
112
- fileReader = new FileReader(); //二进制
113
- // fileReader.readAsBinaryString(blob);
114
-
115
- fileReader.onload = function (event) {
116
- try {
117
- var _data = []; // 以二进制流方式读取得到整份excel表格对象
118
-
119
- var result = event.target.result; // 遍历每张工作表进行读取(这里默认只读取第一张表)
120
-
121
- var workbook = XLSX.read(fixdata(result), {
122
- type: 'binary',
123
- codepage: 65001
124
- });
125
-
126
- for (var sheet in workbook.Sheets) {
127
- if (workbook.Sheets.hasOwnProperty(sheet)) {
128
- // 利用 sheet_to_json 方法将 excel 转成 json 数据
129
- _data = _data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet])); // 如果只取第一张表,就取消注释这行
130
-
131
- break;
132
- }
75
+ }
76
+ _context.next = 4;
77
+ return fetch(path);
78
+ case 4:
79
+ res = _context.sent;
80
+ _context.next = 7;
81
+ return res.blob();
82
+ case 7:
83
+ blob = _context.sent;
84
+ _context.next = 11;
85
+ break;
86
+ case 10:
87
+ blob = _file;
88
+ case 11:
89
+ fileReader = new FileReader(); //二进制
90
+ // fileReader.readAsBinaryString(blob);
91
+ fileReader.onload = function (event) {
92
+ try {
93
+ var _data = [];
94
+ // 以二进制流方式读取得到整份excel表格对象
95
+ var result = event.target.result;
96
+ // 遍历每张工作表进行读取(这里默认只读取第一张表)
97
+ var workbook = XLSX.read(fixdata(result), {
98
+ type: 'binary',
99
+ codepage: 65001
100
+ });
101
+ for (var sheet in workbook.Sheets) {
102
+ if (workbook.Sheets.hasOwnProperty(sheet)) {
103
+ // 利用 sheet_to_json 方法将 excel 转成 json 数据
104
+ _data = _data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
105
+ // 如果只取第一张表,就取消注释这行
106
+ break;
133
107
  }
134
-
135
- processDataToExcel(_data);
136
- } catch (e) {
137
- return;
138
108
  }
139
- };
140
-
141
- fileReader.readAsArrayBuffer(blob);
142
-
143
- case 14:
144
- case "end":
145
- return _context.stop();
146
- }
109
+ processDataToExcel(_data);
110
+ } catch (e) {
111
+ return;
112
+ }
113
+ };
114
+ fileReader.readAsArrayBuffer(blob);
115
+ case 14:
116
+ case "end":
117
+ return _context.stop();
147
118
  }
148
119
  }, _callee);
149
120
  }));
150
-
151
121
  return function (_x) {
152
122
  return _ref.apply(this, arguments);
153
123
  };
@@ -159,7 +129,6 @@ var FileView = function FileView(props) {
159
129
  ref.current = null;
160
130
  };
161
131
  }
162
-
163
132
  return function () {};
164
133
  }, [getFileData, path]);
165
134
  React.useEffect(function () {
@@ -169,7 +138,6 @@ var FileView = function FileView(props) {
169
138
  ref.current = null;
170
139
  };
171
140
  }
172
-
173
141
  return function () {};
174
142
  }, [getFileData, file]);
175
143
  React.useEffect(function () {
@@ -179,14 +147,11 @@ var FileView = function FileView(props) {
179
147
  ref.current = null;
180
148
  };
181
149
  }
182
-
183
150
  return function () {};
184
151
  }, [getFileData, data]);
185
-
186
152
  if (!value) {
187
153
  return /*#__PURE__*/React.createElement(React.Fragment, null);
188
154
  }
189
-
190
155
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactJexcel, {
191
156
  ref: ref,
192
157
  data: value,
@@ -194,5 +159,4 @@ var FileView = function FileView(props) {
194
159
  rowResize: true
195
160
  }));
196
161
  };
197
-
198
162
  export default FileView;