@cloudbase/weda-ui 3.26.0 → 3.26.1
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-drawer.d.ts +2 -2
- package/dist/configs/components/wd-drawer.js +4 -4
- package/dist/configs/index.d.ts +4 -4
- package/dist/configs/type-utils/type-form.js +1 -1
- package/dist/style/weda-ui.min.css +3 -3
- package/dist/web/components/wd-drawer/wd-drawer.js +0 -24
- package/dist/web/components/wd-select/hooks/useChooseList.js +0 -1
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +28 -8
- package/dist/web/components/wd-table/components/FieldRender/Form/Enum.js +3 -2
- package/package.json +1 -1
|
@@ -12,7 +12,6 @@ import { WD_DRAWER_PLACEMENT } from '../../../enum';
|
|
|
12
12
|
const DEFAULT_DURATION = 300;
|
|
13
13
|
const DEFAULT_Z_INDEX = 1000;
|
|
14
14
|
const MASK_Z_INDEX_OFFSET = 1;
|
|
15
|
-
const DEFAULT_DELAY = 100;
|
|
16
15
|
// 默认样式对象
|
|
17
16
|
const DEFAULT_STYLE = {};
|
|
18
17
|
const WdDrawer = forwardRef(function WdDrawer(props, ref) {
|
|
@@ -60,29 +59,6 @@ const WdDrawer = forwardRef(function WdDrawer(props, ref) {
|
|
|
60
59
|
document.removeEventListener('keydown', handleKeyDown);
|
|
61
60
|
};
|
|
62
61
|
}, [close, escClosable, platform, visible]);
|
|
63
|
-
// 点击外部关闭
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
const handleDocumentClick = (e) => {
|
|
66
|
-
// 只有在允许点击关闭时才处理
|
|
67
|
-
if (maskClosable && visible && drawerRef.current) {
|
|
68
|
-
// 检查点击目标是否在抽屉内部
|
|
69
|
-
if (!drawerRef.current.contains(e.target)) {
|
|
70
|
-
close();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
if (visible && maskClosable) {
|
|
75
|
-
// 延迟添加事件监听器,避免立即触发
|
|
76
|
-
// eslint-disable-next-line rulesdir/no-timer
|
|
77
|
-
const timer = setTimeout(() => {
|
|
78
|
-
document.addEventListener('click', handleDocumentClick);
|
|
79
|
-
}, DEFAULT_DELAY);
|
|
80
|
-
return () => {
|
|
81
|
-
clearTimeout(timer);
|
|
82
|
-
document.removeEventListener('click', handleDocumentClick);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}, [close, maskClosable, visible]);
|
|
86
62
|
// 遮罩层点击关闭
|
|
87
63
|
const handleMaskClick = (e) => {
|
|
88
64
|
if (maskClosable && e.target === maskRef.current) {
|
|
@@ -6,8 +6,9 @@ import { LoadingTip } from 'tea-component';
|
|
|
6
6
|
import { SelectUI as Select } from '../select/selectUI';
|
|
7
7
|
import { WdIcon } from '../../wd-icon';
|
|
8
8
|
import { getTableColumns } from '../../wd-table/components/FieldRender';
|
|
9
|
+
import { EnumView } from '../../wd-table/components/FieldRender/Form/Enum';
|
|
9
10
|
import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
|
|
10
|
-
import { usePlatform } from '../../../utils/platform';
|
|
11
|
+
import { usePlatform, textToString } from '../../../utils/platform';
|
|
11
12
|
import { DataSource } from '../../../utils/datasource';
|
|
12
13
|
import { useSyncValue } from '../../../utils/hooks/useSyncValue';
|
|
13
14
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
@@ -15,7 +16,14 @@ import { deepClone } from '../../../utils/tool';
|
|
|
15
16
|
import { useChooseList } from '../hooks/useChooseList';
|
|
16
17
|
import { getDefaultQuery } from './queryParams';
|
|
17
18
|
import { EnumHoc } from '../../../utils/hooks/EnumHoc';
|
|
18
|
-
const
|
|
19
|
+
const OptionTextTitle = ({ field, values }) => {
|
|
20
|
+
if (field.format === 'x-enum') {
|
|
21
|
+
return _jsx(EnumView, { field: field, values: values, showRelationWithTag: false });
|
|
22
|
+
}
|
|
23
|
+
return _jsx("span", { title: textToString(values), children: textToString(values) });
|
|
24
|
+
};
|
|
25
|
+
const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, showLabelField, }) => {
|
|
26
|
+
var _a;
|
|
19
27
|
const platform = usePlatform();
|
|
20
28
|
const columns = useMemo(() => {
|
|
21
29
|
return getTableColumns({
|
|
@@ -44,7 +52,7 @@ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelati
|
|
|
44
52
|
option,
|
|
45
53
|
});
|
|
46
54
|
}
|
|
47
|
-
}, 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)
|
|
55
|
+
}, 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: _jsx(OptionTextTitle, { field: showLabelField, values: (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : option === null || option === void 0 ? void 0 : option.value }) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
|
|
48
56
|
onRelationOptionJump({ item: option });
|
|
49
57
|
}, 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
58
|
};
|
|
@@ -99,12 +107,23 @@ export function RelationSelect(props) {
|
|
|
99
107
|
const [isLoading, setIsLoading] = useSyncValue(isValidating, isObjectEqual);
|
|
100
108
|
// 下拉选项数据
|
|
101
109
|
const customOptions = useMemo(() => {
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
const showLabelField = authFields.find((i) => i.name === showLabel);
|
|
111
|
+
if (isRelationSelectOption) {
|
|
112
|
+
return options === null || options === void 0 ? void 0 : options.map((i) => ({
|
|
104
113
|
...i,
|
|
105
|
-
text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump })),
|
|
106
|
-
}))
|
|
107
|
-
|
|
114
|
+
text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump, showLabelField: showLabelField })),
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
else if ((showLabelField === null || showLabelField === void 0 ? void 0 : showLabelField.format) === 'x-enum') {
|
|
118
|
+
return options === null || options === void 0 ? void 0 : options.map((i) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return ({
|
|
121
|
+
...i,
|
|
122
|
+
text: _jsx(OptionTextTitle, { field: showLabelField, values: (_a = i.label) !== null && _a !== void 0 ? _a : i.value }),
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return options;
|
|
108
127
|
}, [
|
|
109
128
|
authFields,
|
|
110
129
|
enableRelationOptionJump,
|
|
@@ -114,6 +133,7 @@ export function RelationSelect(props) {
|
|
|
114
133
|
onRelationOptionJump,
|
|
115
134
|
options,
|
|
116
135
|
selectFields,
|
|
136
|
+
showLabel,
|
|
117
137
|
]);
|
|
118
138
|
const searchOptionListWithWhere = useDebouncedCallback((filter = defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter) => {
|
|
119
139
|
empty();
|
|
@@ -37,8 +37,9 @@ export const formatEnum = (value, field, enumOptions, showRelationWithTag = true
|
|
|
37
37
|
const optionName = field['x-option-name'];
|
|
38
38
|
const isMulti = field['x-multi-select'];
|
|
39
39
|
const options = (enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[optionName]) || [];
|
|
40
|
+
const optionsMap = new Map(options.map((item) => [item.value, item.text]));
|
|
40
41
|
let val = '-';
|
|
41
|
-
const getTextByValue = (value) =>
|
|
42
|
+
const getTextByValue = (value) => optionsMap.get(value) || value;
|
|
42
43
|
if (isMulti) {
|
|
43
44
|
val = (_a = []
|
|
44
45
|
.concat(value)
|
|
@@ -48,7 +49,7 @@ export const formatEnum = (value, field, enumOptions, showRelationWithTag = true
|
|
|
48
49
|
val = getTextByValue(value);
|
|
49
50
|
}
|
|
50
51
|
if (!showRelationWithTag) {
|
|
51
|
-
return _jsx("span", { title: val, children: val });
|
|
52
|
+
return (_jsx("span", { style: { display: 'inline-block' }, title: val, children: val }));
|
|
52
53
|
}
|
|
53
54
|
return (_jsx(WdTag, { range: val === null || val === void 0 ? void 0 : val.split(',').map((i) => ({
|
|
54
55
|
label: i,
|