lu-lowcode-package-form 0.11.64 → 0.11.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.11.64",
3
+ "version": "0.11.65",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -20,6 +20,31 @@ const DragHead = ({ childrenDesc, initialWidth, changeWidth, showAction, showLab
20
20
  }
21
21
  },[initialWidth])
22
22
 
23
+ useEffect(() => {
24
+ // 创建CSS变量
25
+ document.documentElement.style.setProperty('--drag-position', '0px');
26
+
27
+ // 创建指示线DOM元素
28
+ const indicator = document.createElement('div');
29
+ indicator.id = 'column-drag-indicator';
30
+ indicator.style.cssText = `
31
+ position: fixed;
32
+ top: 0;
33
+ left: var(--drag-position);
34
+ width: 2px;
35
+ height: 100vh;
36
+ background-color: #1890ff;
37
+ pointer-events: none;
38
+ z-index: 9999;
39
+ display: none;
40
+ `;
41
+ document.body.appendChild(indicator);
42
+
43
+ return () => {
44
+ document.body.removeChild(indicator);
45
+ };
46
+ }, []);
47
+
23
48
  const getColumnWidth = (index) => {
24
49
  return headWidths[index] || 150
25
50
  }
@@ -27,11 +52,12 @@ const DragHead = ({ childrenDesc, initialWidth, changeWidth, showAction, showLab
27
52
  // 处理拖动开始
28
53
  const onResizeStart = (index) => {
29
54
  return (e, data) => {
30
- e.stopPropagation()
31
- setIsDragging(true)
32
- setResizingColumn(index)
33
- setDragPosition(e.clientX)
34
- startPositionRef.current = e.clientX
55
+ e.stopPropagation();
56
+ document.getElementById('column-drag-indicator').style.display = 'block';
57
+ setIsDragging(true);
58
+ setResizingColumn(index);
59
+ document.documentElement.style.setProperty('--drag-position', `${e.clientX}px`);
60
+ startPositionRef.current = e.clientX;
35
61
  }
36
62
  }
37
63
 
@@ -39,26 +65,32 @@ const DragHead = ({ childrenDesc, initialWidth, changeWidth, showAction, showLab
39
65
  const onResize = (index) => {
40
66
  return (e, { size }) => {
41
67
  e.stopPropagation()
42
- // 只在拖动过程中更新虚拟指示线位置
43
- setDragPosition(e.clientX)
68
+ requestAnimationFrame(() => {
69
+ // // 只在拖动过程中更新虚拟指示线位置
70
+ // setDragPosition(e.clientX)
71
+ document.documentElement.style.setProperty('--drag-position', `${e.clientX}px`);
72
+ });
44
73
  }
45
74
  }
46
75
 
47
76
  // 处理拖动结束
48
77
  const onResizeStop = (index) => {
49
78
  return (e, { size }) => {
79
+ document.getElementById('column-drag-indicator').style.display = 'none';
80
+
50
81
  // 更新列宽
51
- const newHeadWidths = [...headWidthsRef.current]
52
- const delta = e.clientX - startPositionRef.current
53
- const oldWidth = headWidths[index] || 150
54
- const newWidth = Math.max(50, oldWidth + delta)
55
- newHeadWidths[index] = newWidth
56
- headWidthsRef.current = newHeadWidths
57
- setHeadWidths(newHeadWidths)
58
- typeof changeWidth === 'function' && changeWidth(newHeadWidths)
82
+ const newHeadWidths = [...headWidthsRef.current];
83
+ const delta = e.clientX - startPositionRef.current;
84
+ const oldWidth = headWidths[index] || 150;
85
+ const newWidth = Math.max(50, oldWidth + delta);
86
+ newHeadWidths[index] = newWidth;
87
+ headWidthsRef.current = newHeadWidths;
88
+ setHeadWidths(newHeadWidths);
89
+ typeof changeWidth === 'function' && changeWidth(newHeadWidths);
90
+
59
91
  // 重置拖动状态
60
- setIsDragging(false)
61
- setResizingColumn(null)
92
+ setIsDragging(false);
93
+ setResizingColumn(null);
62
94
  }
63
95
  }
64
96
 
@@ -122,7 +154,8 @@ const DragHead = ({ childrenDesc, initialWidth, changeWidth, showAction, showLab
122
154
  })}
123
155
  {showAction && <div className="fsticky fright-0 fborder-b" style={{ boxShadow: "rgba(50, 50, 50, 0.15) -6px 0px 6px -6px", flex: "0 0 50px", width: "50px" }}></div>}
124
156
  </div>
125
- <DragIndicator /></>
157
+ {/* <DragIndicator /> */}
158
+ </>
126
159
  }
127
160
 
128
161
  export default DragHead
@@ -81,7 +81,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
81
81
  setHeadWidths(props?.columnsWidth)
82
82
  setInitialWidth(props?.columnsWidth)
83
83
  }
84
- }, [props])
84
+ }, [props?.columnsWidth])
85
85
 
86
86
  useEffect(()=>{
87
87
  console.log("Table headWidths", headWidths)