@giteeteam/apps-team-components 1.2.2 → 1.3.0-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.
- package/README.md +21 -28
- package/dist/components/common/PriceTag.js +18 -18
- package/dist/components/common/expand-component/index.d.ts +23 -0
- package/dist/components/common/expand-component/index.js +65 -0
- package/dist/components/common/expand-component/style.d.ts +2 -0
- package/dist/components/common/expand-component/style.js +8 -0
- package/dist/components/common/item-icon/ItemIcon.d.ts +8 -0
- package/dist/components/common/item-icon/ItemIcon.js +6 -0
- package/dist/components/common/overflow-tooltip/OverflowTooltip.d.ts +19 -0
- package/dist/components/common/overflow-tooltip/OverflowTooltip.js +54 -0
- package/dist/components/common/overflow-tooltip/style/index.js +13 -13
- package/dist/components/common/style/global.js +2 -2
- package/dist/components/common/style/mixin.d.ts +2 -0
- package/dist/components/common/style/mixin.js +17 -0
- package/dist/components/common/user-field/style/index.js +21 -21
- package/dist/components/common/utils.d.ts +6 -0
- package/dist/components/common/utils.js +54 -0
- package/dist/components/default-empty-icon/config.d.ts +2 -0
- package/dist/components/default-empty-icon/config.js +19 -0
- package/dist/components/default-empty-icon/index.d.ts +5 -0
- package/dist/components/default-empty-icon/index.js +23 -0
- package/dist/components/default-empty-icon/style.d.ts +11 -0
- package/dist/components/default-empty-icon/style.js +64 -0
- package/dist/components/default-empty-icon/types.d.ts +29 -0
- package/dist/components/default-empty-icon/types.js +6 -0
- package/dist/components/field-behavior/fields/type.js +1 -1
- package/dist/components/fields/base-component/types.d.ts +1 -0
- package/dist/components/fields/base-component/utils.d.ts +2 -0
- package/dist/components/fields/base-component/utils.js +9 -0
- package/dist/components/fields/bind-workspace/hooks.js +3 -3
- package/dist/components/fields/bind-workspace/style/index.js +3 -3
- package/dist/components/fields/dropdown/BaseField.d.ts +24 -2
- package/dist/components/fields/dropdown/BaseField.js +562 -1
- package/dist/components/fields/dropdown/Cell.d.ts +4 -0
- package/dist/components/fields/dropdown/Cell.js +6 -0
- package/dist/components/fields/dropdown/ReadView.js +1 -1
- package/dist/components/fields/dropdown/data.d.ts +9 -0
- package/dist/components/fields/dropdown/data.js +26 -0
- package/dist/components/fields/dropdown/hook.d.ts +103 -0
- package/dist/components/fields/dropdown/hook.js +152 -0
- package/dist/components/fields/dropdown/style.d.ts +16 -0
- package/dist/components/fields/dropdown/style.js +90 -0
- package/dist/components/fields/hooks/useViewClass.d.ts +11 -0
- package/dist/components/fields/hooks/useViewClass.js +18 -0
- package/dist/components/fields/hyper-link/style/index.js +14 -14
- package/dist/components/fields/item-type/ItemTypeIcon.d.ts +9 -0
- package/dist/components/fields/item-type/ItemTypeIcon.js +33 -0
- package/dist/components/fields/item-type/style/index.d.ts +1 -0
- package/dist/components/fields/item-type/style/index.js +6 -0
- package/dist/components/fields/key/ReadView.js +2 -2
- package/dist/components/fields/long-text/style/index.js +5 -5
- package/dist/components/fields/priority/ReadView.js +1 -1
- package/dist/components/fields/priority/style/index.js +50 -50
- package/dist/components/fields/status/style/index.js +323 -323
- package/dist/components/fields/tag/style/index.js +5 -5
- package/dist/components/fields/team/style/index.js +2 -2
- package/dist/components/fields/user/style/index.js +8 -8
- package/dist/components/fields/user-group/ReadView.js +1 -1
- package/dist/components/filters/filter-search/utils.d.ts +4 -0
- package/dist/components/filters/filter-search/utils.js +28 -0
- package/dist/components/table-components/EditTableCell.d.ts +1 -0
- package/dist/components/table-components/EditTableCell.js +2 -1
- package/dist/components/table-components/index.js +4 -4
- package/dist/components/table-components/style/index.js +5 -5
- package/dist/components/table-components/utils.js +2 -0
- package/dist/icons/SyncIconFont.d.ts +6 -0
- package/dist/icons/SyncIconFont.js +15 -0
- package/dist/icons/createFromIconFontClass.d.ts +4 -0
- package/dist/icons/createFromIconFontClass.js +33 -0
- package/dist/icons/empty-icon/data-empty.png +0 -0
- package/dist/icons/empty-icon/forbidden.png +0 -0
- package/dist/icons/empty-icon/index.d.ts +1 -0
- package/dist/icons/empty-icon/index.js +8 -0
- package/dist/icons/empty-icon/large-item@2x.png +0 -0
- package/dist/icons/empty-icon/large-workspace@2x.png +0 -0
- package/dist/icons/empty-icon/load-error.png +0 -0
- package/dist/icons/empty-icon/not-found.png +0 -0
- package/dist/icons/empty-icon/small-default@2x.png +0 -0
- package/dist/icons/empty-icon/workspace-empty.svg +127 -0
- package/dist/icons/index.d.ts +58 -1
- package/dist/icons/index.js +294 -0
- package/dist/icons/style/index.d.ts +2 -0
- package/dist/icons/style/index.js +23 -0
- package/dist/icons/svg/DottedCircle.svg +7 -7
- package/dist/icons/svg/HollowCircle.svg +6 -6
- package/dist/icons/svg/Workflow.svg +12 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/app/utils.d.ts +3 -0
- package/dist/lib/app/utils.js +16 -0
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.js +45 -0
- package/dist/lib/constants/code.d.ts +4 -0
- package/dist/lib/constants/code.js +4 -0
- package/dist/lib/constants/field.d.ts +1 -0
- package/dist/lib/constants/field.js +2 -0
- package/dist/lib/contexts/index.js +2 -2
- package/dist/lib/contexts/teamConfig.d.ts +3 -0
- package/dist/lib/contexts/teamConfig.js +19 -4
- package/dist/lib/error/index.d.ts +2 -0
- package/dist/lib/error/index.js +2 -0
- package/dist/lib/error/log.d.ts +10 -0
- package/dist/lib/error/log.js +25 -0
- package/dist/lib/error/utils.d.ts +14 -0
- package/dist/lib/error/utils.js +50 -0
- package/dist/lib/error/withServerError.d.ts +1 -0
- package/dist/lib/error/withServerError.js +1 -0
- package/dist/lib/fetch.d.ts +45 -0
- package/dist/lib/fetch.js +301 -0
- package/dist/lib/global.d.ts +18 -0
- package/dist/lib/global.js +18 -0
- package/dist/lib/i18n.d.ts +1 -0
- package/dist/lib/i18n.js +1 -0
- package/dist/lib/icons/utils.d.ts +23 -0
- package/dist/lib/icons/utils.js +59 -0
- package/dist/lib/path.d.ts +5 -0
- package/dist/lib/path.js +47 -0
- package/dist/lib/router.d.ts +23 -0
- package/dist/lib/router.js +20 -0
- package/dist/lib/storage.d.ts +10 -0
- package/dist/lib/storage.js +62 -0
- package/dist/lib/swr/throttleWithCache.d.ts +17 -0
- package/dist/lib/swr/throttleWithCache.js +108 -0
- package/dist/lib/throttleFetch.d.ts +2 -0
- package/dist/lib/throttleFetch.js +66 -0
- package/dist/lib/useConfig.d.ts +8 -0
- package/dist/lib/useConfig.js +28 -0
- package/dist/locales/index.d.ts +45 -0
- package/dist/locales/index.js +45 -0
- package/dist/public/icons/BulbIcon.svg +1 -0
- package/dist/public/icons/Cloud.svg +1 -0
- package/dist/public/icons/ConsultIcon.svg +1 -0
- package/dist/public/icons/Demo.svg +1 -0
- package/dist/public/icons/ErrorTemplate.svg +1 -0
- package/dist/public/icons/Fail.svg +1 -0
- package/dist/public/icons/Flag.svg +1 -0
- package/dist/public/icons/GiteeIcon.svg +1 -0
- package/dist/public/icons/IntelligenceGradient.svg +1 -0
- package/dist/public/icons/Issue_Approval.svg +1 -0
- package/dist/public/icons/Issue_Bug.svg +1 -0
- package/dist/public/icons/Issue_Demand.svg +1 -0
- package/dist/public/icons/Issue_Doc.svg +1 -0
- package/dist/public/icons/Issue_Idea.svg +1 -0
- package/dist/public/icons/Issue_List.svg +1 -0
- package/dist/public/icons/Issue_Plan.svg +1 -0
- package/dist/public/icons/Issue_Product.svg +1 -0
- package/dist/public/icons/Issue_Risk.svg +1 -0
- package/dist/public/icons/Issue_Story.svg +1 -0
- package/dist/public/icons/Issue_Subtask.svg +1 -0
- package/dist/public/icons/Issue_Task.svg +1 -0
- package/dist/public/icons/Issue_Test.svg +1 -0
- package/dist/public/icons/Issue_TestExcution.svg +1 -0
- package/dist/public/icons/Issue_TestPlan.svg +1 -0
- package/dist/public/icons/Issue_Time.svg +1 -0
- package/dist/public/icons/Issue_develop.svg +1 -0
- package/dist/public/icons/KanbanCover.svg +7 -0
- package/dist/public/icons/ListCover.svg +118 -0
- package/dist/public/icons/ManHour.svg +1 -0
- package/dist/public/icons/MobileIcon.svg +1 -0
- package/dist/public/icons/NoItemType.svg +10 -0
- package/dist/public/icons/ProductIcon.svg +1 -0
- package/dist/public/icons/RedFlagIcon.svg +1 -0
- package/dist/public/icons/Safe.svg +1 -0
- package/dist/public/icons/StarIcon.svg +61 -0
- package/dist/public/icons/StructureCover.svg +1 -0
- package/dist/public/icons/Success.svg +1 -0
- package/dist/public/icons/TeamIcon.svg +1 -0
- package/dist/public/icons/WebIcon.svg +1 -0
- package/dist/public/icons/iconfont.svg +467 -0
- package/dist/public/icons/iconfont.ttf +0 -0
- package/dist/public/icons/iconfont.woff +0 -0
- package/dist/public/icons/iconfont.woff2 +0 -0
- package/dist/public/icons/iconfont_multiple_color.js +1 -0
- package/dist/public/icons/iconfont_single_color.css +912 -0
- package/dist/public/icons/iconfont_single_color.js +1 -0
- package/dist/public/icons/loginBg.svg +1 -0
- package/dist/public/mockServiceWorker.js +284 -0
- package/dist/style/common.d.ts +1 -0
- package/dist/style/common.js +9 -0
- package/dist/style/global.d.ts +1 -0
- package/dist/style/global.js +8 -0
- package/package.json +105 -69
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const getFieldWidthStyle = (labelWidth, labelAlign, hiddenLabel, apply) => {
|
|
2
|
+
if (hiddenLabel) {
|
|
3
|
+
labelWidth = 0;
|
|
4
|
+
}
|
|
5
|
+
if (apply !== 'cell' && labelAlign !== 'top') {
|
|
6
|
+
return { width: `calc(100% - ${labelWidth}px)` };
|
|
7
|
+
}
|
|
8
|
+
return { width: '100%' };
|
|
9
|
+
};
|
|
@@ -2,14 +2,14 @@ import useTeamConfig from '../../../lib/hooks/useTeamConfig';
|
|
|
2
2
|
import useTenant from '../../../lib/hooks/useTenant';
|
|
3
3
|
import isInOne from '../../../lib/isInOne';
|
|
4
4
|
export const useToWorkspacePage = () => {
|
|
5
|
-
const {
|
|
6
|
-
const inOne = isInOne(
|
|
5
|
+
const { publicRuntimeConfig, isMicroApp } = useTeamConfig();
|
|
6
|
+
const inOne = isInOne(publicRuntimeConfig.gateway, isMicroApp);
|
|
7
7
|
const tenant = useTenant();
|
|
8
8
|
return {
|
|
9
9
|
toWorkspacePage: (workspaceKey) => {
|
|
10
10
|
const url = inOne
|
|
11
11
|
? `/${tenant}/${workspaceKey}`
|
|
12
|
-
: `${
|
|
12
|
+
: `${publicRuntimeConfig.basePath}/${tenant}/workspaces/${workspaceKey}?from=item`;
|
|
13
13
|
window.open(`${url}?from=item`, '_blank');
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const pointerStyle = `
|
|
2
|
-
color: #0c62ff;
|
|
3
|
-
cursor: pointer;
|
|
1
|
+
export const pointerStyle = `
|
|
2
|
+
color: #0c62ff;
|
|
3
|
+
cursor: pointer;
|
|
4
4
|
`;
|
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ItemType, PointerObject } from 'lib/types/models';
|
|
3
|
+
import { BaseDropdownProps } from './hook';
|
|
2
4
|
export interface selectValue {
|
|
3
5
|
label: React.ReactNode;
|
|
4
6
|
value: string | number;
|
|
5
|
-
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
enable?: boolean;
|
|
9
|
+
icon?: string;
|
|
10
|
+
itemType?: PointerObject | ItemType;
|
|
11
|
+
archived?: boolean;
|
|
12
|
+
name?: string;
|
|
13
|
+
key?: string;
|
|
14
|
+
values?: {
|
|
15
|
+
[propName: string]: any;
|
|
16
|
+
};
|
|
6
17
|
}
|
|
18
|
+
export declare const isNilFilter: <T>(value: T[]) => T[];
|
|
7
19
|
export declare const handleValue: (value: selectValue | string | number) => string | number;
|
|
20
|
+
type GetFormattedLabelParams = {
|
|
21
|
+
label: string;
|
|
22
|
+
style?: {
|
|
23
|
+
color?: string;
|
|
24
|
+
background?: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const getFormattedLabel: ({ label, style }?: GetFormattedLabelParams) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
28
|
+
declare const Dropdown: React.FC<BaseDropdownProps>;
|
|
29
|
+
export default Dropdown;
|
|
@@ -1,4 +1,565 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Overlay } from 'react-overlays';
|
|
4
|
+
import { DownOutlined } from '@ant-design/icons';
|
|
5
|
+
import { ClassNames } from '@emotion/react';
|
|
6
|
+
import { Checkbox, Col, Divider, Select as AntSelect, Spin } from 'antd';
|
|
7
|
+
import debug from 'debug';
|
|
8
|
+
import { isNil, isObject, isPlainObject, noop, xorWith } from 'lodash-es';
|
|
9
|
+
import { emptyIconWrapper } from 'style/global';
|
|
10
|
+
import useSWR from 'swr';
|
|
11
|
+
import EmptyField from 'components/common/EmptyField';
|
|
12
|
+
import Expand, { EXPAND_TYPE_ENUM } from 'components/common/expand-component';
|
|
13
|
+
import ItemIcon from 'components/common/item-icon/ItemIcon';
|
|
14
|
+
import BaseOverflowTooltip from 'components/common/overflow-tooltip/BaseOverflowTooltip';
|
|
15
|
+
import OverflowTooltip from 'components/common/overflow-tooltip/OverflowTooltip';
|
|
16
|
+
import { defaultFilterOptions, getPopupContainerFun } from 'components/common/utils';
|
|
17
|
+
import EmptyIcon from 'components/default-empty-icon';
|
|
18
|
+
import { getFieldWidthStyle } from 'components/fields/base-component/utils';
|
|
19
|
+
import { getRealValueByIqlTo } from 'components/filters/filter-search/utils';
|
|
20
|
+
import { REMOTE_DATA_QUOTE_FIELD_TYPE } from 'lib/constants/field';
|
|
21
|
+
import { BASE_FIELD_WIDTH, CURRENT_WORKSPACE, FIELD_CONTAINERS_PAGE, FIELD_TYPE_KEY_MAPPINGS } from 'lib/global';
|
|
22
|
+
import useAntdConfig from 'lib/hooks/useAntdConfig';
|
|
23
|
+
import useI18n from 'lib/hooks/useI18n';
|
|
24
|
+
import { API_KEY } from 'lib/swr/constants';
|
|
25
|
+
import useViewClass from '../hooks/useViewClass';
|
|
26
|
+
import { EMPTY_OPTIONS, useCommonProps } from './hook';
|
|
27
|
+
import { disabledClass, displayWrapClass, dropdownSelectDisabled, dropdownSelectOptionClass, dropdownSelectStyle, dropdownStyle, hiddenHoverClass, hoverIconClass, onlyWorkspaceDividerStyle, onlyWorkspaceStyle, optionDisplayWrapClass, valueOptionClass, valueOptionContentClass, valueOptionIconClass, valueOptionLabelClass, workspaceClass, } from './style';
|
|
28
|
+
const loggers = debug('dropdown:BaseField');
|
|
29
|
+
export const isNilFilter = function (value) {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = value === null || value === void 0 ? void 0 : value.filter) === null || _a === void 0 ? void 0 : _a.call(value, val => !isNil(val));
|
|
32
|
+
};
|
|
2
33
|
export const handleValue = function (value) {
|
|
3
34
|
return isObject(value) ? value === null || value === void 0 ? void 0 : value.value : value;
|
|
4
35
|
};
|
|
36
|
+
export const getFormattedLabel = ({ label, style = {} } = {}) => {
|
|
37
|
+
return _jsx("span", { style: { borderRadius: 2, color: style === null || style === void 0 ? void 0 : style.color, background: style === null || style === void 0 ? void 0 : style.background }, children: label });
|
|
38
|
+
};
|
|
39
|
+
const Dropdown = props => {
|
|
40
|
+
const { onSelect = noop, onBlur, onChange = noop, labelWidth = BASE_FIELD_WIDTH, labelAlign, readonly: propsReadonly = false, options: _propsOptions = EMPTY_OPTIONS, editMode = false, apply, mode, hiddenLabel, allowClear = true, useChange = false, objectId, getPopupContainer, dataQuoteInit, userData, workspace, valueDisplayWrap, optionDisplayWrap, onOptionsChange, page, disabledSwr, onlyValue, screenMode, displayValueHidden = false, disabledLineThrough = false, displayWorkspace = false, isShowOnlyWorkspace = false, fieldTypeKey, iqlKey = 'value', fetchOnFocus, isCascaded, clickFetch, iqlToNeedMore = false, ...defaultProps } = props;
|
|
41
|
+
const { t } = useI18n();
|
|
42
|
+
const { antPrefix } = useAntdConfig();
|
|
43
|
+
const { propsValue, onSearchChange: handleSearch, options, onlyWorkspace, setOnlyWorkspace: onChangeCurrent, loading, _setValue, setLoading, setOptions, propsOptions, cachedOptionsRef, needFetchDataSource, fetchOptions, fetchValues, canAsyncFetchOption, cacheSelectOptions, value, } = useCommonProps(props);
|
|
44
|
+
const isClickFetch = useMemo(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
return page && page !== FIELD_CONTAINERS_PAGE.FILTER && clickFetch && ((_a = propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) === null || _a === void 0 ? void 0 : _a.label);
|
|
47
|
+
}, [clickFetch, page, propsValue]);
|
|
48
|
+
const [editing, setEditing] = useState(false);
|
|
49
|
+
const [readonly, setReadonly] = useState(false);
|
|
50
|
+
const [open, setOpen] = useState(false);
|
|
51
|
+
const valueRef = useRef([]);
|
|
52
|
+
const containerRef = useRef(null);
|
|
53
|
+
const targetRef = useRef(null);
|
|
54
|
+
const [isClicked, setClicked] = useState(false);
|
|
55
|
+
const optionLoadedRef = useRef(false);
|
|
56
|
+
const loadMoreRef = useRef(false);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (needFetchDataSource) {
|
|
59
|
+
if (screenMode !== 'create' && screenMode) {
|
|
60
|
+
setReadonly((userData === null || userData === void 0 ? void 0 : userData.readonly) || propsReadonly);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
setReadonly(propsReadonly);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setReadonly(propsReadonly);
|
|
68
|
+
}
|
|
69
|
+
}, [propsReadonly, userData === null || userData === void 0 ? void 0 : userData.readonly, needFetchDataSource, screenMode]);
|
|
70
|
+
const { isView, viewClassNames } = useViewClass({ screenMode, readonly, editing });
|
|
71
|
+
const shouldSWRFetch = useMemo(() => {
|
|
72
|
+
return apply === 'cell';
|
|
73
|
+
}, [apply]);
|
|
74
|
+
const hasClickFetch = useMemo(() => { var _a; return isClickFetch && !isClicked && ((propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) ? (_a = propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) === null || _a === void 0 ? void 0 : _a.label : true); }, [isClickFetch, isClicked, propsValue]);
|
|
75
|
+
const noClickEditing = useMemo(() => isClickFetch && !editing && !(options === null || options === void 0 ? void 0 : options.length), [editing, isClickFetch, options === null || options === void 0 ? void 0 : options.length]);
|
|
76
|
+
const finallyOptions = useMemo(() => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
return typeof dataQuoteInit === 'function'
|
|
79
|
+
? dataQuoteInit(((_a = propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) === null || _a === void 0 ? void 0 : _a.label) && !(options === null || options === void 0 ? void 0 : options.length) ? propsValue : options, value, userData === null || userData === void 0 ? void 0 : userData.display)
|
|
80
|
+
: ((_b = propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) === null || _b === void 0 ? void 0 : _b.label)
|
|
81
|
+
? propsValue
|
|
82
|
+
: options;
|
|
83
|
+
}, [dataQuoteInit, options, propsValue, userData === null || userData === void 0 ? void 0 : userData.display, value]);
|
|
84
|
+
const _options = useMemo(() => ((options === null || options === void 0 ? void 0 : options.length) > 0 ? options : finallyOptions) || [], [finallyOptions, options]);
|
|
85
|
+
async function fetcher() {
|
|
86
|
+
return await fetchOptions('');
|
|
87
|
+
}
|
|
88
|
+
const { data = [], isValidating = false } = useSWR(!disabledSwr && shouldSWRFetch && canAsyncFetchOption
|
|
89
|
+
? `${API_KEY.GET_BASE_FIELD_OPTIONS}_${objectId + workspace}_${onlyWorkspace}`
|
|
90
|
+
: null, fetcher);
|
|
91
|
+
const opts = useMemo(() => data, [data]);
|
|
92
|
+
const isMultiple = useMemo(() => mode === 'multiple', [mode]);
|
|
93
|
+
const setValue = useCallback(value => {
|
|
94
|
+
valueRef.current = value;
|
|
95
|
+
_setValue(value);
|
|
96
|
+
}, [_setValue]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (canAsyncFetchOption) {
|
|
99
|
+
cachedOptionsRef.current = [];
|
|
100
|
+
setOptions([]);
|
|
101
|
+
optionLoadedRef.current = false;
|
|
102
|
+
}
|
|
103
|
+
}, [canAsyncFetchOption, workspace, onlyWorkspace, props.itemId, props.expression, cachedOptionsRef, setOptions]);
|
|
104
|
+
const handleSelectFocus = useCallback(() => {
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
if (!readonly && !editMode) {
|
|
107
|
+
targetRef.current && targetRef.current.focus();
|
|
108
|
+
if (!open) {
|
|
109
|
+
setOpen(true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}, [editMode, readonly, open]);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!canAsyncFetchOption && Array.isArray(propsOptions)) {
|
|
116
|
+
setOptions(propsOptions || []);
|
|
117
|
+
}
|
|
118
|
+
if (!optionLoadedRef.current && canAsyncFetchOption && !isValidating) {
|
|
119
|
+
if (!shouldSWRFetch && (!fetchOnFocus || (props === null || props === void 0 ? void 0 : props.searchComponent))) {
|
|
120
|
+
if (!(isClickFetch && !isClicked)) {
|
|
121
|
+
optionLoadedRef.current = true;
|
|
122
|
+
fetchOptions('')
|
|
123
|
+
.then(options => {
|
|
124
|
+
var _a;
|
|
125
|
+
let optionsInit = options;
|
|
126
|
+
if (REMOTE_DATA_QUOTE_FIELD_TYPE.includes(fieldTypeKey)) {
|
|
127
|
+
optionsInit = (_a = cacheSelectOptions(options)) === null || _a === void 0 ? void 0 : _a.map(opt => {
|
|
128
|
+
const newOption = options.find(ele => ele.value === opt.value);
|
|
129
|
+
return {
|
|
130
|
+
...opt,
|
|
131
|
+
values: newOption === null || newOption === void 0 ? void 0 : newOption.values,
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
setOptions(cacheSelectOptions(optionsInit));
|
|
136
|
+
setLoading(false);
|
|
137
|
+
if (noClickEditing) {
|
|
138
|
+
setEditing(true);
|
|
139
|
+
handleSelectFocus();
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
.finally(() => {
|
|
143
|
+
setLoading(false);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
cacheSelectOptions(finallyOptions);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
setOptions(cacheSelectOptions(opts));
|
|
152
|
+
optionLoadedRef.current = true;
|
|
153
|
+
setLoading(false);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, [
|
|
157
|
+
cacheSelectOptions,
|
|
158
|
+
fetchOptions,
|
|
159
|
+
fetchValues,
|
|
160
|
+
canAsyncFetchOption,
|
|
161
|
+
propsOptions,
|
|
162
|
+
options,
|
|
163
|
+
opts,
|
|
164
|
+
shouldSWRFetch,
|
|
165
|
+
isValidating,
|
|
166
|
+
hasClickFetch,
|
|
167
|
+
handleSelectFocus,
|
|
168
|
+
finallyOptions,
|
|
169
|
+
noClickEditing,
|
|
170
|
+
isClickFetch,
|
|
171
|
+
isClicked,
|
|
172
|
+
fetchOnFocus,
|
|
173
|
+
props === null || props === void 0 ? void 0 : props.searchComponent,
|
|
174
|
+
fieldTypeKey,
|
|
175
|
+
setOptions,
|
|
176
|
+
setLoading,
|
|
177
|
+
]);
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
var _a;
|
|
180
|
+
loggers('loadMoreRef', loadMoreRef.current);
|
|
181
|
+
if (canAsyncFetchOption &&
|
|
182
|
+
Array.isArray(value) &&
|
|
183
|
+
optionLoadedRef.current === true &&
|
|
184
|
+
loadMoreRef.current === false &&
|
|
185
|
+
(!value.some(item => item === null || item === void 0 ? void 0 : item.iqlTo) || iqlToNeedMore)) {
|
|
186
|
+
let isNotExistedKeys = [];
|
|
187
|
+
const v = value[0];
|
|
188
|
+
if (isPlainObject(v)) {
|
|
189
|
+
isNotExistedKeys = value
|
|
190
|
+
.filter(val => val && (val === null || val === void 0 ? void 0 : val.value) !== CURRENT_WORKSPACE && cachedOptionsRef.current.every(opt => opt.value !== val.value))
|
|
191
|
+
.map(val => val === null || val === void 0 ? void 0 : val.value)
|
|
192
|
+
.filter(data => data !== undefined);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
isNotExistedKeys = value.filter(val => val && cachedOptionsRef.current.every(opt => opt.value !== val));
|
|
196
|
+
}
|
|
197
|
+
if (isNotExistedKeys.length) {
|
|
198
|
+
setLoading(true);
|
|
199
|
+
loadMoreRef.current = true;
|
|
200
|
+
fetchValues(isNotExistedKeys === null || isNotExistedKeys === void 0 ? void 0 : isNotExistedKeys.filter(Boolean), fieldTypeKey).then(appendOptions => {
|
|
201
|
+
const options = cacheSelectOptions(typeof dataQuoteInit === 'function'
|
|
202
|
+
? dataQuoteInit(appendOptions, value, userData === null || userData === void 0 ? void 0 : userData.display)
|
|
203
|
+
: appendOptions);
|
|
204
|
+
setOptions(options);
|
|
205
|
+
setLoading(false);
|
|
206
|
+
const res = valueRef.current.filter(val => {
|
|
207
|
+
const value = typeof val === 'object' ? val.value : val;
|
|
208
|
+
const index = options === null || options === void 0 ? void 0 : options.findIndex((o) => {
|
|
209
|
+
return o.value === value;
|
|
210
|
+
});
|
|
211
|
+
if (index !== -1 || value === 'NULL' || value === CURRENT_WORKSPACE) {
|
|
212
|
+
return val;
|
|
213
|
+
}
|
|
214
|
+
else if (displayValueHidden && value !== 'NULL') {
|
|
215
|
+
setOptions(cacheSelectOptions([{ value, label: t('global.haveDelete'), disabled: true }]));
|
|
216
|
+
return val;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
setValue(res || []);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (!loadMoreRef.current && value.some(item => item === null || item === void 0 ? void 0 : item.iqlTo)) {
|
|
224
|
+
loggers('canAsyncFetchOption', canAsyncFetchOption);
|
|
225
|
+
const isSet = canAsyncFetchOption ? optionLoadedRef.current : value.some(item => item === null || item === void 0 ? void 0 : item.iqlTo) && (options === null || options === void 0 ? void 0 : options.length);
|
|
226
|
+
loggers('isSet', isSet);
|
|
227
|
+
if (isSet) {
|
|
228
|
+
const _value = (_a = getRealValueByIqlTo(value, options, iqlKey)) === null || _a === void 0 ? void 0 : _a.map(item => {
|
|
229
|
+
if ((item === null || item === void 0 ? void 0 : item.value) === CURRENT_WORKSPACE) {
|
|
230
|
+
return {
|
|
231
|
+
label: `${t('pages.fields.workspace.default.currentWorkspace')}(currentWorkspace)`,
|
|
232
|
+
value: CURRENT_WORKSPACE,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return item;
|
|
236
|
+
});
|
|
237
|
+
loggers('_value', _value);
|
|
238
|
+
loadMoreRef.current = true;
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
setValue(_value);
|
|
241
|
+
}, 0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}, [
|
|
245
|
+
t,
|
|
246
|
+
value,
|
|
247
|
+
fetchValues,
|
|
248
|
+
cacheSelectOptions,
|
|
249
|
+
canAsyncFetchOption,
|
|
250
|
+
opts,
|
|
251
|
+
userData === null || userData === void 0 ? void 0 : userData.display,
|
|
252
|
+
dataQuoteInit,
|
|
253
|
+
displayValueHidden,
|
|
254
|
+
options,
|
|
255
|
+
iqlKey,
|
|
256
|
+
setValue,
|
|
257
|
+
fieldTypeKey,
|
|
258
|
+
iqlToNeedMore,
|
|
259
|
+
cachedOptionsRef,
|
|
260
|
+
setLoading,
|
|
261
|
+
setOptions,
|
|
262
|
+
]);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
onOptionsChange && onOptionsChange(options);
|
|
265
|
+
}, [onOptionsChange, options]);
|
|
266
|
+
const handleFetchOptions = useCallback(() => {
|
|
267
|
+
optionLoadedRef.current = true;
|
|
268
|
+
setLoading(true);
|
|
269
|
+
fetchOptions('').then(options => {
|
|
270
|
+
setOptions(cacheSelectOptions(options));
|
|
271
|
+
setLoading(false);
|
|
272
|
+
});
|
|
273
|
+
}, [cacheSelectOptions, fetchOptions, setLoading, setOptions]);
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
loadMoreRef.current = false;
|
|
276
|
+
const _propsValue = isClickFetch && Array.isArray(propsValue)
|
|
277
|
+
? propsValue === null || propsValue === void 0 ? void 0 : propsValue.map(item => (item === null || item === void 0 ? void 0 : item.value) || (item === null || item === void 0 ? void 0 : item.objectId) || item)
|
|
278
|
+
: propsValue;
|
|
279
|
+
setValue(Array.isArray(_propsValue) ? _propsValue : []);
|
|
280
|
+
}, [isClickFetch, propsValue, setValue]);
|
|
281
|
+
const showValue = useCallback(({ cx, css }) => {
|
|
282
|
+
var _a, _b, _c, _d;
|
|
283
|
+
let showValue = null;
|
|
284
|
+
const _options = isCascaded ? _propsOptions : noClickEditing ? finallyOptions : options;
|
|
285
|
+
const _optionsMap = {};
|
|
286
|
+
if (Array.isArray(_options)) {
|
|
287
|
+
_options.forEach(item => {
|
|
288
|
+
_optionsMap[item.label] = item;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (isMultiple) {
|
|
292
|
+
if ((Array.isArray(_options) && _options.length >= 1 && value && Array.isArray(value) && value.length) ||
|
|
293
|
+
(noClickEditing && Array.isArray(finallyOptions) && finallyOptions.length > 0)) {
|
|
294
|
+
const valueArr = value
|
|
295
|
+
.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); })
|
|
296
|
+
.filter(Boolean);
|
|
297
|
+
if (!(valueArr === null || valueArr === void 0 ? void 0 : valueArr.length))
|
|
298
|
+
return null;
|
|
299
|
+
showValue = valueArr.map((item, index) => {
|
|
300
|
+
const content = _optionsMap[item] ? getFormattedLabel(_optionsMap[item]) : item;
|
|
301
|
+
return index === value.length - 1 ? content : _jsxs(_Fragment, { children: [content, ","] });
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
if ((Array.isArray(_options) && _options.length >= 1 && value && Array.isArray(value) && value.length) ||
|
|
307
|
+
(noClickEditing && Array.isArray(finallyOptions) && finallyOptions.length > 0)) {
|
|
308
|
+
const val = value === null || value === void 0 ? void 0 : value[0];
|
|
309
|
+
const opt = _options.filter(item => item.value === handleValue(val));
|
|
310
|
+
const label = ((_a = opt[0]) === null || _a === void 0 ? void 0 : _a.label) || handleValue(val);
|
|
311
|
+
if (opt.length >= 1) {
|
|
312
|
+
showValue = (_jsx("span", { className: cx({ [css(dropdownSelectDisabled)]: ((_b = opt[0]) === null || _b === void 0 ? void 0 : _b.disabled) || !opt.length }), children: ((_c = opt[0]) === null || _c === void 0 ? void 0 : _c.icon) ? (_jsx(ItemIcon, { icon: (_d = opt[0]) === null || _d === void 0 ? void 0 : _d.icon, label: label })) : !screenMode && _optionsMap[label] ? (getFormattedLabel(_optionsMap[label])) : (label) }));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return showValue;
|
|
317
|
+
}, [isCascaded, _propsOptions, noClickEditing, finallyOptions, options, isMultiple, value, screenMode]);
|
|
318
|
+
const valueOptions = useMemo(() => {
|
|
319
|
+
if ((Array.isArray(options) && (options === null || options === void 0 ? void 0 : options.length) >= 1 && value && Array.isArray(value)) ||
|
|
320
|
+
(noClickEditing && Array.isArray(_options) && _options.length > 0)) {
|
|
321
|
+
return value
|
|
322
|
+
.map(val => {
|
|
323
|
+
return _options === null || _options === void 0 ? void 0 : _options.find(opt => (opt === null || opt === void 0 ? void 0 : opt.value) === handleValue(val));
|
|
324
|
+
})
|
|
325
|
+
.filter(Boolean);
|
|
326
|
+
}
|
|
327
|
+
return [];
|
|
328
|
+
}, [options, value, noClickEditing, _options]);
|
|
329
|
+
const selectValue = useMemo(() => {
|
|
330
|
+
if (value === undefined) {
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
if (isMultiple) {
|
|
334
|
+
if (Array.isArray(value)) {
|
|
335
|
+
return isNilFilter(value.map(handleValue));
|
|
336
|
+
}
|
|
337
|
+
return isNil(value) ? [] : [value];
|
|
338
|
+
}
|
|
339
|
+
if (Array.isArray(value)) {
|
|
340
|
+
if ((value.length && (optionLoadedRef.current || !canAsyncFetchOption)) ||
|
|
341
|
+
(Array.isArray(_options) && _options.length > 0)) {
|
|
342
|
+
const v = value[0];
|
|
343
|
+
if (isPlainObject(v)) {
|
|
344
|
+
if (_options.some(option => option.value === v.value)) {
|
|
345
|
+
return onlyValue ? v.value : (v === null || v === void 0 ? void 0 : v.value) || v;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
if (_options.some(option => option.value === v))
|
|
350
|
+
return (v === null || v === void 0 ? void 0 : v.value) || v;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
}, [value, canAsyncFetchOption, _options, onlyValue, isMultiple]);
|
|
356
|
+
const handleClick = useCallback(() => {
|
|
357
|
+
if (!hasClickFetch) {
|
|
358
|
+
setEditing(true);
|
|
359
|
+
handleSelectFocus();
|
|
360
|
+
}
|
|
361
|
+
if (shouldSWRFetch && disabledSwr) {
|
|
362
|
+
handleFetchOptions();
|
|
363
|
+
}
|
|
364
|
+
hasClickFetch && setClicked(true);
|
|
365
|
+
}, [hasClickFetch, shouldSWRFetch, disabledSwr, handleSelectFocus, handleFetchOptions]);
|
|
366
|
+
const handleSelect = useCallback((val, option) => {
|
|
367
|
+
if (isMultiple) {
|
|
368
|
+
onSelect && onSelect([val], option);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
onSelect && onSelect([val], option);
|
|
372
|
+
}
|
|
373
|
+
}, [onSelect, isMultiple]);
|
|
374
|
+
const handleChange = useCallback((val, option) => {
|
|
375
|
+
var _a;
|
|
376
|
+
setTimeout(() => {
|
|
377
|
+
var _a;
|
|
378
|
+
(_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
379
|
+
});
|
|
380
|
+
const value = isMultiple ? val : val ? [val] : [];
|
|
381
|
+
setValue(value);
|
|
382
|
+
if (propsValue === undefined && !value.length) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (useChange) {
|
|
386
|
+
if (isMultiple) {
|
|
387
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, option === null || option === void 0 ? void 0 : option.map(item => {
|
|
388
|
+
var _a;
|
|
389
|
+
return ({
|
|
390
|
+
...item,
|
|
391
|
+
label: (_a = options === null || options === void 0 ? void 0 : options.find(ops => ops.value === item.value)) === null || _a === void 0 ? void 0 : _a.label,
|
|
392
|
+
});
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
const targetValue = Array.isArray(value) ? value[0] : value;
|
|
397
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, {
|
|
398
|
+
...option,
|
|
399
|
+
label: (_a = options === null || options === void 0 ? void 0 : options.find(ops => ops.value === targetValue)) === null || _a === void 0 ? void 0 : _a.label,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}, [propsValue, setValue, useChange, onChange, options, isMultiple]);
|
|
404
|
+
const handleClear = useCallback(() => {
|
|
405
|
+
setValue([]);
|
|
406
|
+
onChange && onChange([], options);
|
|
407
|
+
}, [onChange, options, setValue]);
|
|
408
|
+
const handleFocus = useCallback(() => {
|
|
409
|
+
if (fetchOnFocus) {
|
|
410
|
+
optionLoadedRef.current = true;
|
|
411
|
+
fetchOptions('').then(options => {
|
|
412
|
+
setOptions(cacheSelectOptions(options));
|
|
413
|
+
setLoading(false);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
else if (!(options === null || options === void 0 ? void 0 : options.length) && !canAsyncFetchOption) {
|
|
417
|
+
setValue([]);
|
|
418
|
+
}
|
|
419
|
+
}, [
|
|
420
|
+
fetchOnFocus,
|
|
421
|
+
options === null || options === void 0 ? void 0 : options.length,
|
|
422
|
+
canAsyncFetchOption,
|
|
423
|
+
fetchOptions,
|
|
424
|
+
setOptions,
|
|
425
|
+
cacheSelectOptions,
|
|
426
|
+
setLoading,
|
|
427
|
+
setValue,
|
|
428
|
+
]);
|
|
429
|
+
const handleBlur = useCallback(e => {
|
|
430
|
+
var _a;
|
|
431
|
+
if (open) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (!editMode) {
|
|
435
|
+
setEditing(false);
|
|
436
|
+
}
|
|
437
|
+
if (canAsyncFetchOption) {
|
|
438
|
+
setOptions(cachedOptionsRef.current);
|
|
439
|
+
}
|
|
440
|
+
if (propsValue === undefined && !value.length) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (!useChange) {
|
|
444
|
+
if (isClickFetch && ((_a = propsValue === null || propsValue === void 0 ? void 0 : propsValue[0]) === null || _a === void 0 ? void 0 : _a.label)) {
|
|
445
|
+
const needChange = value.length !== propsValue.length ||
|
|
446
|
+
xorWith(propsValue, value, (oldV, newV) => isPlainObject(oldV) ? oldV.value === newV : newV.value === oldV).length > 0;
|
|
447
|
+
needChange && (onChange === null || onChange === void 0 ? void 0 : onChange(value, options));
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, options);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
454
|
+
}, [
|
|
455
|
+
open,
|
|
456
|
+
editMode,
|
|
457
|
+
canAsyncFetchOption,
|
|
458
|
+
propsValue,
|
|
459
|
+
value,
|
|
460
|
+
useChange,
|
|
461
|
+
onBlur,
|
|
462
|
+
setOptions,
|
|
463
|
+
cachedOptionsRef,
|
|
464
|
+
isClickFetch,
|
|
465
|
+
onChange,
|
|
466
|
+
options,
|
|
467
|
+
]);
|
|
468
|
+
useEffect(() => {
|
|
469
|
+
if (mode !== 'multiple' && (propsValue === null || propsValue === void 0 ? void 0 : propsValue.length)) {
|
|
470
|
+
if (apply === 'cell') {
|
|
471
|
+
if (propsValue[0].archived === 'true') {
|
|
472
|
+
setReadonly(true);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
const valueFirst = propsValue[0];
|
|
477
|
+
const result = options === null || options === void 0 ? void 0 : options.find(opt => opt.value === (isObject(valueFirst) ? valueFirst.value : valueFirst));
|
|
478
|
+
if (result === null || result === void 0 ? void 0 : result.archived) {
|
|
479
|
+
setReadonly(true);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}, [options, propsValue, mode, apply]);
|
|
484
|
+
const filterOptionProp = useMemo(() => (canAsyncFetchOption ? false : defaultFilterOptions), [canAsyncFetchOption]);
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
if (open) {
|
|
487
|
+
handleClick();
|
|
488
|
+
}
|
|
489
|
+
}, [onlyWorkspace]);
|
|
490
|
+
const onDropdownVisibleChange = useCallback(open => {
|
|
491
|
+
setOpen(open);
|
|
492
|
+
if (!isMultiple && !open) {
|
|
493
|
+
setTimeout(() => {
|
|
494
|
+
var _a;
|
|
495
|
+
(_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}, [isMultiple]);
|
|
499
|
+
const dropdownRender = useCallback(({ cx, css }) => {
|
|
500
|
+
return menu => {
|
|
501
|
+
if (!isShowOnlyWorkspace)
|
|
502
|
+
return menu;
|
|
503
|
+
const message = t('pages.fields.default.onlyWorkspace', {
|
|
504
|
+
name: props.onlyWorkspaceTip || t(`pages.fields.fieldName.${fieldTypeKey}`),
|
|
505
|
+
});
|
|
506
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: cx(css(onlyWorkspaceStyle)), children: _jsx(Checkbox, { checked: onlyWorkspace, onChange: onChangeCurrent, onClick: e => {
|
|
507
|
+
e.stopPropagation();
|
|
508
|
+
}, children: _jsx(BaseOverflowTooltip, { title: message, children: message }) }) }), _jsx(Divider, { className: cx(css(onlyWorkspaceDividerStyle)) }), menu] }));
|
|
509
|
+
};
|
|
510
|
+
}, [fieldTypeKey, isShowOnlyWorkspace, onChangeCurrent, onlyWorkspace, props.onlyWorkspaceTip, t]);
|
|
511
|
+
const notFoundContentMemo = useMemo(() => {
|
|
512
|
+
return loading && canAsyncFetchOption ? (_jsx(Spin, { size: "small" })) : (_jsx(ClassNames, { children: ({ css, cx }) => (_jsx("div", { className: cx(css(emptyIconWrapper)), children: _jsx(EmptyIcon, { noMargin: true }) })) }));
|
|
513
|
+
}, [canAsyncFetchOption, loading]);
|
|
514
|
+
const style = getFieldWidthStyle(labelWidth, labelAlign, hiddenLabel, apply);
|
|
515
|
+
const hiddenHover = readonly || editMode || editing || apply === 'cell' || isView;
|
|
516
|
+
const overlayRender = useMemo(() => {
|
|
517
|
+
return (_jsx(ClassNames, { children: ({ cx, css }) => {
|
|
518
|
+
const cxDropdownRender = dropdownRender({ cx, css });
|
|
519
|
+
return (_jsx("div", { className: 'field-value-overlay', children: _jsx(AntSelect, { getPopupContainer: triggerNode => getPopupContainerFun(getPopupContainer, triggerNode, apply, page), filterOption: filterOptionProp, ...defaultProps, className: cx('field-value-overlay-component', disabledLineThrough || displayValueHidden ? css(dropdownSelectStyle(antPrefix)) : '', {
|
|
520
|
+
[optionDisplayWrapClass]: optionDisplayWrap,
|
|
521
|
+
}), mode: mode, ref: targetRef, value: selectValue, showSearch: true, maxTagCount: optionDisplayWrap || isView ? null : 'responsive', onSelect: handleSelect, onClear: handleClear, onBlur: handleBlur, open: open, onDropdownVisibleChange: onDropdownVisibleChange, onFocus: handleFocus, onChange: handleChange, allowClear: allowClear, onSearch: handleSearch, defaultOpen: !editMode, listItemHeight: 32, listHeight: 200, optionLabelProp: fieldTypeKey === FIELD_TYPE_KEY_MAPPINGS.Version ? 'label' : 'children', notFoundContent: notFoundContentMemo, dropdownRender: cxDropdownRender, children: _options.map(item => {
|
|
522
|
+
var _a, _b, _c;
|
|
523
|
+
return (_jsxs(AntSelect.Option, { value: item.value, label: item.label, disabled: item.disabled, values: item.values, children: [_jsx("span", { className: cx({ [dropdownSelectOptionClass]: disabledLineThrough || displayValueHidden }, { [disabledClass]: item === null || item === void 0 ? void 0 : item.disabled }), children: _jsxs(BaseOverflowTooltip, { title: (_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toString(), className: "custom-overflow", children: [_jsx(ItemIcon, { icon: item.icon, label: item.label }), fieldTypeKey === FIELD_TYPE_KEY_MAPPINGS.Version && item.archived && (_jsxs("span", { children: ["(", t('workspaceArchived.archived'), ")"] }))] }) }), displayWorkspace ? (_jsx("div", { className: cx(workspaceClass), children: _jsx(BaseOverflowTooltip, { title: (_b = item === null || item === void 0 ? void 0 : item.workspace) === null || _b === void 0 ? void 0 : _b.name, children: (_c = item === null || item === void 0 ? void 0 : item.workspace) === null || _c === void 0 ? void 0 : _c.name }) })) : null] }, item.value));
|
|
524
|
+
}) }) }));
|
|
525
|
+
} }));
|
|
526
|
+
}, [
|
|
527
|
+
_options,
|
|
528
|
+
allowClear,
|
|
529
|
+
antPrefix,
|
|
530
|
+
apply,
|
|
531
|
+
defaultProps,
|
|
532
|
+
disabledLineThrough,
|
|
533
|
+
displayValueHidden,
|
|
534
|
+
displayWorkspace,
|
|
535
|
+
dropdownRender,
|
|
536
|
+
editMode,
|
|
537
|
+
fieldTypeKey,
|
|
538
|
+
filterOptionProp,
|
|
539
|
+
getPopupContainer,
|
|
540
|
+
handleBlur,
|
|
541
|
+
handleChange,
|
|
542
|
+
handleClear,
|
|
543
|
+
handleFocus,
|
|
544
|
+
handleSearch,
|
|
545
|
+
handleSelect,
|
|
546
|
+
isView,
|
|
547
|
+
mode,
|
|
548
|
+
notFoundContentMemo,
|
|
549
|
+
onDropdownVisibleChange,
|
|
550
|
+
open,
|
|
551
|
+
optionDisplayWrap,
|
|
552
|
+
page,
|
|
553
|
+
selectValue,
|
|
554
|
+
t,
|
|
555
|
+
]);
|
|
556
|
+
return (_jsx(ClassNames, { children: ({ cx, css }) => {
|
|
557
|
+
const cxShowValue = showValue({ cx, css });
|
|
558
|
+
return (_jsxs(Col, { style: style, ref: containerRef, className: cx(css(dropdownStyle(antPrefix)), 'field-value', viewClassNames, { [hiddenHoverClass]: hiddenHover }, { [displayWrapClass]: valueDisplayWrap }, { [css(dropdownSelectStyle(antPrefix))]: disabledLineThrough || displayValueHidden }), onClick: handleClick, children: [(readonly || (!editMode && !editing)) &&
|
|
559
|
+
(cxShowValue ? (!valueDisplayWrap ? (isView && isMultiple ? (_jsx(Expand, { readonly: readonly, editing: editing, expandType: EXPAND_TYPE_ENUM.TAG, children: valueOptions.map(item => (_jsx("span", { className: "field-common-view-tag", children: _jsx(BaseOverflowTooltip, { title: item.label, children: item.label }) }, item.value))) })) : (_jsx(OverflowTooltip, { title: cxShowValue, children: cxShowValue }))) : (_jsx("div", { className: cx(valueOptionContentClass), children: valueOptions.map(ele => {
|
|
560
|
+
return (_jsxs("div", { className: cx(valueOptionClass), title: ele.label, children: [_jsx(ItemIcon, { className: cx(valueOptionIconClass), icon: ele.icon }), _jsx("span", { className: cx(valueOptionLabelClass), children: ele.label })] }, ele.value));
|
|
561
|
+
}) }))) : (_jsx(EmptyField, { readonly: readonly }))), !readonly && (editMode || editing) && containerRef && (_jsx(Overlay, { show: true, rootClose: true, container: containerRef, target: containerRef, onHide: noop, children: () => overlayRender })), _jsx(DownOutlined, { className: cx(hoverIconClass) })] }));
|
|
562
|
+
} }));
|
|
563
|
+
};
|
|
564
|
+
Dropdown.displayName = 'DropdownBaseField';
|
|
565
|
+
export default Dropdown;
|
|
@@ -73,7 +73,7 @@ const DropdownReadView = memo(props => {
|
|
|
73
73
|
.join(',');
|
|
74
74
|
return result;
|
|
75
75
|
}, [options, value]);
|
|
76
|
-
return
|
|
76
|
+
return showValue ? (_jsx(SimpleOverflowToolTip, { title: showValueTitle, children: showValue })) : (_jsx(EmptyField, { readonly: readonly }));
|
|
77
77
|
});
|
|
78
78
|
DropdownReadView.displayName = 'DropdownReadView';
|
|
79
79
|
export default DropdownReadView;
|