@giteeteam/apps-team-components 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import '../../lib/dayjs.js';
2
2
  import { DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC } from '../../lib/global.js';
3
- import { blue4, orange4 } from '../../style/common.js';
3
+ import { blue4, green4, orange4 } from '../../style/common.js';
4
4
  import dayjs from 'dayjs';
5
5
 
6
6
  const getNameBadge = (name) => {
@@ -10,7 +10,7 @@ const getNameBadge = (name) => {
10
10
  const str = name.trim();
11
11
  return String.fromCodePoint(str.codePointAt(0));
12
12
  };
13
- const randomBackgroundColor = [blue4, '#4BCC87', orange4];
13
+ const randomBackgroundColor = [blue4, green4, orange4];
14
14
  const getBackgroundColor = (s) => {
15
15
  const code = (s === null || s === void 0 ? void 0 : s.charCodeAt(0)) || 0;
16
16
  const random = Math.floor(code % randomBackgroundColor.length);
@@ -3,20 +3,25 @@ import { memo } from 'react';
3
3
  import { ClassNames } from '@emotion/react';
4
4
  import { useCreation } from 'ahooks';
5
5
  import { getArrayValue } from '../../../lib/array.js';
6
+ import useI18n from '../../../lib/hooks/useI18n.js';
7
+ import { isInCMCC } from '../../../lib/isInCMCC.js';
6
8
  import EmptyField from '../../common/EmptyField.js';
7
9
  import { tooltipOverflowStyle, getTooltipMaxlineStyle } from '../../common/overflow-tooltip/style/index.js';
8
10
  import { useToWorkspacePage } from './hooks.js';
9
11
  import { pointerStyle } from './style/index.js';
10
12
  import ValueDisplay from './ValueDisplay.js';
11
13
 
14
+ const inCMCC = isInCMCC();
12
15
  const BindWorkspaceReadView = memo(props => {
13
16
  const { value: _value, mode } = props;
17
+ const { t } = useI18n();
14
18
  const { toWorkspacePage } = useToWorkspacePage();
15
19
  const value = useCreation(() => getArrayValue(_value), [_value]);
20
+ const title = useCreation(() => (inCMCC ? '' : t('pages.fields.default.toWorkspacePage')), [t]);
16
21
  return (jsx(ClassNames, { children: ({ cx, css }) => {
17
22
  if (!(value === null || value === void 0 ? void 0 : value.length))
18
23
  return jsx(EmptyField, { readonly: true });
19
- return (jsx(ValueDisplay, { mode: mode, value: value, wrapperClassName: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(1))), itemClassName: cx(css(pointerStyle)), onClick: toWorkspacePage }));
24
+ return (jsx(ValueDisplay, { title: title, mode: mode, value: value, wrapperClassName: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(1))), itemClassName: cx(css(pointerStyle)), onClick: toWorkspacePage }));
20
25
  } }));
21
26
  });
22
27
  BindWorkspaceReadView.displayName = 'BindWorkspaceReadView';
