@giteeteam/apps-team-components 1.11.0 → 1.11.1-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.
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { SelectProps } from 'antd';
3
+ import { Priority as PriorityProps } from '../../../lib/types/models';
4
+ interface CellProps {
5
+ apply?: string;
6
+ readonly?: boolean;
7
+ value?: string;
8
+ overlayClsName?: string;
9
+ onChange?: (value?: string) => void;
10
+ options?: PriorityProps[];
11
+ page?: string;
12
+ }
13
+ declare const PriorityCell: React.FC<CellProps & SelectProps<any>>;
14
+ export default PriorityCell;
@@ -0,0 +1,58 @@
1
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
2
+ import { useState, useMemo, useEffect, useCallback } from 'react';
3
+ import { CaretDownOutlined } from '@ant-design/icons';
4
+ import { css, ClassNames } from '@emotion/react';
5
+ import { Menu, Dropdown } from 'antd';
6
+ import { HollowCircleIcon, DottedCircleIcon } from '../../../icons/index.js';
7
+ import useAntdConfig from '../../../lib/hooks/useAntdConfig.js';
8
+ import useI18n from '../../../lib/hooks/useI18n.js';
9
+ import EmptyField from '../../common/EmptyField.js';
10
+ import BaseOverflowTooltip from '../../common/overflow-tooltip/BaseOverflowTooltip.js';
11
+ import { getPopupContainerFun } from '../../common/utils.js';
12
+ import { menuBoxStyle, cellBoxStyle, checkedStyle, colorIconStyle, emptyTipStyle, dropdownStyle, headerCellStyle, downIconStyle, emptyTextStyle, emptyStyle, emptyIconStyle } from './style/index.js';
13
+
14
+ const filterData = (list, id) => {
15
+ return list === null || list === void 0 ? void 0 : list.filter(v => {
16
+ return v.key === id;
17
+ });
18
+ };
19
+ const EMPTY_OPTIONS = [];
20
+ const PriorityCell = props => {
21
+ var _a;
22
+ const { t } = useI18n();
23
+ const { antPrefix } = useAntdConfig();
24
+ const { apply, value, readonly, onChange, options = EMPTY_OPTIONS, getPopupContainer, page, } = props;
25
+ const [showData, setShowData] = useState((_a = filterData(options, value)) === null || _a === void 0 ? void 0 : _a[0]);
26
+ const [visible, setVisible] = useState(false);
27
+ const isFromHeader = useMemo(() => apply === 'header', [apply]);
28
+ useEffect(() => {
29
+ var _a;
30
+ setShowData((_a = filterData(options, value)) === null || _a === void 0 ? void 0 : _a[0]);
31
+ }, [value, options]);
32
+ const changeValue = useCallback(_value => {
33
+ var _a;
34
+ onChange === null || onChange === void 0 ? void 0 : onChange(_value);
35
+ setShowData((_a = filterData(options, _value)) === null || _a === void 0 ? void 0 : _a[0]);
36
+ }, [onChange, options]);
37
+ const handleChange = useCallback(({ key }) => {
38
+ if (key !== value) {
39
+ changeValue(key);
40
+ }
41
+ setVisible(false);
42
+ }, [changeValue, value]);
43
+ const menu = useMemo(() => {
44
+ return (jsx(Menu, { onClick: handleChange, css: css(menuBoxStyle), children: options.length ? (options.map(v => {
45
+ return (jsxs(Menu.Item, { css: css(cellBoxStyle(antPrefix), v.key === value && checkedStyle), children: [jsx(HollowCircleIcon, { css: css(colorIconStyle), style: { color: v.color } }), jsx(BaseOverflowTooltip, { title: v.name, children: v.name })] }, v.key));
46
+ })) : (jsx("div", { onClick: () => {
47
+ setVisible(false);
48
+ }, css: css(emptyTipStyle), children: t('pages.fields.view.emptyPriority') })) }));
49
+ }, [options, handleChange, value, t, antPrefix]);
50
+ return (jsx(ClassNames, { children: ({ cx, css: cssFn }) => (jsx(Dropdown, { destroyPopupOnHide: true, overlayClassName: cx(cssFn(dropdownStyle)), dropdownRender: () => menu, trigger: ['click'], onOpenChange: flag => {
51
+ if (readonly)
52
+ return;
53
+ setVisible(flag);
54
+ }, open: visible, getPopupContainer: triggerNode => getPopupContainerFun(getPopupContainer, triggerNode, apply, page), children: showData ? (jsxs("div", { css: css(cellBoxStyle(antPrefix), isFromHeader && headerCellStyle), children: [jsx(HollowCircleIcon, { css: css(colorIconStyle), style: { color: showData.color } }), jsx(BaseOverflowTooltip, { title: showData.name, children: showData.name }), isFromHeader && jsx(CaretDownOutlined, { css: css(downIconStyle) })] })) : !isFromHeader ? (jsx("div", { css: css(emptyTextStyle), children: jsx(EmptyField, { readonly: readonly }) })) : (jsxs("div", { css: css(emptyStyle), children: [jsx(DottedCircleIcon, { css: css(emptyIconStyle) }), t('pages.fields.view.noPriority')] })) })) }));
55
+ };
56
+ PriorityCell.displayName = 'ActionPriorityCell';
57
+
58
+ export { PriorityCell as default };
@@ -5,3 +5,9 @@ export declare const colorIconStyle = "\n margin-right: 5px;\n font-size: 12px
5
5
  export declare const emptyStyle = "\n color: #909aaa;\n";
