lu-lowcode-package-form 0.11.41 → 0.11.43
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/dist/index.cjs.js +199 -199
- package/dist/index.es.js +10542 -10533
- package/package.json +1 -1
- package/src/App copy 4.jsx +948 -0
- package/src/App.jsx +3 -471
- package/src/components/field/select/search-select.jsx +58 -20
- package/src/components/form-container/index.jsx +24 -5
@@ -52,9 +52,17 @@ function batchElements(elements, groupSize,dmap) {
|
|
52
52
|
|
53
53
|
const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) => {
|
54
54
|
const [form] = Form.useForm();
|
55
|
+
const formContentRef = React.useRef(null);
|
55
56
|
const [formContent, setFormContent] = React.useState(null);
|
56
57
|
|
57
58
|
const dependencyMap = React.useRef(null);
|
59
|
+
const updateFormContent = () => {
|
60
|
+
const newFormContent = memoizedRenderChildren();
|
61
|
+
if (!isEqual(formContentRef.current, newFormContent)) {
|
62
|
+
formContentRef.current = newFormContent;
|
63
|
+
setFormContent(newFormContent);
|
64
|
+
}
|
65
|
+
}
|
58
66
|
// 调用setFieldsValue时,进入锁定状态,阻止因字段值变化而触发级联处理
|
59
67
|
const lockStatus = React.useRef(0);
|
60
68
|
React.useImperativeHandle(ref, () => ({
|
@@ -88,7 +96,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
88
96
|
await initializeDependencyMap();
|
89
97
|
console.log("initializeDependencyMap")
|
90
98
|
requestAnimationFrame(() => {
|
91
|
-
|
99
|
+
updateFormContent();
|
92
100
|
})
|
93
101
|
// console.log("throttledInitializeFormRender end")
|
94
102
|
|
@@ -177,7 +185,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
177
185
|
// for (let key of dependencyMap.current.keys()) {
|
178
186
|
// await handleFieldsWith(key, fieldValues, true);
|
179
187
|
// }
|
180
|
-
if (reloadFields)
|
188
|
+
if (reloadFields) updateFormContent();
|
181
189
|
};
|
182
190
|
// 初始化字段的级联关系
|
183
191
|
const initializeFieldVisibility = debounce(async (reloadFields = false) => {
|
@@ -245,6 +253,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
245
253
|
changedFieldsState.current[fieldName] = fieldValue;
|
246
254
|
}
|
247
255
|
const recordFieldsChange = (changedFields, handleChange = false) => {
|
256
|
+
console.log("recordFieldsChange", changedFields,handleChange)
|
248
257
|
var changedKeys = Object.keys(changedFields)
|
249
258
|
if (changedKeys.length > 0) {
|
250
259
|
changedKeys.forEach(key => {
|
@@ -618,13 +627,13 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
618
627
|
}
|
619
628
|
if (needRefresh) {
|
620
629
|
console.log("needRefresh", needRefresh)
|
621
|
-
|
630
|
+
updateFormContent();
|
622
631
|
}
|
623
632
|
changedFieldsState.current = {};
|
624
633
|
}, delay);
|
625
634
|
}, []);
|
626
635
|
|
627
|
-
const handleFieldsChange = (changedFields) => {
|
636
|
+
const handleFieldsChange = React.useCallback((changedFields) => {
|
628
637
|
changedFields.filter(field => {
|
629
638
|
if (field.name && field.name.length > 0) {
|
630
639
|
// const fieldKey = field.name.filter(item => typeof item == "string").join(".")
|
@@ -633,7 +642,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
633
642
|
})
|
634
643
|
|
635
644
|
debounceHandleFieldsChange();
|
636
|
-
}
|
645
|
+
}, []);
|
637
646
|
|
638
647
|
const getTableWithIds = (ids) => {
|
639
648
|
let withAllIds = []
|
@@ -678,6 +687,13 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
678
687
|
}
|
679
688
|
return null
|
680
689
|
}
|
690
|
+
const memoizedRenderChildren = () => {
|
691
|
+
console.log("memoizedRenderChildren", dependencyMap.current)
|
692
|
+
if (dependencyMap.current) {
|
693
|
+
return renderChildren();
|
694
|
+
}
|
695
|
+
return null;
|
696
|
+
}
|
681
697
|
const renderChildren = () => {
|
682
698
|
console.log("renderChildren")
|
683
699
|
const renderKey = nanoid()
|
@@ -694,6 +710,9 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
694
710
|
);
|
695
711
|
|
696
712
|
|
713
|
+
|
714
|
+
|
715
|
+
|
697
716
|
|
698
717
|
|
699
718
|
return groupedChildren.map((group, index) => (
|