ronds-metadata 1.0.99 → 1.1.2

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.
@@ -10,7 +10,7 @@ import _Input from "antd/es/input";
10
10
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
11
11
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
13
- var _excluded = ["title", "dataIndex", "isAddColumn", "children", "className"];
13
+ var _excluded = ["title", "dataIndex", "isAddColumn", "children", "className", "style"];
14
14
  import { PlusSquareOutlined, DeleteOutlined } from '@ant-design/icons';
15
15
  import React from 'react';
16
16
  import { EditableContext } from '../interface';
@@ -24,6 +24,7 @@ var EditableHeardCell = function EditableHeardCell(props) {
24
24
  isAddColumn = props.isAddColumn,
25
25
  children = props.children,
26
26
  className = props.className,
27
+ style = props.style,
27
28
  restProps = _objectWithoutProperties(props, _excluded);
28
29
 
29
30
  var _ref = React.useContext(EditableContext) || undefined,
@@ -46,6 +47,18 @@ var EditableHeardCell = function EditableHeardCell(props) {
46
47
  visible = _React$useState4[0],
47
48
  setVisible = _React$useState4[1];
48
49
 
50
+ var myStyle = React.useMemo(function () {
51
+ var res = {};
52
+
53
+ if (style) {
54
+ res = _objectSpread(_objectSpread({}, style), {}, {
55
+ right: style.right - 4
56
+ });
57
+ }
58
+
59
+ return res;
60
+ }, [style]);
61
+
49
62
  var onMouseOver = function onMouseOver() {
50
63
  editableStream.next({
51
64
  type: 'editHeardCellKey',
@@ -112,8 +125,10 @@ var EditableHeardCell = function EditableHeardCell(props) {
112
125
  setVisible(b);
113
126
  };
114
127
 
115
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
128
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", _extends({
116
129
  className: "".concat(className, " ant-table-th font-bold ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
130
+ }, restProps, {
131
+ style: _objectSpread({}, myStyle)
117
132
  }), isAddColumn && /*#__PURE__*/React.createElement(_Popover, {
118
133
  placement: "rightTop",
119
134
  content: content,
@@ -2,8 +2,38 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  }
5
- .ronds-edit-table table {
6
- border-collapse: collapse !important;
5
+ .ronds-edit-table .ant-table-body {
6
+ overflow: auto !important;
7
+ }
8
+ .ronds-edit-table .ant-table-header::-webkit-scrollbar {
9
+ width: 4px;
10
+ background: transparent !important;
11
+ }
12
+ .ronds-edit-table .ant-table-body::-webkit-scrollbar,
13
+ .ronds-edit-table .ant-table-body-inner::-webkit-scrollbar {
14
+ width: 4px;
15
+ height: 4px;
16
+ }
17
+ .ronds-edit-table .ant-table-body::-webkit-scrollbar-thumb,
18
+ .ronds-edit-table .ant-table-body-inner::-webkit-scrollbar-thumb {
19
+ border-radius: 4px;
20
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
21
+ background: #909090;
22
+ }
23
+ .ronds-edit-table .ant-table-body::-webkit-scrollbar-track,
24
+ .ronds-edit-table .ant-table-body-inner::-webkit-scrollbar-track {
25
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
26
+ border-radius: 4px;
27
+ background: #ededed;
28
+ }
29
+ .ronds-edit-table .ant-table-fixed-left .ant-table-body-outer,
30
+ .ronds-edit-table .ant-table-fixed-right .ant-table-body-outer {
31
+ margin-bottom: 0 !important;
32
+ }
33
+ .ronds-edit-table .ant-table-fixed-left .ant-table-cell-scrollbar,
34
+ .ronds-edit-table .ant-table-fixed-right .ant-table-cell-scrollbar {
35
+ margin: 0 !important;
36
+ padding: 0 !important;
7
37
  }
8
38
  .ronds-edit-table .ant-spin-nested-loading,
9
39
  .ronds-edit-table .ant-spin-container,
@@ -18,10 +48,6 @@
18
48
  height: 30px;
19
49
  padding: 0px 8px !important;
20
50
  }
21
- .ronds-edit-table .ant-table-cell-fix-right {
22
- position: sticky !important;
23
- right: 0 !important;
24
- }
25
51
  .ronds-edit-table .ant-table-body {
26
52
  height: 100%;
27
53
  overflow-y: auto !important;
@@ -33,10 +33,6 @@ interface IEditableProps<R = any> {
33
33
  * 是否可以添加列
34
34
  */
35
35
  isAddColumn?: boolean;
36
- /**
37
- * 删除列白名单
38
- */
39
- whiteColumn?: string[];
40
36
  /**
41
37
  * antd自身的属性
42
38
  */
@@ -32,7 +32,6 @@ var Editable = function Editable(props) {
32
32
  addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
33
33
  _props$isAddColumn = props.isAddColumn,
34
34
  isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
35
- whiteColumn = props.whiteColumn,
36
35
  tableProps = props.tableProps,
37
36
  onRowConfirm = props.onRowConfirm,
38
37
  onRowDelete = props.onRowDelete,
@@ -67,16 +66,9 @@ var Editable = function Editable(props) {
67
66
  var _React$useState9 = React.useState(),
68
67
  _React$useState10 = _slicedToArray(_React$useState9, 2),
69
68
  editHeardCellKey = _React$useState10[0],
70
- setEditHeardCellkey = _React$useState10[1]; // 记录临时加的列头
69
+ setEditHeardCellkey = _React$useState10[1]; // 记录上一次发生改变的行值
71
70
 
72
71
 
73
- var _React$useState11 = React.useState([]),
74
- _React$useState12 = _slicedToArray(_React$useState11, 2),
75
- addColumns = _React$useState12[0],
76
- setAddColumns = _React$useState12[1];
77
-
78
- var addColumnsRef = React.useRef([]); // 记录上一次发生改变的行值
79
-
80
72
  var lastValueRef = React.useRef(); // 记录上一次的datasource
81
73
 
82
74
  var lastDataSourceRef = React.useRef();
@@ -128,14 +120,6 @@ var Editable = function Editable(props) {
128
120
  setEditHeardCellkey(data.payload);
129
121
  break;
130
122
 
131
- case 'onAddColumn':
132
- processAddColumnsData(data.payload);
133
- break;
134
-
135
- case 'onDeleteColumn':
136
- processDeleteColumnsData(data.payload);
137
- break;
138
-
139
123
  case 'onSingleSave':
140
124
  if (lastValueRef.current && lastValueRef.current.rowIdx === data.payload._rowKey_) {
141
125
  onRowConfirm && onRowConfirm({
@@ -202,52 +186,7 @@ var Editable = function Editable(props) {
202
186
  }
203
187
  }, [type]); // 集中处理数据流
204
188
 
205
- useObservable(processStreamFactory, [editableStream]);
206
-
207
- var processAddColumnsData = function processAddColumnsData(data) {
208
- var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns; // 判断key是否重复
209
-
210
-
211
- if (_columns.findIndex(function (v) {
212
- return v.key === data.key;
213
- }) > -1) {
214
- // message.warning('表格的key不可以重复');
215
- return;
216
- }
217
-
218
- var idx = _columns.findIndex(function (v) {
219
- return v.dataIndex === data.dataIndex;
220
- });
221
-
222
- var obj = {
223
- title: data.title,
224
- key: data.key,
225
- dataIndex: data.key
226
- };
227
-
228
- _columns.splice(idx + 1, 0, _objectSpread(_objectSpread({}, _columns[0]), obj));
229
-
230
- setAddColumns(_toConsumableArray(_columns));
231
- addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
232
- };
233
-
234
- var processDeleteColumnsData = function processDeleteColumnsData(data) {
235
- var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns;
236
-
237
- if (whiteColumn.findIndex(function (v) {
238
- return v === data.dataIndex;
239
- }) > -1) {
240
- // message.warning(`${data.dataIndex}无法删除`);
241
- return;
242
- }
243
-
244
- _columns = _columns.filter(function (v) {
245
- return v.dataIndex != data.dataIndex;
246
- });
247
- setAddColumns(_toConsumableArray(_columns));
248
- addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
249
- }; // 返回stream的实例
250
-
189
+ useObservable(processStreamFactory, [editableStream]); // 返回stream的实例
251
190
 
252
191
  React.useEffect(function () {
253
192
  if (firstLoadRef && editableStream) {
@@ -290,7 +229,7 @@ var Editable = function Editable(props) {
290
229
  }, [readonly, type]); // 处理一下编辑表格的数据
291
230
 
292
231
  var _columns = React.useMemo(function () {
293
- var __columns__ = addColumns && addColumns.length > 0 ? addColumns : columns;
232
+ var __columns__ = columns;
294
233
 
295
234
  var res = __columns__.map(getEditColumn);
296
235
 
@@ -317,7 +256,7 @@ var Editable = function Editable(props) {
317
256
  }
318
257
 
319
258
  return res;
320
- }, [columns, readonly, type, addColumns]); // 主要是自己加一层rowkey
259
+ }, [columns, readonly, type]); // 主要是自己加一层rowkey
321
260
 
322
261
 
323
262
  var _dataSource = React.useMemo(function () {
@@ -380,6 +319,7 @@ var Editable = function Editable(props) {
380
319
  }
381
320
  }
382
321
  }, /*#__PURE__*/React.createElement(_Table, _extends({
322
+ key: _columns.length,
383
323
  className: "ronds-edit-table",
384
324
  bordered: true,
385
325
  scroll: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.99",
4
+ "version": "1.1.2",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",