6
6
  export declare const emptyIconStyle = "\n margin-right: 5px;\n font-size: 12px!important;\n width: 12px!important;\n margin-left: 0!important;\n";
7
7
  export declare const downIconStyle = "\n margin-left: 2px;\n\n svg {\n vertical-align: inherit;\n }\n";
8
+ export declare const emptyTipStyle = "\n padding-left: 15px;\n color: #909aaa;\n";
9
+ export declare const checkedStyle = "\n background-color: var(--select-item-selected-bg);\n";
10
+ export declare const iconStyle = "\n padding-left: 3px;\n color: var(--theme-text-color-secondary);\n";
11
+ export declare const spinStyle = "\n width: 150px;\n height: 50px;\n line-height: 60px;\n";
12
+ export declare const menuBoxStyle = "\n max-height: 300px;\n overflow: auto;\n";
13
+ export declare const dropdownStyle = "\n background: var(--color-gray-1, #FFFFFF);\n\n .menu-box {\n max-height: 300px;\n overflow: auto;\n }\n";
@@ -1,4 +1,4 @@
1
- import { gray9, gray3, fieldLabelColor } from '../../../../style/common.js';
1
+ import { gray9, gray3, fieldLabelColor, gray1 } from '../../../../style/common.js';
2
2
 
3
3
  const cellBoxStyle = (antPrefix) => `
4
4
  display: flex;
@@ -57,5 +57,33 @@ const downIconStyle = `
57
57
  vertical-align: inherit;
58
58
  }
