@giteeteam/apps-team-components 1.1.1-alpha.1 → 1.1.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.
@@ -2,6 +2,7 @@
2
2
  import { ReadViewBaseProps } from '../types';
3
3
  type DropdownReadViewProps = ReadViewBaseProps & {
4
4
  userData?: Record<string, any>;
5
+ mode?: string;
5
6
  };
6
7
  declare const DropdownReadView: import("react").NamedExoticComponent<DropdownReadViewProps>;
7
8
  export default DropdownReadView;
@@ -3,11 +3,16 @@ import { memo, useMemo } from 'react';
3
3
  import EmptyField from '../../common/EmptyField';
4
4
  import SimpleOverflowToolTip from '../../common/overflow-tooltip/SimpleOverflowToolTip';
5
5
  import { handleValue } from './BaseField';
6
+ var MUTIPLE_MODE;
7
+ (function (MUTIPLE_MODE) {
8
+ MUTIPLE_MODE["multiple"] = "multiple";
9
+ MUTIPLE_MODE["tags"] = "tags";
10
+ })(MUTIPLE_MODE || (MUTIPLE_MODE = {}));
6
11
  const getFormattedLabel = ({ label, style = {}, }) => {
7
12
  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 });
8
13
  };
9
14
  const DropdownReadView = memo(props => {
10
- const { value, options, readonly: propsReadonly, userData } = props;
15
+ const { value, options, readonly: propsReadonly, userData, mode } = props;
11
16
  const readonly = useMemo(() => {
12
17
  if ((userData === null || userData === void 0 ? void 0 : userData.source) === 'apps-function') {
13
18
  return (userData === null || userData === void 0 ? void 0 : userData.readonly) || propsReadonly;
@@ -16,44 +21,42 @@ const DropdownReadView = memo(props => {
16
21
  return propsReadonly;
17
22
  }
18
23
  }, [propsReadonly, userData]);
19
- const showValueTitle = useMemo(() => {
20
- var _a;
21
- if (!(value === null || value === void 0 ? void 0 : value.length))
22
- return '';
23
- if ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.label) {
24
- return value.map(item => item.label).join(',');
25
- }
26
- if (!(options === null || options === void 0 ? void 0 : options.length))
27
- return '';
28
- const result = value
29
- .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); })
30
- .filter(Boolean)
31
- .join(',');
32
- return result;
33
- }, [options, value]);
34
- const showValue = useMemo(() => {
35
- var _a;
36
- if (!(value === null || value === void 0 ? void 0 : value.length))
37
- return '';
38
- if ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.label) {
39
- return value.map(item => item.label).join(',');
40
- }
41
- if (!(options === null || options === void 0 ? void 0 : options.length))
42
- return '';
24
+ const optionsMap = useMemo(() => {
43
25
  const optionsMap = {};
44
26
  options === null || options === void 0 ? void 0 : options.forEach(item => {
45
27
  optionsMap[item.label] = item;
46
28
  });
47
- const result = value
48
- .map(item => { var _a; return (item === null || item === void 0 ? void 0 : item.label) || ((_a = options.find(opt => opt.value === handleValue(item))) === null || _a === void 0 ? void 0 : _a.label); })
49
- .filter(Boolean)
50
- .map((item, index) => {
51
- const content = getFormattedLabel(optionsMap[item]);
52
- return index === value.length - 1 ? content : _jsxs(_Fragment, { children: [content, ","] });
53
- });
54
- return result;
55
- }, [options, value]);
56
- return (_jsx(_Fragment, { children: showValue ? (_jsx(SimpleOverflowToolTip, { title: showValueTitle, children: showValue })) : (_jsx(EmptyField, { readonly: readonly })) }));
29
+ return optionsMap;
30
+ }, [options]);
31
+ const showValue = useMemo(() => {
32
+ var _a, _b;
33
+ if (!(value === null || value === void 0 ? void 0 : value.length))
34
+ return '';
35
+ if (mode in MUTIPLE_MODE) {
36
+ if ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.label) {
37
+ return value.map(item => item.label).join(',');
38
+ }
39
+ if (!(options === null || options === void 0 ? void 0 : options.length))
40
+ return '';
41
+ return value
42
+ .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); })
43
+ .filter(Boolean)
44
+ .map((item, index) => {
45
+ const content = getFormattedLabel(optionsMap[item]);
46
+ return index === value.length - 1 ? content : _jsxs(_Fragment, { children: [content, ","] });
47
+ });
48
+ }
49
+ else {
50
+ const item = value[0];
51
+ if (item.label)
52
+ return item.label;
53
+ if (!(options === null || options === void 0 ? void 0 : options.length))
54
+ return '';
55
+ const label = (item === null || item === void 0 ? void 0 : item.label) || ((_b = options.find(opt => opt.value === handleValue(item))) === null || _b === void 0 ? void 0 : _b.label);
56
+ return getFormattedLabel(optionsMap[label]);
57
+ }
58
+ }, [mode, options, optionsMap, value]);
59
+ return (_jsx(_Fragment, { children: showValue ? (_jsx(SimpleOverflowToolTip, { title: showValue, children: showValue })) : (_jsx(EmptyField, { readonly: readonly })) }));
57
60
  });
58
61
  DropdownReadView.displayName = 'DropdownReadView';
59
62
  export default DropdownReadView;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.1.1-alpha.1",
3
+ "version": "1.1.1",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "scripts": {
8
8
  "prepare": "husky install && pnpm build",
9
9
  "build": "rm -rf dist && tsc && cp -r src/icons/svg dist/icons/svg",
10
- "publish:alpha": "pnpm prepublish && npm publish --tag alpha",
10
+ "publish:alpha": "npm publish --tag alpha",
11
11
  "prepack": "pnpm build",
12
12
  "prepublish": "pnpm build",
13
13
  "prepublishOnly": "pnpm build",