@yilianjituan/yilian_dgerm 0.0.1-alpha.43 → 0.0.1-alpha.45

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.
@@ -66,8 +66,6 @@
66
66
  .ant-table-thead>tr>th,
67
67
  .ant-table-tbody>tr>td {
68
68
  text-align: center;
69
- min-width: 80px;
70
- max-width: 230px;
71
69
  }
72
70
 
73
71
  &__filter {
@@ -21,13 +21,13 @@ import { Resizable } from 'react-resizable';
21
21
  import "./index.scss";
22
22
  /**
23
23
  * 处理单元格大小
24
- *
24
+ *
25
25
  * @param index 当前列的索引,用于标识是哪一列的宽度发生了变化
26
26
  * @param columns 表格的列配置数组,包含了所有列的配置信息
27
27
  * @param newColumnsVoid 一个回调函数,用于应用新的列配置
28
28
  */
29
29
  var handleResize = function handleResize(index, columns, newColumnsVoid) {
30
- return function (_, _ref) {
30
+ return function (e, _ref) {
31
31
  var size = _ref.size;
32
32
  try {
33
33
  // 检查索引是否超出范围
@@ -35,6 +35,8 @@ var handleResize = function handleResize(index, columns, newColumnsVoid) {
35
35
  console.error('Index out of bounds:', index);
36
36
  return;
37
37
  }
38
+ var MIN_COLUMN_WIDTH = 20;
39
+ if (size.width < MIN_COLUMN_WIDTH) return;
38
40
 
39
41
  // 更新指定列的宽度
40
42
  var newColumns = columns.map(function (column, i) {
@@ -45,6 +47,8 @@ var handleResize = function handleResize(index, columns, newColumnsVoid) {
45
47
 
46
48
  // 返回新的列配置
47
49
  newColumnsVoid(newColumns);
50
+ e.preventDefault();
51
+ e.stopPropagation();
48
52
  } catch (error) {
49
53
  console.error('Error in handleResize:', error);
50
54
  }
@@ -79,19 +83,26 @@ var mergedColumns = function mergedColumns(columns, tableRef, newColumnsVoid) {
79
83
  console.log('Error while fetching header cells:', error); // 异常处理
80
84
  }
81
85
  }
82
- return columns === null || columns === void 0 ? void 0 : columns.map(function (col, index) {
86
+ var _columns = columns.map(function (col, index) {
87
+ if (typeof col.width === 'number') {
88
+ return _objectSpread(_objectSpread({}, col), {}, {
89
+ width: col.width
90
+ });
91
+ } else {
92
+ return _objectSpread(_objectSpread({}, col), {}, {
93
+ width: widthsList[index]
94
+ });
95
+ }
96
+ });
97
+ return _columns === null || _columns === void 0 ? void 0 : _columns.map(function (col, index) {
83
98
  return _objectSpread(_objectSpread({}, col), {}, {
84
- onHeaderCell: function onHeaderCell(column) {
99
+ onHeaderCell: function onHeaderCell() {
85
100
  return {
86
- width: typeof column.width === 'number' ? column.width : widthsList[index] || 150,
101
+ width: col.width,
87
102
  // 设置默认宽度
88
103
  isEnd: index === columns.length - 1,
89
104
  // 判断是否是最后一个
90
- onResize: handleResize(index, columns.map(function (column) {
91
- return _objectSpread(_objectSpread({}, column), {}, {
92
- width: typeof column.width === 'number' ? column.width : widthsList[index] || 150
93
- });
94
- }), newColumnsVoid)
105
+ onResize: handleResize(index, columns, newColumnsVoid)
95
106
  };
96
107
  }
97
108
  });
@@ -115,10 +126,28 @@ var ResizableTitle = function ResizableTitle(props) {
115
126
  } : {}, {
116
127
  onClick: function onClick(e) {
117
128
  return e.stopPropagation();
129
+ },
130
+ onMouseDown: function onMouseDown(e) {
131
+ e.preventDefault();
132
+ e.stopPropagation();
133
+ },
134
+ onMouseUp: function onMouseUp(e) {
135
+ e.preventDefault();
136
+ e.stopPropagation();
118
137
  }
119
138
  })),
120
139
  onResize: function onResize(event, data) {
121
- return _onResize === null || _onResize === void 0 ? void 0 : _onResize(event, data);
140
+ _onResize === null || _onResize === void 0 || _onResize(event, data);
141
+ event.stopPropagation();
142
+ } // 阻止事件冒泡
143
+ ,
144
+ onResizeStop: function onResizeStop(event) {
145
+ event.preventDefault();
146
+ event.stopPropagation();
147
+ },
148
+ onResizeStart: function onResizeStart(event) {
149
+ event.preventDefault();
150
+ event.stopPropagation();
122
151
  },
123
152
  draggableOpts: {
124
153
  enableUserSelectHack: false
@@ -138,7 +167,7 @@ var CustomTable = function CustomTable(props) {
138
167
  setColumn = _React$useState2[1];
139
168
  useEffect(function () {
140
169
  setColumn(columns);
141
- }, [dataSource]);
170
+ }, [dataSource, columns]);
142
171
  var customComponents = _objectSpread({
143
172
  header: _objectSpread({
144
173
  cell: ResizableTitle
@@ -11,4 +11,15 @@
11
11
  width: 10px;
12
12
  height: 100%;
13
13
  cursor: col-resize;
14
+ }
15
+
16
+ /* 样式文件 */
17
+ .ant-table-cell {
18
+ word-wrap: break-word !important;
19
+ word-break: break-all !important;
20
+ }
21
+
22
+ .react-resizable {
23
+ word-wrap: break-word !important;
24
+ word-break: break-all !important;
14
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yilianjituan/yilian_dgerm",
3
- "version": "0.0.1-alpha.43",
3
+ "version": "0.0.1-alpha.45",
4
4
  "description": "A react library developed with dumi",
5
5
  "keywords": [
6
6
  "React",