@giteeteam/apps-team-components 1.3.0-alpha.2 → 1.3.0
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
CHANGED
|
@@ -52,6 +52,7 @@ const Dropdown = props => {
|
|
|
52
52
|
const valueRef = useRef([]);
|
|
53
53
|
const containerRef = useRef(null);
|
|
54
54
|
const targetRef = useRef(null);
|
|
55
|
+
const onBlurRef = useRef({ time: 0, e: null });
|
|
55
56
|
const [isClicked, setClicked] = useState(false);
|
|
56
57
|
const optionLoadedRef = useRef(false);
|
|
57
58
|
const loadMoreRef = useRef(false);
|
|
@@ -430,6 +431,7 @@ const Dropdown = props => {
|
|
|
430
431
|
const handleBlur = useCallback(e => {
|
|
431
432
|
var _a;
|
|
432
433
|
if (open) {
|
|
434
|
+
onBlurRef.current = { time: Date.now(), e: e };
|
|
433
435
|
return;
|
|
434
436
|
}
|
|
435
437
|
if (!editMode) {
|
|
@@ -497,6 +499,15 @@ const Dropdown = props => {
|
|
|
497
499
|
});
|
|
498
500
|
}
|
|
499
501
|
}, [isMultiple]);
|
|
502
|
+
useEffect(() => {
|
|
503
|
+
if (!open) {
|
|
504
|
+
const now = Date.now();
|
|
505
|
+
if (now > onBlurRef.current.time && now - onBlurRef.current.time < 200) {
|
|
506
|
+
handleBlur(onBlurRef.current.e);
|
|
507
|
+
onBlurRef.current.time = 0;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}, [handleBlur, open]);
|
|
500
511
|
const dropdownRender = useCallback(({ cx, css }) => {
|
|
501
512
|
return menu => {
|
|
502
513
|
if (!isShowOnlyWorkspace)
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { memo } from 'react';
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
3
|
import { omit } from 'lodash-es';
|
|
4
|
+
import { FIELD_TYPE_KEY_MAPPINGS } from '../../lib/global.js';
|
|
4
5
|
|
|
5
|
-
const EditTableCell = ({ overlayClsName, itemTypeId, workspaceId, readonly, id, objectId, property, text, Component, dataSource, handleChange, }) => {
|
|
6
|
-
const commonProps = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
const EditTableCell = ({ overlayClsName, itemTypeId, workspaceId, readonly, id, objectId, property, text, Component, dataSource, data, type, handleChange, }) => {
|
|
7
|
+
const commonProps = useMemo(() => {
|
|
8
|
+
const commonProps = {
|
|
9
|
+
overlayClsName,
|
|
10
|
+
itemTypeId,
|
|
11
|
+
workspaceId,
|
|
12
|
+
readonly: !!readonly,
|
|
13
|
+
itemId: id,
|
|
14
|
+
objectId,
|
|
15
|
+
value: text,
|
|
16
|
+
dataSource,
|
|
17
|
+
...omit(property, 'defaultValue'),
|
|
18
|
+
};
|
|
19
|
+
if ([
|
|
20
|
+
FIELD_TYPE_KEY_MAPPINGS.Dropdown,
|
|
21
|
+
FIELD_TYPE_KEY_MAPPINGS.Tree,
|
|
22
|
+
FIELD_TYPE_KEY_MAPPINGS.Checkbox,
|
|
23
|
+
FIELD_TYPE_KEY_MAPPINGS.Radio,
|
|
24
|
+
FIELD_TYPE_KEY_MAPPINGS.Priority,
|
|
25
|
+
FIELD_TYPE_KEY_MAPPINGS.UserGroup,
|
|
26
|
+
].includes(type)) {
|
|
27
|
+
commonProps.options = (data === null || data === void 0 ? void 0 : data.customData) || [];
|
|
28
|
+
}
|
|
29
|
+
commonProps.userData = data || [];
|
|
30
|
+
if (type === FIELD_TYPE_KEY_MAPPINGS.LongText) {
|
|
31
|
+
commonProps.maxRows = 1;
|
|
32
|
+
commonProps.minRows = 1;
|
|
33
|
+
}
|
|
34
|
+
return commonProps;
|
|
35
|
+
}, [data, dataSource, id, itemTypeId, objectId, overlayClsName, property, readonly, text, type, workspaceId]);
|
|
17
36
|
return jsx(Component, { ...commonProps, onChange: handleChange });
|
|
18
37
|
};
|
|
19
38
|
var EditTableCell$1 = memo(EditTableCell);
|
|
@@ -53,7 +53,7 @@ const BaseTableCell = ({ className, cellData, column, rowData, readComponents =
|
|
|
53
53
|
}, [editComponents]);
|
|
54
54
|
if (cellEntered && EditComponent) {
|
|
55
55
|
const { property, data, objectId } = column;
|
|
56
|
-
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, handleChange: handleChange, dataSource: column.dataSource }) }));
|
|
56
|
+
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
57
|
}
|
|
58
58
|
if (ReadComponent) {
|
|
59
59
|
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 }) }));
|