lu-lowcode-package-form 0.11.56 → 0.11.57
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
@@ -3,7 +3,7 @@ import { eventEmitter } from "../../../utils/events"
|
|
3
3
|
import { createPortal } from "react-dom"
|
4
4
|
import { Resizable } from "react-resizable"
|
5
5
|
|
6
|
-
const DragHead = ({
|
6
|
+
const DragHead = ({ childrenDesc, changeWidth, showAction, showLabel = false, ...props }) => {
|
7
7
|
const [headWidths, setHeadWidths] = useState([])
|
8
8
|
const headWidthsRef = useRef([])
|
9
9
|
const [isDragging, setIsDragging] = useState(false)
|
@@ -57,7 +57,7 @@ const DragHead = ({ children, changeWidth, showAction, showLabel = false, ...pro
|
|
57
57
|
// 虚拟指示线组件
|
58
58
|
const DragIndicator = () => {
|
59
59
|
if (!isDragging) return null
|
60
|
-
|
60
|
+
|
61
61
|
const style = {
|
62
62
|
position: 'fixed',
|
63
63
|
top: 0,
|
@@ -68,7 +68,7 @@ const DragHead = ({ children, changeWidth, showAction, showLabel = false, ...pro
|
|
68
68
|
pointerEvents: 'none',
|
69
69
|
zIndex: 9999
|
70
70
|
}
|
71
|
-
|
71
|
+
|
72
72
|
return createPortal(
|
73
73
|
<div style={style}></div>,
|
74
74
|
document.body
|
@@ -76,44 +76,44 @@ const DragHead = ({ children, changeWidth, showAction, showLabel = false, ...pro
|
|
76
76
|
}
|
77
77
|
|
78
78
|
return <><div className="fflex flex-nowrap fmin-w-full fabsolute">
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
79
|
+
{childrenDesc.map((child, childIndex) => {
|
80
|
+
const width = getColumnWidth(childIndex)
|
81
|
+
|
82
|
+
return (
|
83
|
+
<Resizable
|
84
|
+
key={childIndex}
|
85
|
+
width={width}
|
86
|
+
height={0} // 高度不用调整,设为0
|
87
|
+
onResizeStart={onResizeStart(childIndex)}
|
88
|
+
onResize={onResize(childIndex)}
|
89
|
+
onResizeStop={onResizeStop(childIndex)}
|
90
|
+
handle={
|
91
|
+
<div
|
92
|
+
className="react-resizable-handle react-resizable-handle-e"
|
93
|
+
style={{
|
94
|
+
position: 'absolute',
|
95
|
+
right: 0,
|
96
|
+
top: 0,
|
97
|
+
height: '100%',
|
98
|
+
width: '8px',
|
99
|
+
cursor: 'col-resize',
|
100
|
+
zIndex: 9999
|
101
|
+
}}
|
102
|
+
/>
|
103
|
+
}
|
104
|
+
resizeHandles={['e']} // 只允许从右侧拖动调整宽度
|
105
|
+
>
|
106
|
+
<div
|
107
|
+
className="fflex-1 fh-12 fflex fitems-center fpx-1 frelative"
|
108
|
+
style={{ minWidth: width }}
|
109
|
+
>
|
110
|
+
{showLabel ? <>{child?.props?.label}</> : <> </>}
|
111
|
+
</div>
|
112
|
+
</Resizable>
|
113
|
+
)
|
114
|
+
})}
|
115
|
+
{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>}
|
116
|
+
</div>
|
117
117
|
<DragIndicator /></>
|
118
118
|
}
|
119
119
|
|
@@ -52,14 +52,6 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
|
|
52
52
|
console.log("Table props", props)
|
53
53
|
}, [props])
|
54
54
|
|
55
|
-
useEffect(()=>{
|
56
|
-
const childrenDesc = React.Children.map(children, (child) => {
|
57
|
-
return {id:child.props.componentId || child.props.__id,label:child.props.label}
|
58
|
-
})
|
59
|
-
console.log("Emit Table childrenDesc", childrenDesc)
|
60
|
-
eventEmitter.emit("tableChildrenDesc", childrenDesc)
|
61
|
-
},[children])
|
62
|
-
|
63
55
|
const [headWidths, setHeadWidths] = useState([])
|
64
56
|
const tableComponentId = props.componentId || props.__id
|
65
57
|
const newidRefs = useRef(React.Children.map(children, () => nanoid()));
|
@@ -67,6 +59,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
|
|
67
59
|
const name = props.componentId || props.__id
|
68
60
|
const childrenIds = React.Children.map(children, (child) => `${name}.${child.props.componentId || child.props.__id}`)
|
69
61
|
const rules = []
|
62
|
+
const [childrenDesc, setChildrenDesc] = useState([])
|
70
63
|
const handleAdd = () => {
|
71
64
|
if (!init) setInit(true);
|
72
65
|
form?.setFieldValue(fieldName, [{}])
|
@@ -85,6 +78,15 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
|
|
85
78
|
}
|
86
79
|
}, [])
|
87
80
|
|
81
|
+
useEffect(()=>{
|
82
|
+
const childrenDesc = React.Children.map(children, (child) => {
|
83
|
+
return {id:child.props.componentId || child.props.__id,label:child.props.label}
|
84
|
+
})
|
85
|
+
console.log("Emit Table childrenDesc", childrenDesc)
|
86
|
+
eventEmitter.emit("tableChildrenDesc", childrenDesc)
|
87
|
+
setChildrenDesc(childrenDesc)
|
88
|
+
},[children])
|
89
|
+
|
88
90
|
|
89
91
|
const getColumnWidth = (index) => {
|
90
92
|
return headWidths[index] || 150
|
@@ -140,7 +142,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
|
|
140
142
|
return <div className="fw-full ">
|
141
143
|
|
142
144
|
<div className="fw-full frelative fmin-h-20 foverflow-x-auto" style={{ position: 'relative' }}>
|
143
|
-
<DragHead changeWidth={handleChangeWidth} showAction={disabled != true && readonly != true}
|
145
|
+
<DragHead changeWidth={handleChangeWidth} showAction={disabled != true && readonly != true} childrenDesc={childrenDesc}/>
|
144
146
|
{fields.length === 0 && <div key={`tableHead`} className="fborder-b fflex flex-nowrap fmin-w-full ">
|
145
147
|
{React.Children.map(children, (child, childIndex) => {
|
146
148
|
const hidden = (child?.props?.calcHidden || !getDependencyMapShow(child?.props?.componentId || child?.props?.__id)) && mode != "desgin";
|