@@ -1,4 +1,5 @@
1
1
  interface ValueDisplayBaseProps {
2
+ title?: string;
2
3
  value: any[];
3
4
  onClick?: (workspaceKey: string) => void;
4
5
  wrapperClassName?: string;
@@ -2,20 +2,17 @@ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
2
2
  import { memo, Fragment } from 'react';
3
3
  import OverflowTooltip from '../../common/overflow-tooltip/OverflowTooltip.js';
4
4
  import { getArrayValue } from '../../../lib/array.js';
5
- import useI18n from '../../../lib/hooks/useI18n.js';
6
5
 
7
6
  const WorkspaceLabel = memo(props => {
8
7
  const { title, onClick, className, workspace } = props;
9
8
  const { key, name } = workspace;
10
9
  return (jsx("span", { title: title, onClick: () => onClick(key), className: className, children: name }));
11
10
  });
12
- const SingleValueDisplay = memo(({ value, onClick, wrapperClassName, itemClassName }) => {
13
- const { t } = useI18n();
11
+ const SingleValueDisplay = memo(({ value, onClick, wrapperClassName, itemClassName, title }) => {
14
12
  const [workspace] = getArrayValue(value);
15
- return (jsx(WorkspaceLabel, { title: t('pages.fields.default.toWorkspacePage'), onClick: onClick, className: `${wrapperClassName} ${itemClassName} single`, workspace: workspace }));
13
+ return (jsx(WorkspaceLabel, { title: title, onClick: onClick, className: `${wrapperClassName} ${itemClassName} single`, workspace: workspace }));
16
14
  });
17
- const MultipleValueDisplay = memo(({ value, onClick, itemClassName }) => {
18
- const { t } = useI18n();
15
+ const MultipleValueDisplay = memo(({ value, onClick, itemClassName, title }) => {
19
16
  const showValue = value
20
17
  .map(workspace => workspace === null || workspace === void 0 ? void 0 : workspace.name)
21
18
  .filter(Boolean)
@@ -23,7 +20,7 @@ const MultipleValueDisplay = memo(({ value, onClick, itemClassName }) => {
23
20
  if (!showValue)
24
21
  return null;
25
22
  return (jsx(OverflowTooltip, { title: value.map((workspace, index) => {
26
- return (jsxs(Fragment, { children: [jsx(WorkspaceLabel, { title: t('pages.fields.default.toWorkspacePage'), onClick: onClick, className: itemClassName, workspace: workspace }), index !== value.length - 1 && ','] }, workspace.key));
23
+ return (jsxs(Fragment, { children: [jsx(WorkspaceLabel, { title: title, onClick: onClick, className: itemClassName, workspace: workspace }), index !== value.length - 1 && ','] }, workspace.key));
27
24
  }), enterable: true, alwaysShowTooltip: true, children: showValue }));
28
25
  });
29
26
  MultipleValueDisplay.displayName = 'MultipleValueDisplay';
@@ -1,13 +1,17 @@
1
1
  import { useMemoizedFn } from 'ahooks';
2
2
  import useTeamConfig from '../../../lib/hooks/useTeamConfig.js';
3
3
  import useTenant from '../../../lib/hooks/useTenant.js';
4
+ import { isInCMCC } from '../../../lib/isInCMCC.js';
4
5
  import isInOne from '../../../lib/isInOne.js';
5
6
 
6
7
  const useToWorkspacePage = () => {
7
8
  const { publicRuntimeConfig, isMicroApp } = useTeamConfig();
8
9
  const inOne = isInOne(publicRuntimeConfig.gateway, isMicroApp);
10
+ const inCmcc = isInCMCC(publicRuntimeConfig);
9
11
  const tenant = useTenant();
10
12
  const toWorkspacePage = useMemoizedFn((workspaceKey) => {
13
+ if (inCmcc)
14
+ return;
11
15
  const url = inOne
12
16
  ? `/${tenant}/${workspaceKey}`
13
17
  : `${publicRuntimeConfig.basePath}/${tenant}/workspaces/${workspaceKey}`;
@@ -0,0 +1,3 @@
1
+ type ENV = 'one' | 'cmcc' | 'demo' | 'test' | 'prod';
2
+ export declare const mockENV: ENV;
3
+ export {};
@@ -0,0 +1,5 @@
1
+ import { getLocalStorageItem } from './storage.js';
2
+
3
+ const mockENV = getLocalStorageItem('mockENV');
4
+
5
+ export { mockENV };
@@ -0,0 +1 @@
1
+ export declare const isInCMCC: (config?: Record<string, any>) => boolean;
@@ -0,0 +1,10 @@
1
+ import { mockENV } from './env.js';
2
+
3
+ const isInCMCC = (config) => {
4
+ const { routePath } = config || {};
5
+ if (mockENV === 'cmcc')
6
+ return true;
7
+ return !!routePath;
8
+ };
9
+
10
+ export { isInCMCC };
@@ -1,4 +1,8 @@
1
+ import { mockENV } from './env.js';
2
+
1
3
  const isInOne = (gateway, isMicroApp) => {
4
+ if (mockENV === 'one')
5
+ return true;
2
6
  if (isMicroApp != null)
3
7
  return !!isMicroApp;
4
8
  if (!gateway)
@@ -1,8 +1,8 @@
1
- export declare const getLocalStorageItem: (key: string, defaults?: any) => any;
1
+ export declare const getLocalStorageItem: <T = any>(key: string, defaults?: any) => T;
2
2
  export declare const setLocalStorageItem: (key: string, value: unknown) => boolean;
3
3
  export declare const removeParseItems: () => void;
4
4
  declare const _default: {
5
- getItem: (key: string, defaults?: any) => any;
5
+ getItem: <T = any>(key: string, defaults?: any) => T;
6
6
  setItem: (key: string, value: unknown) => boolean;
7
7
  removeParseItems: () => void;
8
8
  };
@@ -18,6 +18,7 @@ export declare const blue7 = "var(--color-brand-7, #0045d9)";
18
18
  export declare const blue8 = "var(--color-brand-8, #0033b3)";
19
19
  export declare const blue9 = "var(--color-brand-9, #00238c)";
20
20
  export declare const blue10 = "var(--color-brand-10, #001666)";
21
+ export declare const green4 = "var(--color-success-4, #4DD18B)";
21
22
  export declare const green5 = "var(--color-success-5, #29c477)";
22
23
  export declare const orange4 = "var(--color-orange-4, #ffd15e)";
23
24
  export declare const orange5 = "var(--color-orange-5, #ffbf36)";
@@ -18,6 +18,7 @@ const blue7 = 'var(--color-brand-7, #0045d9)';
18
18
  const blue8 = 'var(--color-brand-8, #0033b3)';
19
19
  const blue9 = 'var(--color-brand-9, #00238c)';
20
20
  const blue10 = 'var(--color-brand-10, #001666)';
21
+ const green4 = 'var(--color-success-4, #4DD18B)';
21
22
  const green5 = 'var(--color-success-5, #29c477)';
22
23
  const orange4 = 'var(--color-orange-4, #ffd15e)';
23
24
  const orange5 = 'var(--color-orange-5, #ffbf36)';
@@ -34,4 +35,4 @@ const randomClassName = (name) => {
34
35
  return `${name}_${result}`;
35
36
  };
36
37
 
37
- export { blue1, blue10, blue2, blue3, blue4, blue5, blue6, blue7, blue8, blue9, fieldLabelColor, gray1, gray10, gray2, gray3, gray4, gray5, gray6, gray7, gray8, gray9, green5, orange4, orange5, randomClassName, statusCellMinWidth, themeBgColorBase };
38
+ export { blue1, blue10, blue2, blue3, blue4, blue5, blue6, blue7, blue8, blue9, fieldLabelColor, gray1, gray10, gray2, gray3, gray4, gray5, gray6, gray7, gray8, gray9, green4, green5, orange4, orange5, randomClassName, statusCellMinWidth, themeBgColorBase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",