@giteeteam/apps-team-components 1.2.2 → 1.3.0-alpha.2
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/EmptyField.d.ts +0 -1
- package/dist/components/common/EmptyField.js +7 -5
- package/dist/components/common/PriceTag.js +26 -23
- package/dist/components/common/expand-component/index.d.ts +22 -0
- package/dist/components/common/expand-component/index.js +67 -0
- package/dist/components/common/expand-component/style.d.ts +2 -0
- package/dist/components/common/expand-component/style.js +10 -0
- package/dist/components/common/item-icon/ItemIcon.d.ts +7 -0
- package/dist/components/common/item-icon/ItemIcon.js +8 -0
- package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.d.ts +0 -1
- package/dist/components/common/overflow-tooltip/BaseOverflowTooltip.js +9 -6
- package/dist/components/common/overflow-tooltip/OverflowTooltip.d.ts +19 -0
- package/dist/components/common/overflow-tooltip/OverflowTooltip.js +57 -0
- package/dist/components/common/overflow-tooltip/SimpleOverflowToolTip.js +8 -5
- package/dist/components/common/overflow-tooltip/style/index.js +16 -14
- package/dist/components/common/style/global.js +4 -2
- package/dist/components/common/style/mixin.d.ts +2 -0
- package/dist/components/common/style/mixin.js +20 -0
- package/dist/components/common/user-field/UserAvatar.js +8 -6
- package/dist/components/common/user-field/style/index.js +23 -21
- package/dist/components/common/utils.d.ts +6 -0
- package/dist/components/common/utils.js +63 -5
- package/dist/components/default-empty-icon/config.d.ts +2 -0
- package/dist/components/default-empty-icon/config.js +24 -0
- package/dist/components/default-empty-icon/index.d.ts +5 -0
- package/dist/components/default-empty-icon/index.js +24 -0
- package/dist/components/default-empty-icon/style.d.ts +11 -0
- package/dist/components/default-empty-icon/style.js +67 -0
- package/dist/components/default-empty-icon/types.d.ts +29 -0
- package/dist/components/default-empty-icon/types.js +8 -0
- package/dist/components/field-behavior/fields/type.js +5 -2
- package/dist/components/fields/actors/BaseField.js +5 -2
- package/dist/components/fields/actors/ReadView.d.ts +0 -1
- package/dist/components/fields/actors/ReadView.js +8 -6
- package/dist/components/fields/ancestor/ReadView.js +8 -6
- package/dist/components/fields/ancestor/utils.js +4 -12
- package/dist/components/fields/assignee/ReadView.d.ts +0 -1
- package/dist/components/fields/assignee/ReadView.js +13 -11
- 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 +11 -0
- package/dist/components/fields/bind-workspace/ReadView.d.ts +0 -1
- package/dist/components/fields/bind-workspace/ReadView.js +11 -9
- package/dist/components/fields/bind-workspace/hooks.js +10 -7
- package/dist/components/fields/bind-workspace/style/index.js +5 -3
- package/dist/components/fields/cascade/ReadView.js +8 -6
- package/dist/components/fields/cascade/utils.js +4 -3
- package/dist/components/fields/checkbox/ReadView.d.ts +0 -1
- package/dist/components/fields/checkbox/ReadView.js +7 -5
- package/dist/components/fields/created-at/ReadView.js +10 -8
- package/dist/components/fields/created-by/ReadView.d.ts +0 -1
- package/dist/components/fields/created-by/ReadView.js +11 -9
- package/dist/components/fields/data-quote/ReadView.js +12 -10
- package/dist/components/fields/data-quote/utils.js +5 -3
- package/dist/components/fields/date/ReadView.d.ts +0 -1
- package/dist/components/fields/date/ReadView.js +8 -6
- package/dist/components/fields/dropdown/BaseField.d.ts +24 -2
- package/dist/components/fields/dropdown/BaseField.js +565 -2
- package/dist/components/fields/dropdown/Cell.d.ts +3 -0
- package/dist/components/fields/dropdown/Cell.js +8 -0
- package/dist/components/fields/dropdown/ReadView.d.ts +0 -1
- package/dist/components/fields/dropdown/ReadView.js +10 -8
- package/dist/components/fields/dropdown/data.d.ts +9 -0
- package/dist/components/fields/dropdown/data.js +29 -0
- package/dist/components/fields/dropdown/hook.d.ts +102 -0
- package/dist/components/fields/dropdown/hook.js +155 -0
- package/dist/components/fields/dropdown/style.d.ts +16 -0
- package/dist/components/fields/dropdown/style.js +93 -0
- package/dist/components/fields/file/ReadView.d.ts +0 -1
- package/dist/components/fields/file/ReadView.js +7 -5
- package/dist/components/fields/formula/ReadView.d.ts +0 -1
- package/dist/components/fields/formula/ReadView.js +7 -5
- package/dist/components/fields/hooks/useViewClass.d.ts +11 -0
- package/dist/components/fields/hooks/useViewClass.js +20 -0
- package/dist/components/fields/hyper-link/ReadView.d.ts +0 -1
- package/dist/components/fields/hyper-link/ReadView.js +8 -6
- package/dist/components/fields/hyper-link/style/index.js +18 -15
- package/dist/components/fields/item-group/ReadView.d.ts +0 -1
- package/dist/components/fields/item-group/ReadView.js +6 -4
- package/dist/components/fields/item-type/ItemTypeIcon.d.ts +9 -0
- package/dist/components/fields/item-type/ItemTypeIcon.js +31 -0
- package/dist/components/fields/item-type/ReadView.d.ts +0 -1
- package/dist/components/fields/item-type/ReadView.js +7 -5
- package/dist/components/fields/item-type/style/index.d.ts +1 -0
- package/dist/components/fields/item-type/style/index.js +8 -0
- package/dist/components/fields/key/ReadView.d.ts +0 -1
- package/dist/components/fields/key/ReadView.js +7 -5
- package/dist/components/fields/long-text/ReadView.d.ts +0 -1
- package/dist/components/fields/long-text/ReadView.js +8 -6
- package/dist/components/fields/long-text/style/index.js +7 -5
- package/dist/components/fields/number/BaseField.js +5 -2
- package/dist/components/fields/number/ReadView.d.ts +0 -1
- package/dist/components/fields/number/ReadView.js +8 -6
- package/dist/components/fields/priority/ReadView.js +12 -10
- package/dist/components/fields/priority/style/index.js +54 -51
- package/dist/components/fields/radio/ReadView.d.ts +0 -1
- package/dist/components/fields/radio/ReadView.js +8 -6
- package/dist/components/fields/repo-files/ReadView.js +8 -6
- package/dist/components/fields/repo-files/utils.js +5 -3
- package/dist/components/fields/reporter/ReadView.d.ts +0 -1
- package/dist/components/fields/reporter/ReadView.js +11 -9
- package/dist/components/fields/script/BaseField.js +4 -1
- package/dist/components/fields/script/ReadView.d.ts +0 -1
- package/dist/components/fields/script/ReadView.js +10 -8
- package/dist/components/fields/sprint/ReadView.js +7 -5
- package/dist/components/fields/status/Cell.js +8 -6
- package/dist/components/fields/status/Field.d.ts +0 -1
- package/dist/components/fields/status/ReadView.js +10 -8
- package/dist/components/fields/status/SelectFlowHandler.js +15 -12
- package/dist/components/fields/status/SelectTransition.js +13 -10
- package/dist/components/fields/status/Transition.js +18 -15
- package/dist/components/fields/status/TransitionButton.js +17 -14
- package/dist/components/fields/status/TransitionPanel.js +14 -11
- package/dist/components/fields/status/View.js +11 -8
- package/dist/components/fields/status/style/index.js +302 -325
- package/dist/components/fields/story-point/ReadView.d.ts +0 -1
- package/dist/components/fields/story-point/ReadView.js +6 -4
- package/dist/components/fields/tag/ReadView.js +10 -8
- package/dist/components/fields/tag/style/index.js +7 -5
- package/dist/components/fields/team/ReadView.js +10 -8
- package/dist/components/fields/team/style/index.js +5 -3
- package/dist/components/fields/text/BaseField.d.ts +0 -1
- package/dist/components/fields/text/ReadView.js +8 -6
- package/dist/components/fields/tree/ReadView.js +10 -8
- package/dist/components/fields/tree/utils.js +5 -3
- package/dist/components/fields/updated-at/ReadView.js +10 -8
- package/dist/components/fields/updated-by/ReadView.d.ts +0 -1
- package/dist/components/fields/updated-by/ReadView.js +11 -9
- package/dist/components/fields/user/ReadView.d.ts +0 -1
- package/dist/components/fields/user/ReadView.js +11 -9
- package/dist/components/fields/user/style/index.js +12 -9
- package/dist/components/fields/user-group/BaseField.d.ts +0 -1
- package/dist/components/fields/user-group/ReadView.js +12 -14
- package/dist/components/fields/version/ReadView.js +8 -6
- package/dist/components/fields/workspace/ReadView.d.ts +0 -1
- package/dist/components/fields/workspace/ReadView.js +10 -8
- package/dist/components/filters/filter-search/utils.d.ts +4 -0
- package/dist/components/filters/filter-search/utils.js +28 -0
- package/dist/components/item/hooks.js +5 -2
- package/dist/components/table-components/EditTableCell.d.ts +1 -0
- package/dist/components/table-components/EditTableCell.js +8 -4
- package/dist/components/table-components/index.js +14 -11
- package/dist/components/table-components/style/index.js +7 -5
- package/dist/components/table-components/utils.js +50 -45
- package/dist/icons/SyncIconFont.d.ts +6 -0
- package/dist/icons/SyncIconFont.js +17 -0
- package/dist/icons/createFromIconFontClass.d.ts +4 -0
- package/dist/icons/createFromIconFontClass.js +35 -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 +8 -0
- package/dist/icons/empty-icon/large-item@2x.png +0 -0
- package/dist/icons/empty-icon/large-item@2x.png.js +3 -0
- package/dist/icons/empty-icon/large-workspace@2x.png +0 -0
- package/dist/icons/empty-icon/large-workspace@2x.png.js +3 -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/small-default@2x.png.js +3 -0
- package/dist/icons/empty-icon/workspace-empty.svg +127 -0
- package/dist/icons/index.d.ts +58 -1
- package/dist/icons/index.js +315 -19
- package/dist/icons/style/index.d.ts +2 -0
- package/dist/icons/style/index.js +25 -0
- package/dist/icons/svg/ArrowBack.svg.js +3 -0
- package/dist/icons/svg/Done.svg.js +3 -0
- package/dist/icons/svg/DottedCircle.svg.js +3 -0
- package/dist/icons/svg/HollowCircle.svg.js +3 -0
- package/dist/icons/svg/Search.svg.js +3 -0
- package/dist/icons/svg/Workflow.svg.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +47 -46
- package/dist/lib/app/utils.d.ts +2 -0
- package/dist/lib/app/utils.js +18 -0
- package/dist/lib/array.js +5 -44
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.js +47 -0
- package/dist/lib/constants/code.d.ts +4 -0
- package/dist/lib/constants/code.js +6 -0
- package/dist/lib/constants/field.d.ts +1 -0
- package/dist/lib/constants/field.js +5 -0
- package/dist/lib/contexts/antdConfig.js +10 -7
- package/dist/lib/contexts/currentUser.js +7 -4
- package/dist/lib/contexts/currentWorkspace.js +7 -4
- package/dist/lib/contexts/datetimeFormat.js +7 -4
- package/dist/lib/contexts/index.js +16 -13
- package/dist/lib/contexts/itemConfig.js +7 -4
- package/dist/lib/contexts/teamConfig.d.ts +3 -0
- package/dist/lib/contexts/teamConfig.js +25 -7
- package/dist/lib/contexts/tenant.js +7 -4
- package/dist/lib/contexts/workflowConfig.js +7 -4
- package/dist/lib/dataType.js +4 -5
- package/dist/lib/date.js +11 -52
- package/dist/lib/dayjs.js +2 -1
- package/dist/lib/error/index.d.ts +2 -0
- package/dist/lib/error/log.d.ts +10 -0
- package/dist/lib/error/log.js +28 -0
- package/dist/lib/error/utils.d.ts +14 -0
- package/dist/lib/error/utils.js +38 -0
- package/dist/lib/error/withServerError.d.ts +1 -0
- package/dist/lib/error/withServerError.js +3 -0
- package/dist/lib/fetch.d.ts +45 -0
- package/dist/lib/fetch.js +270 -0
- package/dist/lib/global.d.ts +18 -0
- package/dist/lib/global.js +28 -8
- package/dist/lib/hooks/useAntdConfig.js +4 -2
- package/dist/lib/hooks/useCurrentUser.js +4 -2
- package/dist/lib/hooks/useCurrentWorkspace.js +4 -2
- package/dist/lib/hooks/useDataQuoteStore.js +8 -5
- package/dist/lib/hooks/useDateTimeFormatType.js +4 -2
- package/dist/lib/hooks/useI18n.d.ts +1 -1
- package/dist/lib/hooks/useI18n.js +4 -2
- package/dist/lib/hooks/useItemConfig.js +4 -2
- package/dist/lib/hooks/useTeamConfig.js +4 -2
- package/dist/lib/hooks/useTenant.js +4 -2
- package/dist/lib/hooks/useWorkflowConfig.js +4 -2
- package/dist/lib/i18n.d.ts +1 -0
- package/dist/lib/i18n.js +6 -2
- package/dist/lib/icons/utils.d.ts +23 -0
- package/dist/lib/icons/utils.js +60 -0
- package/dist/lib/isInOne.js +2 -1
- package/dist/lib/number.js +3 -1
- package/dist/lib/path.d.ts +5 -0
- package/dist/lib/path.js +50 -0
- package/dist/lib/regExp.js +3 -1
- package/dist/lib/router.d.ts +23 -0
- package/dist/lib/router.js +23 -0
- package/dist/lib/storage.d.ts +10 -0
- package/dist/lib/storage.js +27 -0
- package/dist/lib/store/dataQuoteStore.js +5 -2
- package/dist/lib/swr/constants.js +4 -2
- package/dist/lib/swr/hooks.js +6 -3
- package/dist/lib/swr/throttleWithCache.d.ts +17 -0
- package/dist/lib/swr/throttleWithCache.js +110 -0
- package/dist/lib/throttleFetch.d.ts +2 -0
- package/dist/lib/throttleFetch.js +68 -0
- package/dist/lib/useConfig.d.ts +8 -0
- package/dist/lib/useConfig.js +31 -0
- package/dist/lib/useUser.js +9 -6
- package/dist/lib/users.js +5 -2
- package/dist/lib/workflow.js +21 -20
- package/dist/locales/index.d.ts +45 -0
- package/dist/locales/index.js +50 -3
- 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 +19 -23
- package/dist/style/global.d.ts +1 -0
- package/dist/style/global.js +10 -0
- package/package.json +111 -69
- package/dist/components/fields/base-component/types.js +0 -1
- package/dist/components/fields/hooks/useParamsAdapter.js +0 -1
- package/dist/components/fields/radio/BaseField.js +0 -1
- package/dist/components/fields/status/Field.js +0 -1
- package/dist/components/fields/tag/BaseField.js +0 -1
- package/dist/components/fields/text/BaseField.js +0 -1
- package/dist/components/fields/tree/BaseField.js +0 -1
- package/dist/components/fields/tree/types.js +0 -1
- package/dist/components/fields/types.js +0 -1
- package/dist/components/fields/user-group/ActionCell.js +0 -1
- package/dist/components/fields/user-group/BaseField.js +0 -1
- package/dist/icons/svg/ArrowBack.svg +0 -1
- package/dist/icons/svg/Done.svg +0 -1
- package/dist/icons/svg/DottedCircle.svg +0 -7
- package/dist/icons/svg/HollowCircle.svg +0 -6
- package/dist/icons/svg/Search.svg +0 -1
- package/dist/icons/svg/Workflow.svg +0 -12
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
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { i18n } from '../../lib/i18n';
|
|
3
|
-
import { gray6 } from '../../style/common';
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { i18n } from '../../lib/i18n.js';
|
|
3
|
+
import { gray6 } from '../../style/common.js';
|
|
4
|
+
|
|
4
5
|
const EmptyField = props => {
|
|
5
6
|
const { readonly, isUser } = props;
|
|
6
|
-
return (
|
|
7
|
+
return (jsx("span", { style: { color: `var(--theme-disabled-color, ${gray6})` }, children: readonly ? '-' : i18n.t(`views.common.emptyField.${isUser ? 'user' : 'null'}`) }));
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
export { EmptyField as default };
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
|
-
import { i18n } from '../../lib/i18n';
|
|
5
|
-
import SimpleOverflowToolTip from './overflow-tooltip/SimpleOverflowToolTip';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { i18n } from '../../lib/i18n.js';
|
|
5
|
+
import SimpleOverflowToolTip from './overflow-tooltip/SimpleOverflowToolTip.js';
|
|
6
|
+
|
|
7
|
+
const containerStyle = `
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
max-width: 100%;
|
|
10
11
|
`;
|
|
11
|
-
|
|
12
|
-
flex: 1;
|
|
13
|
-
width: 0;
|
|
12
|
+
const textStyle = `
|
|
13
|
+
flex: 1;
|
|
14
|
+
width: 0;
|
|
14
15
|
`;
|
|
15
|
-
|
|
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;
|
|
16
|
+
const tagStyle = `
|
|
17
|
+
height: 18px;
|
|
18
|
+
padding: 0 4px;
|
|
19
|
+
margin-left: 8px;
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
line-height: 18px;
|
|
23
|
+
color: #fff;
|
|
24
|
+
background: linear-gradient(230deg, #66dbff 0%, #3683ff 100%);
|
|
25
|
+
border-radius: 5px 0;
|
|
26
|
+
white-space: nowrap;
|
|
26
27
|
`;
|
|
27
|
-
|
|
28
|
+
const PriceTag = ({ text, className, edition, expired }) => {
|
|
28
29
|
const isTagVisible = useMemo(() => {
|
|
29
30
|
if (edition === 'ee') {
|
|
30
31
|
return false;
|
|
@@ -34,5 +35,7 @@ export const PriceTag = ({ text, className, edition, expired }) => {
|
|
|
34
35
|
}
|
|
35
36
|
return expired;
|
|
36
37
|
}, [edition, expired]);
|
|
37
|
-
return isTagVisible ? (
|
|
38
|
+
return isTagVisible ? (jsx(ClassNames, { children: ({ cx, css }) => (jsxs("span", { className: cx(css(containerStyle), className), children: [jsx(SimpleOverflowToolTip, { title: typeof text === 'string' ? text : null, children: jsx("span", { className: css(textStyle), children: text }) }), jsx("span", { className: css(tagStyle), children: i18n.t('components.priceTag.pro') })] })) })) : (text);
|
|
38
39
|
};
|
|
40
|
+
|
|
41
|
+
export { PriceTag, containerStyle, tagStyle, textStyle };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum EXPAND_TYPE_ENUM {
|
|
2
|
+
TEXT = "text",
|
|
3
|
+
TAG = "tag"
|
|
4
|
+
}
|
|
5
|
+
export declare const EXPAND_MAP: {
|
|
6
|
+
tag: {
|
|
7
|
+
maxline: number;
|
|
8
|
+
lineHeight: number;
|
|
9
|
+
};
|
|
10
|
+
text: {
|
|
11
|
+
maxline: number;
|
|
12
|
+
lineHeight: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
interface ExpandProps {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
expandType?: EXPAND_TYPE_ENUM;
|
|
18
|
+
editing?: boolean;
|
|
19
|
+
readonly: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const Expand: React.FC<ExpandProps>;
|
|
22
|
+
export default Expand;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useMemo, useCallback, useEffect } 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 '../overflow-tooltip/BaseOverflowTooltip.js';
|
|
7
|
+
import { requestIdleCallback, cancelIdleCallback } from '../../../lib/app/utils.js';
|
|
8
|
+
import useI18n from '../../../lib/hooks/useI18n.js';
|
|
9
|
+
import { expandFooter, expandBtn } from './style.js';
|
|
10
|
+
|
|
11
|
+
const buttonHeight = 20;
|
|
12
|
+
var EXPAND_TYPE_ENUM;
|
|
13
|
+
(function (EXPAND_TYPE_ENUM) {
|
|
14
|
+
EXPAND_TYPE_ENUM["TEXT"] = "text";
|
|
15
|
+
EXPAND_TYPE_ENUM["TAG"] = "tag";
|
|
16
|
+
})(EXPAND_TYPE_ENUM || (EXPAND_TYPE_ENUM = {}));
|
|
17
|
+
const EXPAND_MAP = {
|
|
18
|
+
[EXPAND_TYPE_ENUM.TAG]: {
|
|
19
|
+
maxline: 10,
|
|
20
|
+
lineHeight: 28,
|
|
21
|
+
},
|
|
22
|
+
[EXPAND_TYPE_ENUM.TEXT]: {
|
|
23
|
+
maxline: 15,
|
|
24
|
+
lineHeight: 22,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const Expand = ({ children, editing, expandType = EXPAND_TYPE_ENUM.TAG }) => {
|
|
28
|
+
const [currentLine, setCurrentLine] = useState(0);
|
|
29
|
+
const [isExpand, setExpand] = useState(false);
|
|
30
|
+
const ref = useRef();
|
|
31
|
+
const { t } = useI18n();
|
|
32
|
+
const { maxline, lineHeight } = useMemo(() => {
|
|
33
|
+
const map = EXPAND_MAP[expandType];
|
|
34
|
+
return map || EXPAND_MAP[EXPAND_TYPE_ENUM.TAG];
|
|
35
|
+
}, [expandType]);
|
|
36
|
+
const showButton = useMemo(() => {
|
|
37
|
+
return currentLine > maxline;
|
|
38
|
+
}, [currentLine, maxline]);
|
|
39
|
+
const toggle = e => {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
setExpand(prev => !prev);
|
|
42
|
+
};
|
|
43
|
+
const calculate = useCallback(() => {
|
|
44
|
+
if (editing || !ref.current)
|
|
45
|
+
return;
|
|
46
|
+
const height = ref.current.offsetHeight;
|
|
47
|
+
const line = Math.ceil(height / lineHeight);
|
|
48
|
+
setCurrentLine(line);
|
|
49
|
+
}, [editing, lineHeight]);
|
|
50
|
+
useListener('itemDetailModalResize', calculate);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const id = requestIdleCallback(() => calculate());
|
|
53
|
+
return () => {
|
|
54
|
+
cancelIdleCallback(id);
|
|
55
|
+
};
|
|
56
|
+
}, [calculate]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const handle = debounce(calculate, 200);
|
|
59
|
+
window.addEventListener('resize', handle);
|
|
60
|
+
return () => {
|
|
61
|
+
window.removeEventListener('resize', handle);
|
|
62
|
+
};
|
|
63
|
+
}, [calculate]);
|
|
64
|
+
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') }) })) }))] }));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { EXPAND_MAP, EXPAND_TYPE_ENUM, Expand as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { ItemTypeIcon } from '../../fields/item-type/ItemTypeIcon.js';
|
|
3
|
+
|
|
4
|
+
const ItemIcon = ({ icon, label, className }) => {
|
|
5
|
+
return (jsxs(Fragment, { children: [icon ? jsx(ItemTypeIcon, { icon: icon, className: className }) : null, label] }));
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { ItemIcon as default };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { memo, useRef, cloneElement } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
|
-
import {
|
|
4
|
+
import { tooltipOverflowStyle, getTooltipMaxlineStyle } from './style/index.js';
|
|
5
|
+
|
|
5
6
|
const BaseOverflowTooltip = props => {
|
|
6
7
|
const { className, title, children, maxline = 1, style, onClick } = props;
|
|
7
8
|
const elRef = useRef();
|
|
8
9
|
if (!children) {
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
|
-
const childElement =
|
|
12
|
-
return (
|
|
12
|
+
const childElement = jsx("span", { children: children });
|
|
13
|
+
return (jsx(ClassNames, { children: ({ cx, css }) => {
|
|
13
14
|
return cloneElement(childElement, {
|
|
14
15
|
ref: elRef,
|
|
15
16
|
className: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(maxline)), className),
|
|
@@ -20,4 +21,6 @@ const BaseOverflowTooltip = props => {
|
|
|
20
21
|
} }));
|
|
21
22
|
};
|
|
22
23
|
BaseOverflowTooltip.displayName = 'BaseOverflowTooltip';
|
|
23
|
-
|
|
24
|
+
var BaseOverflowTooltip$1 = memo(BaseOverflowTooltip);
|
|
25
|
+
|
|
26
|
+
export { BaseOverflowTooltip$1 as default };
|
|
@@ -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,57 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { memo, useState, useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { ClassNames } from '@emotion/react';
|
|
4
|
+
import { Tooltip } from 'antd';
|
|
5
|
+
import { tooltipOverflowStyle, getTooltipMaxlineStyle } from './style/index.js';
|
|
6
|
+
|
|
7
|
+
const isTextOverflow = element => {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
window.requestAnimationFrame(() => {
|
|
10
|
+
resolve((element && element.clientHeight < element.scrollHeight) || false);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const overlayStyle = {
|
|
15
|
+
wordBreak: 'break-word',
|
|
16
|
+
whiteSpace: 'pre-wrap',
|
|
17
|
+
};
|
|
18
|
+
const getCurrentNodeContainer = target => target.parentNode;
|
|
19
|
+
const getPopupContainer = () => document.body;
|
|
20
|
+
const OverflowTooltip = props => {
|
|
21
|
+
const { trigger = 'hover', className = '', title = '', children, disabled = false, placement = 'top', maxline = 1, overlayClassName, mountOnCurrentNode = false, style, alwaysShowTooltip, defaultVisible = false, enterable, } = props;
|
|
22
|
+
const [visible, setVisible] = useState(defaultVisible);
|
|
23
|
+
const elRef = useRef();
|
|
24
|
+
const getContainer = mountOnCurrentNode ? getCurrentNodeContainer : getPopupContainer;
|
|
25
|
+
const updateVisible = useCallback(visible => {
|
|
26
|
+
setVisible(visible);
|
|
27
|
+
}, [setVisible]);
|
|
28
|
+
const handleVisibleChange = useCallback(async (visible) => {
|
|
29
|
+
const overflow = await isTextOverflow(elRef.current);
|
|
30
|
+
if (visible && alwaysShowTooltip && !disabled) {
|
|
31
|
+
updateVisible(true);
|
|
32
|
+
setVisible(true);
|
|
33
|
+
}
|
|
34
|
+
if (visible && overflow && !disabled) {
|
|
35
|
+
updateVisible(visible);
|
|
36
|
+
setVisible(visible);
|
|
37
|
+
}
|
|
38
|
+
if (!visible) {
|
|
39
|
+
updateVisible(visible);
|
|
40
|
+
}
|
|
41
|
+
}, [disabled, updateVisible, alwaysShowTooltip]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (disabled) {
|
|
44
|
+
setVisible(false);
|
|
45
|
+
}
|
|
46
|
+
}, [disabled]);
|
|
47
|
+
if (!children) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const content = (jsx(ClassNames, { children: ({ cx, css }) => (jsx("span", { ref: elRef, className: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(maxline)), className), style: style, onMouseLeave: () => {
|
|
51
|
+
!enterable && setVisible(false);
|
|
52
|
+
}, children: children })) }));
|
|
53
|
+
return (jsx(Tooltip, { trigger: trigger, placement: placement, overlayStyle: overlayStyle, overlayClassName: overlayClassName, title: title, open: visible, onOpenChange: handleVisibleChange, getPopupContainer: getContainer, destroyTooltipOnHide: true, children: content }));
|
|
54
|
+
};
|
|
55
|
+
var OverflowTooltip$1 = memo(OverflowTooltip);
|
|
56
|
+
|
|
57
|
+
export { OverflowTooltip$1 as default };
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React, { cloneElement } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
|
-
import { simpleTooltipStyle } from './style';
|
|
4
|
+
import { simpleTooltipStyle } from './style/index.js';
|
|
5
|
+
|
|
5
6
|
const SimpleOverflowToolTip = ({ title, children, className }) => {
|
|
6
7
|
const contentRef = React.useRef();
|
|
7
|
-
return (
|
|
8
|
-
return cloneElement(
|
|
8
|
+
return (jsx(ClassNames, { children: ({ cx, css }) => {
|
|
9
|
+
return cloneElement(jsx("span", { children: children }), {
|
|
9
10
|
ref: contentRef,
|
|
10
11
|
className: cx(css(simpleTooltipStyle), className),
|
|
11
12
|
title: title || '',
|
|
12
13
|
});
|
|
13
14
|
} }));
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
var SimpleOverflowToolTip$1 = React.memo(SimpleOverflowToolTip);
|
|
17
|
+
|
|
18
|
+
export { SimpleOverflowToolTip$1 as default };
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
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
|
+
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
|
-
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
text-overflow: ellipsis;
|
|
12
|
-
white-space: nowrap;
|
|
9
|
+
const simpleTooltipStyle = `
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
text-overflow: ellipsis;
|
|
12
|
+
white-space: nowrap;
|
|
13
13
|
`;
|
|
14
|
-
|
|
15
|
-
return `
|
|
16
|
-
-webkit-line-clamp: ${n};
|
|
14
|
+
const getTooltipMaxlineStyle = (n) => {
|
|
15
|
+
return `
|
|
16
|
+
-webkit-line-clamp: ${n};
|
|
17
17
|
`;
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
export { getTooltipMaxlineStyle, simpleTooltipStyle, tooltipOverflowStyle };
|
|
@@ -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,20 @@
|
|
|
1
|
+
import { gray4, gray6 } from '../../../style/common.js';
|
|
2
|
+
|
|
3
|
+
const hoverStyle = `
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
height: 32px;
|
|
9
|
+
padding: 0 8px !important;
|
|
10
|
+
color: rgb(226 236 255 50%);
|
|
11
|
+
border: 1px solid ${gray4};
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
`;
|
|
14
|
+
const hoverIconStyle = `
|
|
15
|
+
display: none;
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
color: ${gray6};
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export { hoverIconStyle, hoverStyle };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
|
-
import {
|
|
5
|
-
import { avatarItemStyle, avatarStyle, defaultAvatarStyle } from './style';
|
|
4
|
+
import { getNameBadge, getBackgroundColor } from '../utils.js';
|
|
5
|
+
import { avatarItemStyle, avatarStyle, defaultAvatarStyle } from './style/index.js';
|
|
6
|
+
|
|
6
7
|
const UserAvatar = React.memo(({ user, className }) => {
|
|
7
8
|
const avatarUrl = useMemo(() => { var _a; return (_a = user === null || user === void 0 ? void 0 : user.avatar) === null || _a === void 0 ? void 0 : _a.url; }, [user]);
|
|
8
9
|
const displayName = useMemo(() => (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.nickname) || (user === null || user === void 0 ? void 0 : user.username), [user]);
|
|
9
10
|
const userBadge = useMemo(() => getNameBadge(displayName), [displayName]);
|
|
10
|
-
return (
|
|
11
|
-
return avatarUrl ? (
|
|
11
|
+
return (jsx(ClassNames, { children: ({ cx, css }) => {
|
|
12
|
+
return avatarUrl ? (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(avatarStyle), css(className)), style: { backgroundImage: `url(${avatarUrl})` } })) : (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(defaultAvatarStyle), css(className)), style: getBackgroundColor(userBadge), children: userBadge }));
|
|
12
13
|
} }));
|
|
13
14
|
});
|
|
14
15
|
UserAvatar.displayName = 'UserAvatar';
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
export { UserAvatar as default };
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
const avatarSize = '20px';
|
|
2
|
-
|
|
3
|
-
flex-shrink: 0;
|
|
2
|
+
const avatarItemStyle = `
|
|
3
|
+
flex-shrink: 0;
|
|
4
4
|
`;
|
|
5
|
-
|
|
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
|
+
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
|
-
|
|
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
|
+
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
|
`;
|
|
26
|
+
|
|
27
|
+
export { avatarItemStyle, avatarStyle, defaultAvatarStyle };
|
|
@@ -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 {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC } from '../../lib/global';
|
|
3
|
-
|
|
1
|
+
import '../../lib/dayjs.js';
|
|
2
|
+
import { DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC } from '../../lib/global.js';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
|
|
5
|
+
const getNameBadge = (name) => {
|
|
4
6
|
var _a;
|
|
5
7
|
if (!((_a = name === null || name === void 0 ? void 0 : name.trim) === null || _a === void 0 ? void 0 : _a.call(name)))
|
|
6
8
|
return null;
|
|
@@ -8,14 +10,14 @@ export const getNameBadge = (name) => {
|
|
|
8
10
|
return String.fromCodePoint(str.codePointAt(0));
|
|
9
11
|
};
|
|
10
12
|
const randomBackgroundColor = ['#5EA1FF', '#4BCC87', '#FFD15E'];
|
|
11
|
-
|
|
13
|
+
const getBackgroundColor = (s) => {
|
|
12
14
|
const code = (s === null || s === void 0 ? void 0 : s.charCodeAt(0)) || 0;
|
|
13
15
|
const random = Math.floor(code % randomBackgroundColor.length);
|
|
14
16
|
return {
|
|
15
17
|
background: randomBackgroundColor[random],
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
const dateFormat = (time, type) => {
|
|
19
21
|
const format = DATE_TIME_FORMAT;
|
|
20
22
|
const format_sec = DATE_TIME_FORMAT_SEC;
|
|
21
23
|
const date = dayjs(time);
|
|
@@ -34,3 +36,59 @@ export const dateFormat = (time, type) => {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
};
|
|
39
|
+
const defaultFilterOptions = (inputValue, option) => {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
const lowerInputValue = inputValue.toLocaleLowerCase();
|
|
42
|
+
try {
|
|
43
|
+
if (typeof option.children === 'string') {
|
|
44
|
+
return option.children.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
45
|
+
}
|
|
46
|
+
else if (option.children && typeof ((_a = option.children.props) === null || _a === void 0 ? void 0 : _a.label) === 'string') {
|
|
47
|
+
return option.children.props.label.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
48
|
+
}
|
|
49
|
+
else if (option.children) {
|
|
50
|
+
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;
|
|
51
|
+
const str = label !== null && label !== void 0 ? label : JSON.stringify(option);
|
|
52
|
+
return str.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
53
|
+
}
|
|
54
|
+
else if (option.label) {
|
|
55
|
+
return option.label.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (option.children) {
|
|
60
|
+
const cloneOption = { ...option };
|
|
61
|
+
delete cloneOption.children;
|
|
62
|
+
const str = JSON.stringify(cloneOption);
|
|
63
|
+
return str.toLowerCase().indexOf(lowerInputValue) >= 0;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
};
|
|
69
|
+
const defaultConditionFunc = (dom, className) => dom.parentElement.className.includes(className);
|
|
70
|
+
const getParentEle = (dom, className, conditionFunc = defaultConditionFunc) => {
|
|
71
|
+
if (conditionFunc(dom, className)) {
|
|
72
|
+
return dom.parentElement;
|
|
73
|
+
}
|
|
74
|
+
else if (dom.parentElement === document.body) {
|
|
75
|
+
return document.body;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return getParentEle(dom.parentElement, className);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const getPopupContainerFun = (getPopupContainer, triggerNode, apply, page) => {
|
|
82
|
+
if (getPopupContainer) {
|
|
83
|
+
return getPopupContainer();
|
|
84
|
+
}
|
|
85
|
+
const ele = getParentEle(triggerNode, page + '-page-class');
|
|
86
|
+
if (apply === 'cell' || !ele) {
|
|
87
|
+
return document.body;
|
|
88
|
+
}
|
|
89
|
+
return ele;
|
|
90
|
+
};
|
|
91
|
+
const zhReg = /[\u4e00-\u9fa5]/g;
|
|
92
|
+
const isChinese = (text) => zhReg.test(text);
|
|
93
|
+
|
|
94
|
+
export { dateFormat, defaultFilterOptions, getBackgroundColor, getNameBadge, getParentEle, getPopupContainerFun, isChinese };
|