@giteeteam/apps-team-components 1.0.36 → 1.0.37-alpha.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.
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { memo, useMemo } from 'react';
|
|
3
3
|
import EmptyField from '../../common/EmptyField';
|
|
4
4
|
import SimpleOverflowToolTip from '../../common/overflow-tooltip/SimpleOverflowToolTip';
|
|
5
5
|
import { handleValue } from './BaseField';
|
|
6
|
+
const getFormattedLabel = ({ label, style = {}, }) => {
|
|
7
|
+
return _jsx("span", { style: { color: style === null || style === void 0 ? void 0 : style.color, background: style === null || style === void 0 ? void 0 : style.background }, children: label });
|
|
8
|
+
};
|
|
6
9
|
const DropdownReadView = memo(props => {
|
|
7
10
|
const { value, options, readonly: propsReadonly, userData } = props;
|
|
8
11
|
const readonly = useMemo(() => {
|
|
@@ -13,7 +16,7 @@ const DropdownReadView = memo(props => {
|
|
|
13
16
|
return propsReadonly;
|
|
14
17
|
}
|
|
15
18
|
}, [propsReadonly, userData]);
|
|
16
|
-
const
|
|
19
|
+
const showValueTitle = useMemo(() => {
|
|
17
20
|
var _a;
|
|
18
21
|
if (!(value === null || value === void 0 ? void 0 : value.length))
|
|
19
22
|
return '';
|
|
@@ -28,7 +31,26 @@ const DropdownReadView = memo(props => {
|
|
|
28
31
|
.join(',');
|
|
29
32
|
return result;
|
|
30
33
|
}, [options, value]);
|
|
31
|
-
|
|
34
|
+
const showValue = useMemo(() => {
|
|
35
|
+
var _a;
|
|
36
|
+
if (!(value === null || value === void 0 ? void 0 : value.length))
|
|
37
|
+
return '';
|
|
38
|
+
if ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.label) {
|
|
39
|
+
return value.map(item => item.label).join(',');
|
|
40
|
+
}
|
|
41
|
+
if (!(options === null || options === void 0 ? void 0 : options.length))
|
|
42
|
+
return '';
|
|
43
|
+
const optionsMap = {};
|
|
44
|
+
options === null || options === void 0 ? void 0 : options.forEach(item => {
|
|
45
|
+
optionsMap[item.label] = item;
|
|
46
|
+
});
|
|
47
|
+
const result = value
|
|
48
|
+
.map(item => { var _a; return (item === null || item === void 0 ? void 0 : item.label) || ((_a = options.find(opt => opt.value === handleValue(item))) === null || _a === void 0 ? void 0 : _a.label); })
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.map((item, index) => index === value.length - 1 ? getFormattedLabel(optionsMap[item]) : _jsxs(_Fragment, { children: [getFormattedLabel(optionsMap[item]), ","] }));
|
|
51
|
+
return result;
|
|
52
|
+
}, [options, value]);
|
|
53
|
+
return (_jsx(_Fragment, { children: showValue ? (_jsx(SimpleOverflowToolTip, { title: showValueTitle, children: showValue })) : (_jsx(EmptyField, { readonly: readonly })) }));
|
|
32
54
|
});
|
|
33
55
|
DropdownReadView.displayName = 'DropdownReadView';
|
|
34
56
|
export default DropdownReadView;
|