@cloudbase/weda-ui 3.14.4 → 3.15.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/listView.d.ts +11 -0
- package/dist/configs/components/listView.js +53 -0
- package/dist/configs/components/wd-select-multiple.d.ts +72 -28
- package/dist/configs/components/wd-select-multiple.js +233 -19
- package/dist/configs/components/wd-select.d.ts +70 -29
- package/dist/configs/components/wd-select.js +211 -17
- package/dist/configs/index.d.ts +174 -60
- package/dist/configs/type-utils/type-form.js +65 -21
- package/dist/configs/type-utils/x-runtime-default.d.ts +2 -0
- package/dist/configs/type-utils/x-runtime-default.js +4 -0
- package/dist/style/index.css +15 -0
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +3 -3
- package/dist/web/components/form/uploader/util.js +3 -2
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +3 -2
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +3 -2
- package/dist/web/components/listView/index.css +4 -2
- package/dist/web/components/listView/index.js +25 -43
- package/dist/web/components/richText/index.js +3 -2
- package/dist/web/components/statusContent/index.js +1 -1
- package/dist/web/components/wd-input/wd-input.js +16 -20
- package/dist/web/components/wd-select/contexts/selectContext.d.ts +15 -0
- package/dist/web/components/wd-select/contexts/selectContext.js +13 -0
- package/dist/web/components/wd-select/hooks/useChooseList.d.ts +19 -0
- package/dist/web/components/wd-select/hooks/useChooseList.js +94 -0
- package/dist/web/components/wd-select/relationSelect/enumSelect.d.ts +2 -0
- package/dist/web/components/wd-select/relationSelect/enumSelect.js +48 -0
- package/dist/web/components/wd-select/relationSelect/index.d.ts +2 -0
- package/dist/web/components/wd-select/relationSelect/index.js +19 -0
- package/dist/web/components/wd-select/relationSelect/queryParams.d.ts +15 -0
- package/dist/web/components/wd-select/relationSelect/queryParams.js +15 -0
- package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +0 -2
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +39 -83
- package/dist/web/components/wd-select/select/index.js +1 -1
- package/dist/web/components/wd-select/wd-select.css +8 -0
- package/dist/web/components/wd-select/wd-select.js +11 -8
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +11 -8
- package/dist/web/components/wd-table/components/FieldRender/index.js +3 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +8 -13
- package/dist/web/utils/getModelParams.d.ts +6 -1
- package/dist/web/utils/getModelParams.js +16 -13
- package/dist/web/utils/tcb.d.ts +4 -0
- package/dist/web/utils/tcb.js +11 -9
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useImperativeHandle } from 'react';
|
|
4
4
|
import { useDebouncedCallback } from '@react-hookz/web';
|
|
5
5
|
import { LoadingTip } from 'tea-component';
|
|
6
6
|
import { SelectUI as Select } from '../select/selectUI';
|
|
@@ -9,12 +9,11 @@ import { getTableColumns } from '../../wd-table/components/FieldRender';
|
|
|
9
9
|
import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
|
|
10
10
|
import { usePlatform } from '../../../utils/platform';
|
|
11
11
|
import { DataSource } from '../../../utils/datasource';
|
|
12
|
-
import { EnumHoc } from '../../../utils/hooks/EnumHoc';
|
|
13
12
|
import { useSyncValue } from '../../../utils/hooks/useSyncValue';
|
|
14
13
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { deepClone } from '../../../utils/tool';
|
|
15
|
+
import { useChooseList } from '../hooks/useChooseList';
|
|
16
|
+
import { getDefaultQuery } from './queryParams';
|
|
18
17
|
const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, }) => {
|
|
19
18
|
const platform = usePlatform();
|
|
20
19
|
const columns = useMemo(() => {
|
|
@@ -46,18 +45,18 @@ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelati
|
|
|
46
45
|
}
|
|
47
46
|
}, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", title: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value), children: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
|
|
48
47
|
onRelationOptionJump({ item: option });
|
|
49
|
-
}, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
|
|
48
|
+
}, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
|
|
50
49
|
};
|
|
51
50
|
// 每次请求数据个数
|
|
52
51
|
const defaultSize = 50;
|
|
53
52
|
const defaultPage = 1;
|
|
54
53
|
export function RelationSelect(props) {
|
|
55
54
|
var _a, _b;
|
|
56
|
-
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, } = props;
|
|
55
|
+
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, ignoreCase = true, where, queryCondition, supportManyRelated, sorter, } = props;
|
|
57
56
|
const selectFieldsLength = selectFieldType === 'custom' ? selectFields === null || selectFields === void 0 ? void 0 : selectFields.length : 0;
|
|
58
57
|
// 设置下拉列表与下拉按钮同宽
|
|
59
58
|
// 以传入为准,未传入,在自定义展示字段少于2个时设置为 true,否则设置为false,宽度设置为700,
|
|
60
|
-
const _matchButtonWidth = (_a = props === null || props === void 0 ? void 0 : props.matchButtonWidth) !== null && _a !== void 0 ? _a : selectFieldsLength <
|
|
59
|
+
const _matchButtonWidth = (_a = props === null || props === void 0 ? void 0 : props.matchButtonWidth) !== null && _a !== void 0 ? _a : selectFieldsLength < 3;
|
|
61
60
|
// 以传入为准,未传入,在不与按钮同宽度的情况下,listHeight 会被设置为 400
|
|
62
61
|
const _listHeight = (_b = props === null || props === void 0 ? void 0 : props.listHeight) !== null && _b !== void 0 ? _b : (_matchButtonWidth ? undefined : 400);
|
|
63
62
|
const { authFields } = useAuthFields({
|
|
@@ -74,11 +73,18 @@ export function RelationSelect(props) {
|
|
|
74
73
|
// 是否具备展示自定义字段的条件
|
|
75
74
|
const isRelationSelectOption = selectFieldType === 'custom' && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length) && (authFields === null || authFields === void 0 ? void 0 : authFields.length);
|
|
76
75
|
const dataSourceAPI = useMemo(() => new DataSource(dataSourceName), [dataSourceName]); // datasource 方法-模型
|
|
77
|
-
const
|
|
76
|
+
const defaultQuery = useMemo(() => getDefaultQuery({
|
|
77
|
+
queryCondition,
|
|
78
|
+
where,
|
|
79
|
+
selectFieldType,
|
|
80
|
+
selectFields,
|
|
81
|
+
supportManyRelated,
|
|
82
|
+
sorter,
|
|
83
|
+
}), [queryCondition, selectFieldType, selectFields, where, supportManyRelated, sorter]);
|
|
78
84
|
const [query, setQuery] = useSyncValue({
|
|
85
|
+
...defaultQuery,
|
|
79
86
|
pageNo: defaultPage,
|
|
80
87
|
pageSize: defaultSize,
|
|
81
|
-
where: whereList,
|
|
82
88
|
}, isObjectEqual);
|
|
83
89
|
const { result: options, total, isValidating, empty, getRelationOptions, } = useChooseList({
|
|
84
90
|
dataSourceAPI,
|
|
@@ -86,7 +92,6 @@ export function RelationSelect(props) {
|
|
|
86
92
|
queryParams: query,
|
|
87
93
|
primaryColumn: primaryField,
|
|
88
94
|
value,
|
|
89
|
-
isInsertSelectedValue: true,
|
|
90
95
|
});
|
|
91
96
|
const [isLoading, setIsLoading] = useSyncValue(isValidating, isObjectEqual);
|
|
92
97
|
// 下拉选项数据
|
|
@@ -107,10 +112,10 @@ export function RelationSelect(props) {
|
|
|
107
112
|
options,
|
|
108
113
|
selectFields,
|
|
109
114
|
]);
|
|
110
|
-
const searchOptionListWithWhere = useDebouncedCallback((
|
|
115
|
+
const searchOptionListWithWhere = useDebouncedCallback((filter = defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter) => {
|
|
111
116
|
empty();
|
|
112
|
-
setQuery({ ...query, pageNo: defaultPage,
|
|
113
|
-
}, [
|
|
117
|
+
setQuery({ ...query, pageNo: defaultPage, filter });
|
|
118
|
+
}, [query, defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter, empty, setQuery], 300);
|
|
114
119
|
useImperativeHandle(childRef, () => {
|
|
115
120
|
return {
|
|
116
121
|
refresh: async () => {
|
|
@@ -132,78 +137,29 @@ export function RelationSelect(props) {
|
|
|
132
137
|
const searchHandle = (keyword) => {
|
|
133
138
|
empty();
|
|
134
139
|
setIsLoading(true);
|
|
135
|
-
let
|
|
136
|
-
if (keyword
|
|
140
|
+
let filter = deepClone(defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter);
|
|
141
|
+
if (keyword) {
|
|
142
|
+
const search = ignoreCase ? '$search_ci' : '$search';
|
|
137
143
|
// 筛选面板的查询条件与数据过滤的查询条件是且的关系
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
filter = {
|
|
145
|
+
...filter,
|
|
146
|
+
where: {
|
|
147
|
+
$and: [filter.where, { $and: [{ [primaryField]: { [`${search}`]: keyword } }] }],
|
|
148
|
+
},
|
|
140
149
|
};
|
|
141
150
|
}
|
|
142
|
-
searchOptionListWithWhere(
|
|
143
|
-
onSearch(keyword);
|
|
144
|
-
};
|
|
145
|
-
return (_jsx(EnumHoc, { fields: authFields, children: _jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, listWidth: listWidth, listHeight: _listHeight, matchButtonWidth: _matchButtonWidth, placeholder: placeholder, appearance: 'button', filter: () => true, size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
|
|
146
|
-
if (!isLoading && customOptions.length < total) {
|
|
147
|
-
setQuery((query) => ({
|
|
148
|
-
...query,
|
|
149
|
-
pageNo: query.pageNo + defaultPage,
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
}, onOpen: () => {
|
|
153
|
-
setIsLoading(true);
|
|
154
|
-
searchOptionListWithWhere();
|
|
155
|
-
}, footer: addRelationButton, mode: mode }) }));
|
|
156
|
-
}
|
|
157
|
-
export function EnumSelect(props) {
|
|
158
|
-
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
|
|
159
|
-
const [enumOption, setEnumOption] = useState([]);
|
|
160
|
-
const [isLoading, setLoading] = useState(false);
|
|
161
|
-
// 获取枚举字段类型的下拉选项
|
|
162
|
-
const getEnumOption = useCallback(async () => {
|
|
163
|
-
const params = {
|
|
164
|
-
format,
|
|
165
|
-
dataSourceName,
|
|
166
|
-
viewId,
|
|
167
|
-
where,
|
|
168
|
-
primaryField,
|
|
169
|
-
enumName,
|
|
170
|
-
};
|
|
171
|
-
setLoading(true);
|
|
172
|
-
const options = await requestEnumOption(params);
|
|
173
|
-
setEnumOption(options);
|
|
174
|
-
setLoading(false);
|
|
175
|
-
}, [dataSourceName, enumName, format, primaryField, viewId, where]);
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
getEnumOption();
|
|
178
|
-
}, [getEnumOption]);
|
|
179
|
-
useImperativeHandle(childRef, () => {
|
|
180
|
-
return {
|
|
181
|
-
refresh: async () => {
|
|
182
|
-
setRefreshStatus(true);
|
|
183
|
-
await getEnumOption();
|
|
184
|
-
// eslint-disable-next-line rulesdir/no-timer
|
|
185
|
-
const timer = setTimeout(() => {
|
|
186
|
-
setRefreshStatus(false);
|
|
187
|
-
clearTimeout(timer);
|
|
188
|
-
}, 500);
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
}, [getEnumOption, setRefreshStatus]);
|
|
192
|
-
const searchHandle = (keyword) => {
|
|
151
|
+
searchOptionListWithWhere(filter);
|
|
193
152
|
onSearch(keyword);
|
|
194
153
|
};
|
|
195
|
-
return (_jsx(Select, { ...props,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return _jsx(LoadingTip, {});
|
|
207
|
-
}
|
|
208
|
-
return isEnumType ? (_jsx(EnumSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus })) : (_jsx(RelationSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus }));
|
|
154
|
+
return (_jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, listWidth: listWidth, listHeight: _listHeight, matchButtonWidth: _matchButtonWidth, placeholder: placeholder, appearance: 'button', filter: () => true, size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
|
|
155
|
+
if (!isLoading && customOptions.length < total) {
|
|
156
|
+
setQuery((query) => ({
|
|
157
|
+
...query,
|
|
158
|
+
pageNo: query.pageNo + defaultPage,
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
}, onOpen: () => {
|
|
162
|
+
setIsLoading(true);
|
|
163
|
+
searchOptionListWithWhere();
|
|
164
|
+
}, footer: addRelationButton, mode: mode }));
|
|
209
165
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConfigProvider } from 'tea-component';
|
|
3
|
-
import { CustomSelect } from '../relationSelect/
|
|
3
|
+
import { CustomSelect } from '../relationSelect/index';
|
|
4
4
|
import { SelectUI as Select } from './selectUI';
|
|
5
5
|
export function SelectCom(props) {
|
|
6
6
|
const { isRelation } = props;
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
display: none;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/* h5 */
|
|
18
|
+
.wd-form-item.wd-h5-select-root .form-select-pc {
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
/* pc */
|
|
18
23
|
.wd-form-item.wd-pc-select-root .form-select-pc {
|
|
19
24
|
width: 100%;
|
|
@@ -165,6 +170,9 @@
|
|
|
165
170
|
.wd-relation-select-overlay .wedatea2td-dropdown-box .wedatea2td-list--option .wedatea2td-list__status {
|
|
166
171
|
padding: 6px 8px;
|
|
167
172
|
}
|
|
173
|
+
.wd-relation-select-overlay .wedatea2td-dropdown-box > div:nth-child(2) {
|
|
174
|
+
min-height: 105px;
|
|
175
|
+
}
|
|
168
176
|
/* h5端关联下拉样式 */
|
|
169
177
|
.weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select.wd-relation-select-overlay
|
|
170
178
|
.weda-ui-custom-picker__cloumn-item {
|
|
@@ -9,9 +9,12 @@ import { useSelected } from '../../utils/hooks/use-selected';
|
|
|
9
9
|
import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
|
|
10
10
|
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
11
11
|
import { useDelayEvents } from '../../utils/hooks/use-delay-events';
|
|
12
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
13
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
12
14
|
import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
|
|
13
15
|
import { RelationalSetting } from './relationSelect/relationalSetting';
|
|
14
16
|
import { SelectCom as Select } from './select';
|
|
17
|
+
import { SelectProvider } from './contexts/selectContext';
|
|
15
18
|
/**
|
|
16
19
|
* 下拉单选-标准化
|
|
17
20
|
*/
|
|
@@ -19,7 +22,7 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
|
|
|
19
22
|
const { classRoot = 'select', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, format, tipBlock = X_RUNTIME_DEFAULT.tipBlock, where = X_RUNTIME_DEFAULT.where, enumName, primaryField, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
|
|
20
23
|
selectFieldType = 'primary', searchPlaceholder, } = props;
|
|
21
24
|
const childRef = useRef(null);
|
|
22
|
-
const [options, setOptions] =
|
|
25
|
+
const [options, setOptions] = useSyncValue(range, isObjectEqual);
|
|
23
26
|
const [innerHandle, setInnerHandle] = useState({});
|
|
24
27
|
const traitProps = { ...props, inputRef: ref, setInnerHandle };
|
|
25
28
|
const trait = useFormInputTrait(traitProps);
|
|
@@ -102,11 +105,11 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
|
|
|
102
105
|
}, [debouncedTriggerSearchEvent]);
|
|
103
106
|
if (!visible)
|
|
104
107
|
return null;
|
|
105
|
-
return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(Select, { ...props, style: undefined, className: undefined,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
return (_jsx(SelectProvider, { options: options, setOptions: setOptions, children: _jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(Select, { ...props, style: undefined, className: undefined, onRelationTagClick: (item) => {
|
|
109
|
+
var _a;
|
|
110
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
111
|
+
}, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
|
|
112
|
+
var _a;
|
|
113
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
114
|
+
}, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, where: where, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
|
|
112
115
|
});
|
|
@@ -8,11 +8,14 @@ import { useSelected } from '../../utils/hooks/use-selected';
|
|
|
8
8
|
import { emptyObject } from '../../utils/constant';
|
|
9
9
|
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
10
10
|
import { useDelayEvents } from '../../utils/hooks/use-delay-events';
|
|
11
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
12
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
11
13
|
import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
|
|
12
14
|
import './style';
|
|
13
15
|
import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
|
|
14
16
|
import { isFormatWithRelation } from '../form/select/formats-util';
|
|
15
17
|
import { RelationalSetting } from '../wd-select/relationSelect/relationalSetting';
|
|
18
|
+
import { SelectProvider } from '../wd-select/contexts/selectContext';
|
|
16
19
|
/**
|
|
17
20
|
* 下拉多选-标准化
|
|
18
21
|
*/
|
|
@@ -20,7 +23,7 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
|
|
|
20
23
|
const { classRoot = 'select-multiple', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, enumName, format, primaryField, tipBlock = X_RUNTIME_DEFAULT.tipBlock, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, where = X_RUNTIME_DEFAULT.where, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
|
|
21
24
|
selectFieldType = 'primary', searchPlaceholder, } = props;
|
|
22
25
|
const childRef = useRef(null);
|
|
23
|
-
const [options, setOptions] =
|
|
26
|
+
const [options, setOptions] = useSyncValue(range, isObjectEqual);
|
|
24
27
|
const [innerHandle, setInnerHandle] = useState({});
|
|
25
28
|
const traitProps = { ...props, inputRef: ref, setInnerHandle };
|
|
26
29
|
const trait = useFormInputTrait(traitProps);
|
|
@@ -98,11 +101,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
|
|
|
98
101
|
}, [debouncedTriggerSearchEvent]);
|
|
99
102
|
if (!visible)
|
|
100
103
|
return null;
|
|
101
|
-
return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, style: undefined, className: undefined,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
return (_jsx(SelectProvider, { options: options, setOptions: setOptions, children: _jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, style: undefined, className: undefined, onRelationTagClick: (item) => {
|
|
105
|
+
var _a;
|
|
106
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
107
|
+
}, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
|
|
108
|
+
var _a;
|
|
109
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
110
|
+
}, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
|
|
108
111
|
});
|
|
@@ -782,7 +782,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
782
782
|
? {
|
|
783
783
|
modelType: 'table-h5',
|
|
784
784
|
showTip: false,
|
|
785
|
-
relation: record[`@${key}`],
|
|
785
|
+
relation: record === null || record === void 0 ? void 0 : record[`@${key}`],
|
|
786
786
|
columnSet: item2,
|
|
787
787
|
rowId: record._id,
|
|
788
788
|
supportManyRelated,
|
|
@@ -791,9 +791,9 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
791
791
|
}
|
|
792
792
|
: {
|
|
793
793
|
modelType: 'table',
|
|
794
|
-
relation: record[`@${key}`],
|
|
794
|
+
relation: record === null || record === void 0 ? void 0 : record[`@${key}`],
|
|
795
795
|
columnSet: item2,
|
|
796
|
-
rowId: record._id,
|
|
796
|
+
rowId: record === null || record === void 0 ? void 0 : record._id,
|
|
797
797
|
supportManyRelated,
|
|
798
798
|
isH5,
|
|
799
799
|
showRelationWithTag,
|
|
@@ -12,7 +12,7 @@ export const fieldCalculations = {
|
|
|
12
12
|
// { text: '不为空', value: '$nempty' },
|
|
13
13
|
],
|
|
14
14
|
string: [
|
|
15
|
-
{ text: '包含', value: '
|
|
15
|
+
{ text: '包含', value: 'search_ci' },
|
|
16
16
|
{ text: '不包含', value: 'exclude' },
|
|
17
17
|
{ text: '等于', value: 'eq' },
|
|
18
18
|
{ text: '不等于', value: 'neq' },
|
|
@@ -70,8 +70,7 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
70
70
|
fieldCalculation,
|
|
71
71
|
options: [],
|
|
72
72
|
};
|
|
73
|
-
if (i.type === 'number' &&
|
|
74
|
-
['time', 'date', 'datetime'].includes(i.format)) {
|
|
73
|
+
if (i.type === 'number' && ['time', 'date', 'datetime'].includes(i.format)) {
|
|
75
74
|
filterFieldItemConfig.filterType = i.format;
|
|
76
75
|
}
|
|
77
76
|
if (i.type === 'boolean') {
|
|
@@ -97,10 +96,8 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
97
96
|
filterFieldItemConfig.filterType = i.format;
|
|
98
97
|
filterFieldItemConfig.xMultiSelect = i['x-multi-select'];
|
|
99
98
|
filterFieldItemConfig.xOptionName = i['x-option-name'];
|
|
100
|
-
filterFieldItemConfig.fieldCalculation.type =
|
|
101
|
-
|
|
102
|
-
filterFieldItemConfig.fieldCalculation.value =
|
|
103
|
-
filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
99
|
+
filterFieldItemConfig.fieldCalculation.type = filterFieldItemConfig.xMultiSelect ? 'checkbox' : 'radio';
|
|
100
|
+
filterFieldItemConfig.fieldCalculation.value = filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
104
101
|
}
|
|
105
102
|
if (i.format === 'father-son' || i.format === 'related') {
|
|
106
103
|
filterFieldItemConfig.filterType = i.format;
|
|
@@ -115,18 +112,16 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
115
112
|
filterFieldItemConfig.value = ((_c = i.filterConfig) === null || _c === void 0 ? void 0 : _c.value) || '';
|
|
116
113
|
// 默认计算方式
|
|
117
114
|
const customFieldCalculation = fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.find((option) => { var _a; return option.value === ((_a = i.filterConfig) === null || _a === void 0 ? void 0 : _a.filterType); });
|
|
118
|
-
filterFieldItemConfig.fieldCalculation =
|
|
119
|
-
customFieldCalculation || filterFieldItemConfig.fieldCalculation;
|
|
115
|
+
filterFieldItemConfig.fieldCalculation = customFieldCalculation || filterFieldItemConfig.fieldCalculation;
|
|
120
116
|
// 支持的运算类型
|
|
121
117
|
const customFieldCalculationOptions = fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.filter((option) => {
|
|
122
118
|
var _a;
|
|
123
119
|
const filterTypeOption = [].concat((_a = i.filterConfig) === null || _a === void 0 ? void 0 : _a.filterTypeOption);
|
|
124
120
|
return filterTypeOption === null || filterTypeOption === void 0 ? void 0 : filterTypeOption.find((j) => (option === null || option === void 0 ? void 0 : option.value) === j);
|
|
125
121
|
});
|
|
126
|
-
filterFieldItemConfig.fieldCalculationOption =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
: fieldCalculationOption;
|
|
122
|
+
filterFieldItemConfig.fieldCalculationOption = (customFieldCalculationOptions === null || customFieldCalculationOptions === void 0 ? void 0 : customFieldCalculationOptions.length)
|
|
123
|
+
? customFieldCalculationOptions
|
|
124
|
+
: fieldCalculationOption;
|
|
130
125
|
}
|
|
131
126
|
return filterFieldItemConfig;
|
|
132
127
|
});
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export function convertWhere(props: any, supportManyRelated: any): any;
|
|
2
|
+
export function getFilter(wList: any): any;
|
|
3
|
+
export function getSelectFields(props: any): any;
|
|
2
4
|
export function getModelParams(props: any): {
|
|
3
5
|
orderBy: any;
|
|
4
6
|
orderType: any;
|
|
5
7
|
filter: any;
|
|
6
|
-
select:
|
|
8
|
+
select: any;
|
|
7
9
|
where: any[];
|
|
8
10
|
};
|
|
11
|
+
export function transformSorter(sorter?: any[]): {
|
|
12
|
+
[x: number]: any;
|
|
13
|
+
}[];
|
|
@@ -24,7 +24,7 @@ export const convertWhere = (props, supportManyRelated) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* 拼接filter参数
|
|
26
26
|
*/
|
|
27
|
-
const getFilter = (wList) => {
|
|
27
|
+
export const getFilter = (wList) => {
|
|
28
28
|
var _a, _b, _c;
|
|
29
29
|
let where = [];
|
|
30
30
|
let filter = { where: {} };
|
|
@@ -62,19 +62,21 @@ const getFilter = (wList) => {
|
|
|
62
62
|
}
|
|
63
63
|
return getParseValue(filter);
|
|
64
64
|
};
|
|
65
|
-
const getSelectFields = (props) => {
|
|
66
|
-
|
|
65
|
+
export const getSelectFields = (props) => {
|
|
66
|
+
const { selectFieldType = 'main', selectFields = [] } = props;
|
|
67
|
+
// 是否具备展示自定义字段的条件
|
|
68
|
+
const isRelationSelectOption = selectFieldType === 'custom' && Array.isArray(selectFields) && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length);
|
|
67
69
|
// 支持自定义查询字段
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
select
|
|
70
|
+
if (isRelationSelectOption) {
|
|
71
|
+
const select = selectFields.reduce((acc, item) => {
|
|
72
|
+
if (!acc[item]) {
|
|
73
|
+
acc[item] = true;
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
return select;
|
|
76
78
|
}
|
|
77
|
-
return
|
|
79
|
+
return { $master: true };
|
|
78
80
|
};
|
|
79
81
|
/**
|
|
80
82
|
* 获取tcb查询条件
|
|
@@ -122,7 +124,8 @@ export const getModelParams = (props) => {
|
|
|
122
124
|
}
|
|
123
125
|
return params;
|
|
124
126
|
};
|
|
125
|
-
|
|
127
|
+
// relationalTableName,后端暂不支持按照关联关系表的字段排序(前端预埋参数)
|
|
128
|
+
export const transformSorter = (sorter = []) => {
|
|
126
129
|
var _a;
|
|
127
130
|
return (_a = sorter === null || sorter === void 0 ? void 0 : sorter.filter((n) => (n.orderBy && n.orderType) || n.relationalTableName)) === null || _a === void 0 ? void 0 : _a.map((i) => {
|
|
128
131
|
var _a, _b;
|
package/dist/web/utils/tcb.d.ts
CHANGED
|
@@ -42,3 +42,7 @@ export declare const appCloudGetWedaUserId: () => any;
|
|
|
42
42
|
export declare const appCloudIsInWedaIde: () => any;
|
|
43
43
|
export declare const appCloudGetWedaRelatedRoles: () => any;
|
|
44
44
|
export declare function appCloudShowWedaToast(params: any): any;
|
|
45
|
+
/**
|
|
46
|
+
* 设置默认上传路径
|
|
47
|
+
*/
|
|
48
|
+
export declare const getDefaultUploadPath: (uploadPath: any) => any;
|
package/dist/web/utils/tcb.js
CHANGED
|
@@ -2,13 +2,7 @@ import { isInIde } from './platform';
|
|
|
2
2
|
import { deepClone } from './tool';
|
|
3
3
|
import { errorHandler } from './error';
|
|
4
4
|
// 默认使用swr的methodName
|
|
5
|
-
const SWR_METHOD_DEFAULT = [
|
|
6
|
-
'wedaGetItem',
|
|
7
|
-
'wedaGetRecords',
|
|
8
|
-
'wedaGetItemV2',
|
|
9
|
-
'wedaGetRecordsV2',
|
|
10
|
-
'getApiKey',
|
|
11
|
-
];
|
|
5
|
+
const SWR_METHOD_DEFAULT = ['wedaGetItem', 'wedaGetRecords', 'wedaGetItemV2', 'wedaGetRecordsV2', 'getApiKey'];
|
|
12
6
|
// 默认使用swr的action
|
|
13
7
|
const SWR_ACTION_DEFAULT = [
|
|
14
8
|
'DescribeAppCustomNav',
|
|
@@ -145,8 +139,7 @@ export const getIsExitApi = async (params) => {
|
|
|
145
139
|
}
|
|
146
140
|
catch (error) {
|
|
147
141
|
const message = (_b = (_a = error === null || error === void 0 ? void 0 : error.original) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.message;
|
|
148
|
-
const status = (message === null || message === void 0 ? void 0 : message.indexOf('Action不存在')) != -1 ||
|
|
149
|
-
(message === null || message === void 0 ? void 0 : message.indexOf('接口不存在')) != -1;
|
|
142
|
+
const status = (message === null || message === void 0 ? void 0 : message.indexOf('Action不存在')) != -1 || (message === null || message === void 0 ? void 0 : message.indexOf('接口不存在')) != -1;
|
|
150
143
|
errorHandler({ code: 'GetIsExitApi', error });
|
|
151
144
|
return !status;
|
|
152
145
|
}
|
|
@@ -191,3 +184,12 @@ export function appCloudShowWedaToast(params) {
|
|
|
191
184
|
var _a;
|
|
192
185
|
return (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.showToast(params);
|
|
193
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* 设置默认上传路径
|
|
189
|
+
*/
|
|
190
|
+
export const getDefaultUploadPath = (uploadPath) => {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
const appName = ((_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.name) || ((_b = window === null || window === void 0 ? void 0 : window.app) === null || _b === void 0 ? void 0 : _b.id);
|
|
193
|
+
const _uploadPath = appName ? `${uploadPath}/${appName}` : uploadPath;
|
|
194
|
+
return _uploadPath;
|
|
195
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"description": "腾讯云微搭低代码组件库模板",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@antv/g6": "^4.8.5",
|
|
88
|
-
"@cloudbase/weda-client": "^1.1.
|
|
88
|
+
"@cloudbase/weda-client": "^1.1.24",
|
|
89
89
|
"@codemirror/autocomplete": "^6.16.0",
|
|
90
90
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
91
91
|
"@codemirror/lang-json": "^6.0.1",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"@babel/preset-env": "^7.22.15",
|
|
148
148
|
"@babel/preset-react": "^7.22.15",
|
|
149
149
|
"@babel/preset-typescript": "^7.22.15",
|
|
150
|
-
"@cloudbase/cals": "^1.2.
|
|
150
|
+
"@cloudbase/cals": "^1.2.10",
|
|
151
151
|
"@cloudbase/lowcode-cli": "^0.22.1",
|
|
152
152
|
"@cloudbase/weda-cloud-sdk": "^1.0.97",
|
|
153
153
|
"@commitlint/cli": "^16.0.2",
|