lu-lowcode-package-form 0.11.55 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.11.55",
3
+ "version": "0.11.57",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -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 = ({ children, changeWidth, showAction, ...props }) => {
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)
@@ -48,7 +48,6 @@ const DragHead = ({ children, changeWidth, showAction, ...props }) => {
48
48
  headWidthsRef.current = newHeadWidths
49
49
  setHeadWidths(newHeadWidths)
50
50
  typeof changeWidth === 'function' && changeWidth(newHeadWidths)
51
- eventEmitter.emit('changeSubTableColumnWidth', newHeadWidths)
52
51
  // 重置拖动状态
53
52
  setIsDragging(false)
54
53
  setResizingColumn(null)
@@ -58,7 +57,7 @@ const DragHead = ({ children, changeWidth, showAction, ...props }) => {
58
57
  // 虚拟指示线组件
59
58
  const DragIndicator = () => {
60
59
  if (!isDragging) return null
61
-
60
+
62
61
  const style = {
63
62
  position: 'fixed',
64
63
  top: 0,
@@ -69,7 +68,7 @@ const DragHead = ({ children, changeWidth, showAction, ...props }) => {
69
68
  pointerEvents: 'none',
70
69
  zIndex: 9999
71
70
  }
72
-
71
+
73
72
  return createPortal(
74
73
  <div style={style}></div>,
75
74
  document.body
@@ -77,44 +76,44 @@ const DragHead = ({ children, changeWidth, showAction, ...props }) => {
77
76
  }
78
77
 
79
78
  return <><div className="fflex flex-nowrap fmin-w-full fabsolute">
80
- {React.Children.map(children, (child, childIndex) => {
81
- const width = getColumnWidth(childIndex)
82
-
83
- return (
84
- <Resizable
85
- key={childIndex}
86
- width={width}
87
- height={0} // 高度不用调整,设为0
88
- onResizeStart={onResizeStart(childIndex)}
89
- onResize={onResize(childIndex)}
90
- onResizeStop={onResizeStop(childIndex)}
91
- handle={
92
- <div
93
- className="react-resizable-handle react-resizable-handle-e"
94
- style={{
95
- position: 'absolute',
96
- right: 0,
97
- top: 0,
98
- height: '100%',
99
- width: '8px',
100
- cursor: 'col-resize',
101
- zIndex: 9999
102
- }}
103
- />
104
- }
105
- resizeHandles={['e']} // 只允许从右侧拖动调整宽度
106
- >
107
- <div
108
- className="fflex-1 fh-12 fflex fitems-center fpx-1 frelative"
109
- style={{minWidth: width}}
110
- >
111
- &nbsp;
112
- </div>
113
- </Resizable>
114
- )
115
- })}
116
- {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>}
117
- </div>
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}</> : <>&nbsp;</>}
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>
118
117
  <DragIndicator /></>
119
118
  }
120
119
 
@@ -59,6 +59,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
59
59
  const name = props.componentId || props.__id
60
60
  const childrenIds = React.Children.map(children, (child) => `${name}.${child.props.componentId || child.props.__id}`)
61
61
  const rules = []
62
+ const [childrenDesc, setChildrenDesc] = useState([])
62
63
  const handleAdd = () => {
63
64
  if (!init) setInit(true);
64
65
  form?.setFieldValue(fieldName, [{}])
@@ -77,6 +78,15 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
77
78
  }
78
79
  }, [])
79
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
+
80
90
 
81
91
  const getColumnWidth = (index) => {
82
92
  return headWidths[index] || 150
@@ -132,7 +142,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
132
142
  return <div className="fw-full ">
133
143
 
134
144
  <div className="fw-full frelative fmin-h-20 foverflow-x-auto" style={{ position: 'relative' }}>
135
- <DragHead changeWidth={handleChangeWidth} showAction={disabled != true && readonly != true}>{children}</DragHead>
145
+ <DragHead changeWidth={handleChangeWidth} showAction={disabled != true && readonly != true} childrenDesc={childrenDesc}/>
136
146
  {fields.length === 0 && <div key={`tableHead`} className="fborder-b fflex flex-nowrap fmin-w-full ">
137
147
  {React.Children.map(children, (child, childIndex) => {
138
148
  const hidden = (child?.props?.calcHidden || !getDependencyMapShow(child?.props?.componentId || child?.props?.__id)) && mode != "desgin";
@@ -280,4 +290,5 @@ TableWrapper.displayName = "Table"
280
290
  export default TableWrapper;
281
291
  export { TableCol, TableAction };
282
292
 
283
- export { WithTable } from "./with-table"
293
+ export { WithTable } from "./with-table"
294
+ export { DragHead }
@@ -9,7 +9,7 @@ import { default as RadioGroup } from './field/radio/index.jsx'
9
9
  import { UploadFile,UploadImage } from './field/upload'
10
10
  import {default as Switch} from './field/switch'
11
11
  import {default as DatePicker } from './field/date-picker'
12
- import { default as Table , TableCol, WithTable } from './field/table'
12
+ import { default as Table , TableCol, WithTable, DragHead } from './field/table'
13
13
  const Field = {
14
14
  Input,
15
15
  TextArea,
@@ -37,7 +37,8 @@ const Field = {
37
37
  Custom,
38
38
  UserSelect,
39
39
  DeptSelect,
40
- PostSelect
40
+ PostSelect,
41
+ DragHead
41
42
  }
42
43
  Object.keys(Field).forEach(key => {
43
44
  Field[key].displayName = `Field.${key}`;