lu-lowcode-package-form 0.11.9 → 0.11.11

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.
@@ -90,7 +90,7 @@ const WithSingleSelect = ({ readItemRender, readonly, onChange, onCustomChange,v
90
90
  }
91
91
 
92
92
  }, [value])
93
- if (readonly) return <div className=" fh-8 fflex fitems-center fgap-2">
93
+ if (readonly) return <div className=" fh-8 fflex fitems-center fgap-2 w-full fborder fborder-[#dadada] frounded fbox-border fpx-2 fpy-1 ">
94
94
  {value && value.label && <>{readItemRender && typeof readItemRender === "function" ? readItemRender(value) : <span key={`btn_${value?.value}`}>{value?.label}</span>}</>}
95
95
  </div>
96
96
  return (
@@ -80,17 +80,20 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
80
80
 
81
81
  // 添加节流后的 initializeFormRender
82
82
  const throttledInitializeFormRender = React.useCallback(
83
- throttle(() => {
83
+ throttle(async () => {
84
84
  console.log("throttledInitializeFormRender")
85
- initializeDependencyMap();
86
- setFormContent(renderChildren());
85
+ await initializeDependencyMap();
86
+ requestAnimationFrame(() => {
87
+ setFormContent(renderChildren());
88
+ })
89
+ console.log("throttledInitializeFormRender end")
90
+
87
91
  }, 300),
88
92
  [children, cols]
89
93
  );
90
94
 
91
95
 
92
96
  useEffect(() => {
93
- console.log("children", children)
94
97
  throttledInitializeFormRender();
95
98
  return () => {
96
99
  throttledInitializeFormRender.cancel();
@@ -113,7 +116,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
113
116
  // }
114
117
  // return current;
115
118
  }
116
- const initializeDependencyMap = () => {
119
+ const initializeDependencyMap = async () => {
117
120
  const fields = [];
118
121
  function traverse(currentNode, parentNode = null) {
119
122
  var componentName = currentNode.type?.displayName || currentNode.props?._componentName;
@@ -157,19 +160,26 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
157
160
  });
158
161
  });
159
162
  console.log("dependencyMap.current", dependencyMap.current)
160
- initializeFieldVisibility();
163
+ await initializeFieldVisibilityImmediate();
161
164
  };
162
-
163
- // 初始化字段的级联关系
164
- const initializeFieldVisibility = debounce(async (reloadFields = false) => {
165
+ const initializeFieldVisibilityImmediate = async (reloadFields = false) => {
165
166
  console.log("initializeFieldVisibility *************************************")
166
167
  const fieldValues = form.getFieldsValue();
167
- for (let key of dependencyMap.current.keys()) {
168
- await handleFieldsWith(key, fieldValues, true);
169
- }
168
+
169
+ await Promise.all(Array.from(dependencyMap.current.keys()).map(async (key) => {
170
+ await handleFieldsWith(key, fieldValues, true);
171
+ }))
172
+ // for (let key of dependencyMap.current.keys()) {
173
+ // await handleFieldsWith(key, fieldValues, true);
174
+ // }
170
175
  if (reloadFields) setFormContent(renderChildren());
176
+ };
177
+ // 初始化字段的级联关系
178
+ const initializeFieldVisibility = debounce(async (reloadFields = false) => {
179
+ await initializeFieldVisibilityImmediate(reloadFields);
171
180
  }, 100);
172
181
 
182
+
173
183
  // 计算字段级联关系
174
184
  const handleFieldsWith = async (identifier, fieldValues, init = false) => {
175
185
  // console.log("handleFieldsWith identifier", identifier)