lu-lowcode-package-form 0.10.58 → 0.10.60
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 +249 -249
- package/dist/index.es.js +12522 -12526
- package/package.json +1 -1
- package/src/App.jsx +1 -0
- package/src/components/field/select/search-select.jsx +23 -20
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -139,30 +139,32 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
139
139
|
}
|
140
140
|
return list
|
141
141
|
}
|
142
|
+
const handleOptions = async (list) => {
|
143
|
+
if (Array.isArray(list)) {
|
144
|
+
for (let index = 0; index < list.length; index++) {
|
145
|
+
const item = list[index];
|
146
|
+
if (typeof subRequest == "function") {
|
147
|
+
let subList = []
|
148
|
+
const { data } = await subRequest(item)
|
149
|
+
if (data?.list && Array.isArray(data.list)) {
|
150
|
+
subList = data.list.map(subItem => ({ label: `${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}` }))
|
151
|
+
}
|
152
|
+
list[index] = { ...item, label: item[option_label], title: item[option_label], options: subList }
|
153
|
+
}
|
154
|
+
list[index] = { ...item, label: item[option_label], value: item[option_value] }
|
155
|
+
}
|
156
|
+
if (nOptions.length > 0 && !isEqual(nOptions, list)) {
|
157
|
+
typeof onChange === 'function' && onChange(undefined)
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return list
|
161
|
+
}
|
142
162
|
|
143
163
|
const fetchOptions = async (params, ruleParams) => {
|
144
164
|
try {
|
145
165
|
let list = await fetchList(params, ruleParams)
|
146
|
-
|
147
|
-
|
148
|
-
for (let index = 0; index < list.length; index++) {
|
149
|
-
const item = list[index];
|
150
|
-
if (typeof subRequest == "function") {
|
151
|
-
let subList = []
|
152
|
-
const { data } = await subRequest(item)
|
153
|
-
if (data?.list && Array.isArray(data.list)) {
|
154
|
-
subList = data.list.map(subItem => ({ label: `${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}` }))
|
155
|
-
}
|
156
|
-
list[index] = { ...item, label: item[option_label], title: item[option_label], options: subList }
|
157
|
-
}
|
158
|
-
list[index] = { ...item, label: item[option_label], value: item[option_value] }
|
159
|
-
}
|
160
|
-
if (nOptions.length > 0 && !isEqual(nOptions, list)) {
|
161
|
-
typeof onChange === 'function' && onChange(undefined)
|
162
|
-
}
|
163
|
-
setNOptions(list)
|
164
|
-
}
|
165
|
-
else setNOptions([])
|
166
|
+
list = await handleOptions(list)
|
167
|
+
setNOptions(Array.isArray(list) ? list : [])
|
166
168
|
return list
|
167
169
|
} catch (error) {
|
168
170
|
console.error("fetchOptions", error)
|
@@ -192,6 +194,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
192
194
|
const loadMoreOptions = async () => {
|
193
195
|
const nextPageParams = { ...requestParams, page: currentPageRef.current + 1, pageSize: currentPageSize };
|
194
196
|
let newOptions = await fetchList(nextPageParams, null)
|
197
|
+
newOptions = await handleOptions(newOptions)
|
195
198
|
if (Array.isArray(newOptions) && newOptions.length > 0) {
|
196
199
|
setNOptions(prevOptions => [...prevOptions, ...newOptions]);
|
197
200
|
currentPageRef.current = currentPageRef.current + 1;
|