@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
package/README.md
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
# @giteeteam/apps-team-components
|
|
2
|
-
|
|
3
|
-
- gitee team components
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
- 去除 BaseOverflowToolTip 的 maxline
|
|
23
|
-
|
|
24
|
-
# 1.1.x版本
|
|
25
|
-
- team最低版本为4.16.0
|
|
26
|
-
|
|
27
|
-
# 1.2.x版本
|
|
28
|
-
- team最低版本为4.21.0
|
|
1
|
+
# @giteeteam/apps-team-components
|
|
2
|
+
|
|
3
|
+
- gitee team components
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm i
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 预览
|
|
12
|
+
**开发前务必先阅读预览首页文档**
|
|
13
|
+
```
|
|
14
|
+
pnpm storybook
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
# 1.1.x版本
|
|
18
|
+
- team最低版本为4.16.0
|
|
19
|
+
|
|
20
|
+
# 1.2.x版本
|
|
21
|
+
- team最低版本为4.21.0
|
|
@@ -3,26 +3,26 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
4
|
import { i18n } from '../../lib/i18n';
|
|
5
5
|
import SimpleOverflowToolTip from './overflow-tooltip/SimpleOverflowToolTip';
|
|
6
|
-
export const containerStyle = `
|
|
7
|
-
display: inline-flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
max-width: 100%;
|
|
6
|
+
export const containerStyle = `
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
max-width: 100%;
|
|
10
10
|
`;
|
|
11
|
-
export const textStyle = `
|
|
12
|
-
flex: 1;
|
|
13
|
-
width: 0;
|
|
11
|
+
export const textStyle = `
|
|
12
|
+
flex: 1;
|
|
13
|
+
width: 0;
|
|
14
14
|
`;
|
|
15
|
-
export const tagStyle = `
|
|
16
|
-
height: 18px;
|
|
17
|
-
padding: 0 4px;
|
|
18
|
-
margin-left: 8px;
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
font-weight: 500;
|
|
21
|
-
line-height: 18px;
|
|
22
|
-
color: #fff;
|
|
23
|
-
background: linear-gradient(230deg, #66dbff 0%, #3683ff 100%);
|
|
24
|
-
border-radius: 5px 0;
|
|
25
|
-
white-space: nowrap;
|
|
15
|
+
export const tagStyle = `
|
|
16
|
+
height: 18px;
|
|
17
|
+
padding: 0 4px;
|
|
18
|
+
margin-left: 8px;
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
font-weight: 500;
|
|
21
|
+
line-height: 18px;
|
|
22
|
+
color: #fff;
|
|
23
|
+
background: linear-gradient(230deg, #66dbff 0%, #3683ff 100%);
|
|
24
|
+
border-radius: 5px 0;
|
|
25
|
+
white-space: nowrap;
|
|
26
26
|
`;
|
|
27
27
|
export const PriceTag = ({ text, className, edition, expired }) => {
|
|
28
28
|
const isTagVisible = useMemo(() => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare enum EXPAND_TYPE_ENUM {
|
|
3
|
+
TEXT = "text",
|
|
4
|
+
TAG = "tag"
|
|
5
|
+
}
|
|
6
|
+
export declare const EXPAND_MAP: {
|
|
7
|
+
tag: {
|
|
8
|
+
maxline: number;
|
|
9
|
+
lineHeight: number;
|
|
10
|
+
};
|
|
11
|
+
text: {
|
|
12
|
+
maxline: number;
|
|
13
|
+
lineHeight: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
interface ExpandProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
expandType?: EXPAND_TYPE_ENUM;
|
|
19
|
+
editing?: boolean;
|
|
20
|
+
readonly: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const Expand: React.FC<ExpandProps>;
|
|
23
|
+
export default Expand;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { ClassNames } from '@emotion/react';
|
|
4
|
+
import { useListener } from '@giteeteam/proxima-sdk-js';
|
|
5
|
+
import { debounce } from 'lodash-es';
|
|
6
|
+
import BaseOverflowTooltip from 'components/common/overflow-tooltip/BaseOverflowTooltip';
|
|
7
|
+
import { cancelIdleCallback, requestIdleCallback } from 'lib/app/utils';
|
|
8
|
+
import useI18n from 'lib/hooks/useI18n';
|
|
9
|
+
import { expandBtn, expandFooter } from './style';
|
|
10
|
+
const buttonHeight = 20;
|
|
11
|
+
export var EXPAND_TYPE_ENUM;
|
|
12
|
+
(function (EXPAND_TYPE_ENUM) {
|
|
13
|
+
EXPAND_TYPE_ENUM["TEXT"] = "text";
|
|
14
|
+
EXPAND_TYPE_ENUM["TAG"] = "tag";
|
|
15
|
+
})(EXPAND_TYPE_ENUM || (EXPAND_TYPE_ENUM = {}));
|
|
16
|
+
export const EXPAND_MAP = {
|
|
17
|
+
[EXPAND_TYPE_ENUM.TAG]: {
|
|
18
|
+
maxline: 10,
|
|
19
|
+
lineHeight: 28,
|
|
20
|
+
},
|
|
21
|
+
[EXPAND_TYPE_ENUM.TEXT]: {
|
|
22
|
+
maxline: 15,
|
|
23
|
+
lineHeight: 22,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const Expand = ({ children, editing, expandType = EXPAND_TYPE_ENUM.TAG }) => {
|
|
27
|
+
const [currentLine, setCurrentLine] = useState(0);
|
|
28
|
+
const [isExpand, setExpand] = useState(false);
|
|
29
|
+
const ref = useRef();
|
|
30
|
+
const { t } = useI18n();
|
|
31
|
+
const { maxline, lineHeight } = useMemo(() => {
|
|
32
|
+
const map = EXPAND_MAP[expandType];
|
|
33
|
+
return map || EXPAND_MAP[EXPAND_TYPE_ENUM.TAG];
|
|
34
|
+
}, [expandType]);
|
|
35
|
+
const showButton = useMemo(() => {
|
|
36
|
+
return currentLine > maxline;
|
|
37
|
+
}, [currentLine, maxline]);
|
|
38
|
+
const toggle = e => {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
setExpand(prev => !prev);
|
|
41
|
+
};
|
|
42
|
+
const calculate = useCallback(() => {
|
|
43
|
+
if (editing || !ref.current)
|
|
44
|
+
return;
|
|
45
|
+
const height = ref.current.offsetHeight;
|
|
46
|
+
const line = Math.ceil(height / lineHeight);
|
|
47
|
+
setCurrentLine(line);
|
|
48
|
+
}, [editing, lineHeight]);
|
|
49
|
+
useListener('itemDetailModalResize', calculate);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const id = requestIdleCallback(() => calculate());
|
|
52
|
+
return () => {
|
|
53
|
+
cancelIdleCallback(id);
|
|
54
|
+
};
|
|
55
|
+
}, [calculate]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const handle = debounce(calculate, 200);
|
|
58
|
+
window.addEventListener('resize', handle);
|
|
59
|
+
return () => {
|
|
60
|
+
window.removeEventListener('resize', handle);
|
|
61
|
+
};
|
|
62
|
+
}, [calculate]);
|
|
63
|
+
return (_jsxs("div", { className: "expand-wrapper", style: { padding: currentLine > 1 && expandType === EXPAND_TYPE_ENUM.TEXT ? '5px 0' : 0 }, children: [_jsx("div", { className: "expand-content", children: _jsx(BaseOverflowTooltip, { maxline: isExpand ? 999 : maxline, children: _jsx("span", { ref: ref, children: children }) }) }), showButton && (_jsx(ClassNames, { children: ({ cx, css }) => (_jsx("div", { className: cx(css(expandFooter)), style: { height: `${buttonHeight}px`, lineHeight: `${buttonHeight}px` }, children: _jsx("span", { className: cx(css(expandBtn)), onClick: toggle, children: isExpand ? t('global.collapse') : t('global.expand') }) })) }))] }));
|
|
64
|
+
};
|
|
65
|
+
export default Expand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import ItemTypeIcon from 'components/fields/item-type/ItemTypeIcon';
|
|
3
|
+
const ItemIcon = ({ icon, label, className }) => {
|
|
4
|
+
return (_jsxs(_Fragment, { children: [icon ? _jsx(ItemTypeIcon, { icon: icon, className: className }) : null, label] }));
|
|
5
|
+
};
|
|
6
|
+
export default ItemIcon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
interface OverflowTooltip {
|
|
3
|
+
trigger?: 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
4
|
+
className?: string;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
children: any;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
maxline?: number;
|
|
9
|
+
mountOnCurrentNode?: boolean;
|
|
10
|
+
overlayClassName?: string;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
placement?: 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
13
|
+
alwaysShowTooltip?: boolean;
|
|
14
|
+
defaultVisible?: boolean;
|
|
15
|
+
enterable?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const OverflowTooltip: React.FC<OverflowTooltip>;
|
|
18
|
+
declare const _default: import("react").NamedExoticComponent<OverflowTooltip>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { ClassNames } from '@emotion/react';
|
|
4
|
+
import { Tooltip } from 'antd';
|
|
5
|
+
import { getTooltipMaxlineStyle, tooltipOverflowStyle } from './style';
|
|
6
|
+
const isTextOverflow = element => {
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
window.requestAnimationFrame(() => {
|
|
9
|
+
resolve((element && element.clientHeight < element.scrollHeight) || false);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const overlayStyle = {
|
|
14
|
+
wordBreak: 'break-word',
|
|
15
|
+
whiteSpace: 'pre-wrap',
|
|
16
|
+
};
|
|
17
|
+
const getCurrentNodeContainer = target => target.parentNode;
|
|
18
|
+
const getPopupContainer = () => document.body;
|
|
19
|
+
const OverflowTooltip = props => {
|
|
20
|
+
const { trigger = 'hover', className = '', title = '', children, disabled = false, placement = 'top', maxline = 1, overlayClassName, mountOnCurrentNode = false, style, alwaysShowTooltip, defaultVisible = false, enterable, } = props;
|
|
21
|
+
const [visible, setVisible] = useState(defaultVisible);
|
|
22
|
+
const elRef = useRef();
|
|
23
|
+
const getContainer = mountOnCurrentNode ? getCurrentNodeContainer : getPopupContainer;
|
|
24
|
+
const updateVisible = useCallback(visible => {
|
|
25
|
+
setVisible(visible);
|
|
26
|
+
}, [setVisible]);
|
|
27
|
+
const handleVisibleChange = useCallback(async (visible) => {
|
|
28
|
+
const overflow = await isTextOverflow(elRef.current);
|
|
29
|
+
if (visible && alwaysShowTooltip && !disabled) {
|
|
30
|
+
updateVisible(true);
|
|
31
|
+
setVisible(true);
|
|
32
|
+
}
|
|
33
|
+
if (visible && overflow && !disabled) {
|
|
34
|
+
updateVisible(visible);
|
|
35
|
+
setVisible(visible);
|
|
36
|
+
}
|
|
37
|
+
if (!visible) {
|
|
38
|
+
updateVisible(visible);
|
|
39
|
+
}
|
|
40
|
+
}, [disabled, updateVisible, alwaysShowTooltip]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (disabled) {
|
|
43
|
+
setVisible(false);
|
|
44
|
+
}
|
|
45
|
+
}, [disabled]);
|
|
46
|
+
if (!children) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const content = (_jsx(ClassNames, { children: ({ cx, css }) => (_jsx("span", { ref: elRef, className: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(maxline)), className), style: style, onMouseLeave: () => {
|
|
50
|
+
!enterable && setVisible(false);
|
|
51
|
+
}, children: children })) }));
|
|
52
|
+
return (_jsx(Tooltip, { trigger: trigger, placement: placement, overlayStyle: overlayStyle, overlayClassName: overlayClassName, title: title, open: visible, onOpenChange: handleVisibleChange, getPopupContainer: getContainer, destroyTooltipOnHide: true, children: content }));
|
|
53
|
+
};
|
|
54
|
+
export default memo(OverflowTooltip);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export const tooltipOverflowStyle = `
|
|
2
|
-
display: -webkit-box;
|
|
3
|
-
overflow: hidden;
|
|
4
|
-
text-overflow: ellipsis;
|
|
5
|
-
word-break: break-all;
|
|
6
|
-
white-space: pre-line !important;
|
|
7
|
-
-webkit-box-orient: vertical;
|
|
1
|
+
export const tooltipOverflowStyle = `
|
|
2
|
+
display: -webkit-box;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
text-overflow: ellipsis;
|
|
5
|
+
word-break: break-all;
|
|
6
|
+
white-space: pre-line !important;
|
|
7
|
+
-webkit-box-orient: vertical;
|
|
8
8
|
`;
|
|
9
|
-
export const simpleTooltipStyle = `
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
text-overflow: ellipsis;
|
|
12
|
-
white-space: nowrap;
|
|
9
|
+
export const simpleTooltipStyle = `
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
text-overflow: ellipsis;
|
|
12
|
+
white-space: nowrap;
|
|
13
13
|
`;
|
|
14
14
|
export const getTooltipMaxlineStyle = (n) => {
|
|
15
|
-
return `
|
|
16
|
-
-webkit-line-clamp: ${n};
|
|
15
|
+
return `
|
|
16
|
+
-webkit-line-clamp: ${n};
|
|
17
17
|
`;
|
|
18
18
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const fieldValueOverlayStyle = `
|
|
2
|
-
width: 100%;
|
|
1
|
+
export const fieldValueOverlayStyle = `
|
|
2
|
+
width: 100%;
|
|
3
3
|
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const hoverStyle = "\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 32px;\n padding: 0 8px !important;\n color: rgb(226 236 255 50%);\n border: 1px solid #F1F2F4;\n border-radius: 4px;\n";
|
|
2
|
+
export declare const hoverIconStyle = "\n display: none;\n font-size: 12px;\n color: #C1C5CF;\n";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { gray4, gray6 } from 'style/common';
|
|
2
|
+
export const hoverStyle = `
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
height: 32px;
|
|
8
|
+
padding: 0 8px !important;
|
|
9
|
+
color: rgb(226 236 255 50%);
|
|
10
|
+
border: 1px solid ${gray4};
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
`;
|
|
13
|
+
export const hoverIconStyle = `
|
|
14
|
+
display: none;
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: ${gray6};
|
|
17
|
+
`;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
const avatarSize = '20px';
|
|
2
|
-
export const avatarItemStyle = `
|
|
3
|
-
flex-shrink: 0;
|
|
2
|
+
export const avatarItemStyle = `
|
|
3
|
+
flex-shrink: 0;
|
|
4
4
|
`;
|
|
5
|
-
export const avatarStyle = `
|
|
6
|
-
display: inline-block;
|
|
7
|
-
width: ${avatarSize};
|
|
8
|
-
height: ${avatarSize};
|
|
9
|
-
margin-right: 3px;
|
|
10
|
-
vertical-align: middle;
|
|
11
|
-
background: #fff center/contain no-repeat;
|
|
12
|
-
border-radius: 50%;
|
|
5
|
+
export const avatarStyle = `
|
|
6
|
+
display: inline-block;
|
|
7
|
+
width: ${avatarSize};
|
|
8
|
+
height: ${avatarSize};
|
|
9
|
+
margin-right: 3px;
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
background: #fff center/contain no-repeat;
|
|
12
|
+
border-radius: 50%;
|
|
13
13
|
`;
|
|
14
|
-
export const defaultAvatarStyle = `
|
|
15
|
-
display: inline-flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
width: ${avatarSize};
|
|
19
|
-
height: ${avatarSize};
|
|
20
|
-
margin-right: 6px;
|
|
21
|
-
font-size: 12px;
|
|
22
|
-
color: #fff;
|
|
23
|
-
background: #5243aa;
|
|
24
|
-
border-radius: 50%;
|
|
14
|
+
export const defaultAvatarStyle = `
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
width: ${avatarSize};
|
|
19
|
+
height: ${avatarSize};
|
|
20
|
+
margin-right: 6px;
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
color: #fff;
|
|
23
|
+
background: #5243aa;
|
|
24
|
+
border-radius: 50%;
|
|
25
25
|
`;
|
|
@@ -3,3 +3,9 @@ export declare const getBackgroundColor: (s?: string) => {
|
|
|
3
3
|
background: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const dateFormat: (time: string, type?: string) => string;
|
|
6
|
+
export declare const defaultFilterOptions: (inputValue: string, option: any) => boolean;
|
|
7
|
+
type GetCondition = (dom: HTMLElement, className: string) => boolean;
|
|
8
|
+
export declare const getParentEle: (dom: HTMLElement, className: string, conditionFunc?: GetCondition) => HTMLElement;
|
|
9
|
+
export declare const getPopupContainerFun: (getPopupContainer: (node?: HTMLElement) => HTMLElement, triggerNode: HTMLElement, apply: string, page?: string) => HTMLElement;
|
|
10
|
+
export declare const isChinese: (text: string) => boolean;
|
|
11
|
+
export {};
|
|
@@ -34,3 +34,57 @@ export const dateFormat = (time, type) => {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
export const defaultFilterOptions = (inputValue, option) => {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
const lowerInputValue = inputValue.toLocaleLowerCase();
|
|
40
|
+
try {
|
|
41
|
+
if (typeof option.children === 'string') {
|
|
42
|
+
return option.children.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
43
|
+
}
|
|
44
|
+
else if (option.children && typeof ((_a = option.children.props) === null || _a === void 0 ? void 0 : _a.label) === 'string') {
|
|
45
|
+
return option.children.props.label.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
46
|
+
}
|
|
47
|
+
else if (option.children) {
|
|
48
|
+
const label = (_c = (_b = option === null || option === void 0 ? void 0 : option.children) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.label;
|
|
49
|
+
const str = label !== null && label !== void 0 ? label : JSON.stringify(option);
|
|
50
|
+
return str.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
51
|
+
}
|
|
52
|
+
else if (option.label) {
|
|
53
|
+
return option.label.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (option.children) {
|
|
58
|
+
const cloneOption = { ...option };
|
|
59
|
+
delete cloneOption.children;
|
|
60
|
+
const str = JSON.stringify(cloneOption);
|
|
61
|
+
return str.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
const defaultConditionFunc = (dom, className) => dom.parentElement.className.includes(className);
|
|
68
|
+
export const getParentEle = (dom, className, conditionFunc = defaultConditionFunc) => {
|
|
69
|
+
if (conditionFunc(dom, className)) {
|
|
70
|
+
return dom.parentElement;
|
|
71
|
+
}
|
|
72
|
+
else if (dom.parentElement === document.body) {
|
|
73
|
+
return document.body;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return getParentEle(dom.parentElement, className);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
export const getPopupContainerFun = (getPopupContainer, triggerNode, apply, page) => {
|
|
80
|
+
if (getPopupContainer) {
|
|
81
|
+
return getPopupContainer();
|
|
82
|
+
}
|
|
83
|
+
const ele = getParentEle(triggerNode, page + '-page-class');
|
|
84
|
+
if (apply === 'cell' || !ele) {
|
|
85
|
+
return document.body;
|
|
86
|
+
}
|
|
87
|
+
return ele;
|
|
88
|
+
};
|
|
89
|
+
const zhReg = /[\u4e00-\u9fa5]/g;
|
|
90
|
+
export const isChinese = (text) => zhReg.test(text);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LargeItem, LargeWorkspace, SmallDefault } from 'icons/empty-icon';
|
|
2
|
+
import { largeItemClass, largeWorkspaceClass, smallDefaultClass } from './style';
|
|
3
|
+
export const config = {
|
|
4
|
+
smallDefault: {
|
|
5
|
+
text: 'views.common.searchSelect.emptyData.noData',
|
|
6
|
+
url: SmallDefault,
|
|
7
|
+
className: smallDefaultClass,
|
|
8
|
+
},
|
|
9
|
+
largeItem: {
|
|
10
|
+
text: 'views.tableComponents.TableEmpty.noDataTip',
|
|
11
|
+
url: LargeItem,
|
|
12
|
+
className: largeItemClass,
|
|
13
|
+
},
|
|
14
|
+
largeWorkspace: {
|
|
15
|
+
text: 'pages.workspaces.default.emptyDataDefaultProps.operationInfo',
|
|
16
|
+
url: LargeWorkspace,
|
|
17
|
+
className: largeWorkspaceClass,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { ClassNames } from '@emotion/react';
|
|
3
|
+
import useI18n from 'lib/hooks/useI18n';
|
|
4
|
+
import { config } from './config';
|
|
5
|
+
import { autoMarginClass, emptyIconWrapper, largeMarginClass, noMarginClass, smallMarginClass, smallTextClass, textClass, } from './style';
|
|
6
|
+
import { EmptyType } from './types';
|
|
7
|
+
const EmptyIcon = ({ type = EmptyType.SMALL_DEFAULT, text, extra, className, style, center, smallText, smallMargin, largeMargin, noMargin, autoMargin, }) => {
|
|
8
|
+
const { t } = useI18n();
|
|
9
|
+
const { text: defaultText, url, className: defaultClass } = config[type] || {};
|
|
10
|
+
return (_jsx(ClassNames, { children: ({ cx, css }) => (_jsxs("div", { className: cx(css(emptyIconWrapper), {
|
|
11
|
+
center,
|
|
12
|
+
[smallTextClass]: smallText,
|
|
13
|
+
[smallMarginClass]: smallMargin,
|
|
14
|
+
[largeMarginClass]: largeMargin,
|
|
15
|
+
[noMarginClass]: noMargin,
|
|
16
|
+
[autoMarginClass]: autoMargin,
|
|
17
|
+
}, className), style: style, children: [_jsx("img", { className: cx(defaultClass), src: url, alt: "" }), _jsx("p", { className: cx(textClass), children: text || t(defaultText) }), extra] })) }));
|
|
18
|
+
};
|
|
19
|
+
export default EmptyIcon;
|
|
20
|
+
EmptyIcon.defaultProps = {
|
|
21
|
+
type: EmptyType.SMALL_DEFAULT,
|
|
22
|
+
};
|
|
23
|
+
export { EmptyType } from './types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const centerClass: string;
|
|
2
|
+
export declare const smallTextClass: string;
|
|
3
|
+
export declare const smallMarginClass: string;
|
|
4
|
+
export declare const textClass: string;
|
|
5
|
+
export declare const largeMarginClass: string;
|
|
6
|
+
export declare const noMarginClass: string;
|
|
7
|
+
export declare const autoMarginClass: string;
|
|
8
|
+
export declare const smallDefaultClass: string;
|
|
9
|
+
export declare const largeWorkspaceClass: string;
|
|
10
|
+
export declare const largeItemClass: string;
|
|
11
|
+
export declare const emptyIconWrapper: string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { randomClassName } from 'style/common';
|
|
2
|
+
export const centerClass = randomClassName('center');
|
|
3
|
+
export const smallTextClass = randomClassName('small-text');
|
|
4
|
+
export const smallMarginClass = randomClassName('small-margin');
|
|
5
|
+
export const textClass = randomClassName('text');
|
|
6
|
+
export const largeMarginClass = randomClassName('large-margin');
|
|
7
|
+
export const noMarginClass = randomClassName('no-margin');
|
|
8
|
+
export const autoMarginClass = randomClassName('auto-margin');
|
|
9
|
+
export const smallDefaultClass = randomClassName('small-default');
|
|
10
|
+
export const largeWorkspaceClass = randomClassName('large-workspace');
|
|
11
|
+
export const largeItemClass = randomClassName('large-item');
|
|
12
|
+
export const emptyIconWrapper = `
|
|
13
|
+
margin-top: 12px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
|
|
16
|
+
&.${centerClass} {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
user-select: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.${smallTextClass} {
|
|
25
|
+
.${textClass} {
|
|
26
|
+
font-size: 12px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.${smallMarginClass} {
|
|
31
|
+
margin-top: 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.${largeMarginClass} {
|
|
35
|
+
margin-top: 48px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.${noMarginClass} {
|
|
39
|
+
margin: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.${autoMarginClass} {
|
|
43
|
+
margin: auto;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.${smallDefaultClass} {
|
|
47
|
+
width: 90px;
|
|
48
|
+
height: 90px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.${largeWorkspaceClass},
|
|
52
|
+
.${largeItemClass} {
|
|
53
|
+
width: 180px;
|
|
54
|
+
height: 180px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.${textClass} {
|
|
58
|
+
padding: 0;
|
|
59
|
+
margin: 12px 0;
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
line-height: 22px;
|
|
62
|
+
color: #848c9f;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface PropType {
|
|
3
|
+
type?: EmptyType;
|
|
4
|
+
text?: string;
|
|
5
|
+
extra?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
center?: boolean;
|
|
9
|
+
smallText?: boolean;
|
|
10
|
+
smallMargin?: boolean;
|
|
11
|
+
largeMargin?: boolean;
|
|
12
|
+
noMargin?: boolean;
|
|
13
|
+
autoMargin?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare enum EmptyType {
|
|
16
|
+
SMALL_DEFAULT = "smallDefault",
|
|
17
|
+
LARGE_ITEM = "largeItem",
|
|
18
|
+
LARGE_WS = "largeWorkspace"
|
|
19
|
+
}
|
|
20
|
+
export interface ConfigType {
|
|
21
|
+
smallDefault: ConfigItem;
|
|
22
|
+
largeItem: ConfigItem;
|
|
23
|
+
largeWorkspace: ConfigItem;
|
|
24
|
+
}
|
|
25
|
+
export interface ConfigItem {
|
|
26
|
+
text: string;
|
|
27
|
+
url: string;
|
|
28
|
+
className: string;
|
|
29
|
+
}
|