@cloudbase/weda-ui 3.17.6 → 3.18.0
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/configs/components/wd-select-multiple.d.ts +2 -0
- package/dist/configs/components/wd-select-multiple.js +4 -2
- package/dist/configs/components/wd-select.d.ts +2 -0
- package/dist/configs/components/wd-select.js +4 -2
- package/dist/configs/components/wd-table.js +1 -1
- package/dist/configs/index.d.ts +4 -0
- package/dist/configs/type-utils/type-form.d.ts +2 -0
- package/dist/configs/type-utils/type-form.js +32 -4
- package/dist/style/index.css +14 -3
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +5 -5
- package/dist/web/components/form/uploader/upload/index.js +4 -0
- package/dist/web/components/wd-input/wd-input.js +2 -2
- package/dist/web/components/wd-select/hooks/useChooseList.js +5 -3
- package/dist/web/components/wd-select/relationSelect/index.js +2 -7
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +6 -4
- package/dist/web/components/wd-select/select/index.js +9 -3
- package/dist/web/components/wd-select/select/selectUI.js +1 -1
- package/dist/web/components/wd-select/style.d.ts +0 -2
- package/dist/web/components/wd-select/style.js +2 -2
- package/dist/web/components/wd-select/wd-select.js +4 -7
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +4 -4
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +51 -50
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.d.ts +2 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +18 -8
- package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.d.ts +5 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.js +20 -41
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +7 -0
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +44 -14
- package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +13 -8
- package/dist/web/components/wd-table/utils/index.d.ts +18 -0
- package/dist/web/components/wd-table/utils/index.js +64 -56
- package/dist/web/components/wd-table/wd-table.js +4 -2
- package/dist/web/weda-ui.css +28 -63
- package/package.json +1 -1
- package/dist/web/components/wd-table/hooks/useChooseList.d.ts +0 -16
- package/dist/web/components/wd-table/hooks/useChooseList.js +0 -126
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
-
const defaultPage = 1;
|
|
3
|
-
const getUniqueOption = (option) => {
|
|
4
|
-
var _a;
|
|
5
|
-
const optionMap = option.reduce((acc, item) => {
|
|
6
|
-
if (!acc[item.value]) {
|
|
7
|
-
acc[item.value] = item;
|
|
8
|
-
}
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
const uniqueOption = (_a = Object.values(optionMap)) === null || _a === void 0 ? void 0 : _a.filter((item) => item === null || item === void 0 ? void 0 : item.value);
|
|
12
|
-
return uniqueOption;
|
|
13
|
-
};
|
|
14
|
-
const getDataBase = (format, fields) => {
|
|
15
|
-
const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
|
|
16
|
-
const data = filter === null || filter === void 0 ? void 0 : filter.map((item) => {
|
|
17
|
-
var _a, _b, _c;
|
|
18
|
-
const childDbName = (_a = item['x-parent']) === null || _a === void 0 ? void 0 : _a.parentDataSourceName;
|
|
19
|
-
const primaryColumn = (_c = (_b = item.parentDatasource) === null || _b === void 0 ? void 0 : _b.schema) === null || _c === void 0 ? void 0 : _c['x-primary-column'];
|
|
20
|
-
const childItem = {
|
|
21
|
-
childDbName,
|
|
22
|
-
primaryColumn,
|
|
23
|
-
};
|
|
24
|
-
return childItem;
|
|
25
|
-
});
|
|
26
|
-
return data;
|
|
27
|
-
};
|
|
28
|
-
export const getDataBaseInfo = (fields, format, childDbName) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const FORMAT_FATHER_SON = 'father-son';
|
|
31
|
-
const FORMAT_RELATED = 'related';
|
|
32
|
-
const fatherSon = getDataBase(FORMAT_FATHER_SON, fields);
|
|
33
|
-
const related = getDataBase(FORMAT_RELATED, fields);
|
|
34
|
-
const dsList = [
|
|
35
|
-
{
|
|
36
|
-
format: FORMAT_FATHER_SON,
|
|
37
|
-
list: fatherSon,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
format: FORMAT_RELATED,
|
|
41
|
-
list: related,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
const dataBase = (_a = dsList === null || dsList === void 0 ? void 0 : dsList.find((child) => child.format === format)) === null || _a === void 0 ? void 0 : _a.list.find((item) => item.childDbName === childDbName);
|
|
45
|
-
return dataBase;
|
|
46
|
-
};
|
|
47
|
-
export const mapResult = (records, primaryColumn) => {
|
|
48
|
-
var _a;
|
|
49
|
-
return (_a = records === null || records === void 0 ? void 0 : records.filter((i) => i._id)) === null || _a === void 0 ? void 0 : _a.map((childItem) => ({
|
|
50
|
-
_id: childItem._id,
|
|
51
|
-
value: childItem._id,
|
|
52
|
-
text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
|
|
53
|
-
label: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
|
|
54
|
-
extra: childItem,
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
|
-
export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
|
|
58
|
-
const [option, setOption] = useState([]);
|
|
59
|
-
const [total, setTotal] = useState(0);
|
|
60
|
-
const [loading, setLoading] = useState(true);
|
|
61
|
-
const unshiftVal = (transformedRecords, itemResult, originOption) => {
|
|
62
|
-
if (itemResult &&
|
|
63
|
-
transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
|
|
64
|
-
originOption.findIndex((item) => item._id === itemResult._id) < 0) {
|
|
65
|
-
return [itemResult, ...transformedRecords];
|
|
66
|
-
}
|
|
67
|
-
return transformedRecords;
|
|
68
|
-
};
|
|
69
|
-
const fetchData = useCallback(async () => {
|
|
70
|
-
setLoading(true);
|
|
71
|
-
const isMultiple = Array.isArray(value);
|
|
72
|
-
const promiseList = [
|
|
73
|
-
dataSourceAPI.getRecordList(queryParams, {
|
|
74
|
-
db: childDbName,
|
|
75
|
-
}),
|
|
76
|
-
];
|
|
77
|
-
if (value && isInsertSelectedValue) {
|
|
78
|
-
if (isMultiple) {
|
|
79
|
-
value.forEach((i) => {
|
|
80
|
-
if (i) {
|
|
81
|
-
promiseList.push(dataSourceAPI.getRecord(i, {
|
|
82
|
-
db: childDbName,
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
promiseList.push(dataSourceAPI.getRecord(value, {
|
|
89
|
-
db: childDbName,
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const [result, ...rest] = await Promise.all(promiseList);
|
|
94
|
-
let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
|
|
95
|
-
const itemResult = [...rest];
|
|
96
|
-
// 若下拉列表中无选中值,则将选中值插到数组头部
|
|
97
|
-
if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
|
|
98
|
-
itemResult.forEach((i) => {
|
|
99
|
-
transformedRecords = unshiftVal(transformedRecords, i, option);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
let optionRes = mapResult(transformedRecords, primaryColumn);
|
|
103
|
-
if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
|
|
104
|
-
optionRes = [...option, ...optionRes];
|
|
105
|
-
}
|
|
106
|
-
optionRes = getUniqueOption(optionRes);
|
|
107
|
-
setOption(optionRes);
|
|
108
|
-
setTotal(result === null || result === void 0 ? void 0 : result.total);
|
|
109
|
-
setLoading(false);
|
|
110
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
-
}, [childDbName, primaryColumn, queryParams, value]);
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
if (childDbName) {
|
|
114
|
-
fetchData();
|
|
115
|
-
}
|
|
116
|
-
}, [childDbName, fetchData]);
|
|
117
|
-
return {
|
|
118
|
-
result: option || [],
|
|
119
|
-
total: total,
|
|
120
|
-
isValidating: loading,
|
|
121
|
-
empty: () => {
|
|
122
|
-
setOption([]);
|
|
123
|
-
},
|
|
124
|
-
getRelationOptions: fetchData,
|
|
125
|
-
};
|
|
126
|
-
};
|