59
59
  `;
60
+ const emptyTipStyle = `
61
+ padding-left: 15px;
62
+ color: ${fieldLabelColor};
63
+ `;
64
+ const checkedStyle = `
65
+ background-color: var(--select-item-selected-bg);
66
+ `;
67
+ const iconStyle = `
68
+ padding-left: 3px;
69
+ color: var(--theme-text-color-secondary);
70
+ `;
71
+ const spinStyle = `
72
+ width: 150px;
73
+ height: 50px;
74
+ line-height: 60px;
75
+ `;
76
+ const menuBoxStyle = `
77
+ max-height: 300px;
78
+ overflow: auto;
79
+ `;
80
+ const dropdownStyle = `
81
+ background: ${gray1};
82
+
83
+ .menu-box {
84
+ max-height: 300px;
85
+ overflow: auto;
86
+ }
87
+ `;
60
88
 
61
- export { cellBoxStyle, colorIconStyle, downIconStyle, emptyIconStyle, emptyStyle, emptyTextStyle, headerCellStyle };
89
+ export { cellBoxStyle, checkedStyle, colorIconStyle, downIconStyle, dropdownStyle, emptyIconStyle, emptyStyle, emptyTextStyle, emptyTipStyle, headerCellStyle, iconStyle, menuBoxStyle, spinStyle };
@@ -54,7 +54,7 @@ const BaseTableCell = ({ className, cellData, column, rowData, readComponents =
54
54
  }, [editComponents]);
55
55
  if (cellEntered && EditComponent) {
56
56
  const { property, data, objectId } = column;
57
- return (jsx("div", { className: cls, children: jsx(EditTableCell, { Component: EditComponent, workspaceId: (_a = rowData.workspace) === null || _a === void 0 ? void 0 : _a.objectId, itemTypeId: (_b = rowData.itemType) === null || _b === void 0 ? void 0 : _b.objectId, property: property, data: data, id: rowData.objectId, readonly: readonly, objectId: objectId, text: cellData, type: column.componentType, handleChange: handleChange, dataSource: column.dataSource }) }));
57
+ return (jsx("div", { className: cls, children: jsx(EditTableCell, { Component: EditComponent, workspaceId: (_a = rowData.workspace) === null || _a === void 0 ? void 0 : _a.objectId, itemTypeId: (_b = rowData.itemType) === null || _b === void 0 ? void 0 : _b.objectId, property: property, data: data, id: rowData.objectId, readonly: readonly, objectId: objectId, text: cellData, type: column.componentType || column.cellType, handleChange: handleChange, dataSource: column.dataSource }) }));
58
58
  }
59
59
  if (ReadComponent) {
60
60
  return (jsx("div", { className: cls, onMouseOver: handleMouseOver, children: jsx(ReadComponent, { readonly: readonly, value: cellData, ...column.property, userData: column.data, options: ((_c = column.data) === null || _c === void 0 ? void 0 : _c.customData) || EMPTY_ARRAY, itemValues: rowData, objectId: column.objectId, dataSource: column.dataSource, fieldKey: fieldKey, isReadingTableCell: column.isReadingList, noPadding: column.noPadding }) }));
@@ -21,6 +21,7 @@ import ItemTypeReadView from '../fields/item-type/ReadView.js';
21
21
  import KeyReadView from '../fields/key/ReadView.js';
22
22
  import LongTextReadView from '../fields/long-text/ReadView.js';
23
23
  import NumberReadView from '../fields/number/ReadView.js';
24
+ import PriorityCell from '../fields/priority/ActionCell.js';
24
25
  import PriorityReadView from '../fields/priority/ReadView.js';
25
26
  import RadioReadView from '../fields/radio/ReadView.js';
26
27
  import RepoFileReadView from '../fields/repo-files/ReadView.js';
@@ -97,6 +98,7 @@ const getStandardEditComponents = () => {
97
98
  return {
98
99
  [FIELD_TYPE_KEY_MAPPINGS.Status]: StatusCell,
99
100
  [FIELD_TYPE_KEY_MAPPINGS.Dropdown]: DropdownCell,
101
+ [FIELD_TYPE_KEY_MAPPINGS.Priority]: PriorityCell,
100
102
  };
101
103
  };
102
104
 
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export { default as ItemTypeReadView } from './components/fields/item-type/ReadV
23
23
  export { default as KeyReadView } from './components/fields/key/ReadView';
24
24
  export { default as LongTextReadView } from './components/fields/long-text/ReadView';
25
25
  export { default as NumberReadView } from './components/fields/number/ReadView';
26
+ export { default as Priority } from './components/fields/priority/ActionCell';
26
27
  export { default as PriorityReadView } from './components/fields/priority/ReadView';
27
28
  export { default as RadioReadView } from './components/fields/radio/ReadView';
28
29
  export { default as RepoFileReadView } from './components/fields/repo-files/ReadView';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export { default as ItemTypeReadView } from './components/fields/item-type/ReadV
23
23
  export { default as KeyReadView } from './components/fields/key/ReadView.js';
24
24
  export { default as LongTextReadView } from './components/fields/long-text/ReadView.js';
25
25
  export { default as NumberReadView } from './components/fields/number/ReadView.js';
26
+ export { default as Priority } from './components/fields/priority/ActionCell.js';
26
27
  export { default as PriorityReadView } from './components/fields/priority/ReadView.js';
27
28
  export { default as RadioReadView } from './components/fields/radio/ReadView.js';
28
29
  export { default as RepoFileReadView } from './components/fields/repo-files/ReadView.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.11.0",
3
+ "version": "1.11.1-alpha.1",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",