@giteeteam/apps-team-components 1.11.3 → 1.11.4
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/dist/components/common/expand-component/index.d.ts +1 -1
- package/dist/components/common/utils.d.ts +4 -0
- package/dist/components/common/utils.js +17 -1
- package/dist/components/fields/base-component/types.d.ts +42 -1
- package/dist/components/fields/base-component/utils.d.ts +1 -1
- package/dist/components/fields/base-component/utils.js +4 -1
- package/dist/components/fields/text/BaseField.d.ts +4 -0
- package/dist/components/fields/text/BaseField.js +78 -0
- package/dist/components/fields/text/Cell.d.ts +18 -0
- package/dist/components/fields/text/Cell.js +10 -0
- package/dist/components/fields/text/style.d.ts +2 -0
- package/dist/components/fields/text/style.js +12 -0
- package/dist/components/table-components/utils.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -8,4 +8,8 @@ type GetCondition = (dom: HTMLElement, className: string) => boolean;
|
|
|
8
8
|
export declare const getParentEle: (dom: HTMLElement, className: string, conditionFunc?: GetCondition) => HTMLElement;
|
|
9
9
|
export declare const getPopupContainerFun: (getPopupContainer: (node?: HTMLElement) => HTMLElement, triggerNode: HTMLElement, apply: string, page?: string) => HTMLElement;
|
|
10
10
|
export declare const isChinese: (text: string) => boolean;
|
|
11
|
+
export declare const REG_REGEXP: RegExp;
|
|
12
|
+
export declare const isRegExp: (expression: string) => boolean;
|
|
13
|
+
export declare const toRegExp: (expression: string) => RegExp;
|
|
14
|
+
export declare const isPropsEqual: <T = any>(prevProps: T, nextProps: T) => boolean;
|
|
11
15
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { omit, isEqual } from 'lodash-es';
|
|
1
2
|
import '../../lib/dayjs.js';
|
|
2
3
|
import { DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC } from '../../lib/global.js';
|
|
3
4
|
import { blue4, green4, orange4 } from '../../style/common.js';
|
|
@@ -91,5 +92,20 @@ const getPopupContainerFun = (getPopupContainer, triggerNode, apply, page) => {
|
|
|
91
92
|
};
|
|
92
93
|
const zhReg = /[\u4e00-\u9fa5]/g;
|
|
93
94
|
const isChinese = (text) => zhReg.test(text);
|
|
95
|
+
const REG_REGEXP = /^\/.+\/$/;
|
|
96
|
+
const isRegExp = (expression) => new RegExp(REG_REGEXP).test(expression);
|
|
97
|
+
const toRegExp = (expression) => {
|
|
98
|
+
if (!expression) {
|
|
99
|
+
return new RegExp(null);
|
|
100
|
+
}
|
|
101
|
+
const sliceExpression = expression.slice(1, expression.length - 1);
|
|
102
|
+
const reg = new RegExp(sliceExpression);
|
|
103
|
+
return reg;
|
|
104
|
+
};
|
|
105
|
+
const isPropsEqual = (prevProps, nextProps) => {
|
|
106
|
+
const prev = omit(prevProps, ['onChange']);
|
|
107
|
+
const next = omit(nextProps, ['onChange']);
|
|
108
|
+
return isEqual(prev, next);
|
|
109
|
+
};
|
|
94
110
|
|
|
95
|
-
export { dateFormat, defaultFilterOptions, getBackgroundColor, getNameBadge, getParentEle, getPopupContainerFun, isChinese };
|
|
111
|
+
export { REG_REGEXP, dateFormat, defaultFilterOptions, getBackgroundColor, getNameBadge, getParentEle, getPopupContainerFun, isChinese, isPropsEqual, isRegExp, toRegExp };
|
|
@@ -2,7 +2,48 @@ export interface CellProps {
|
|
|
2
2
|
overlayClsName?: string;
|
|
3
3
|
workspaceId?: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export declare const SCREEN_TYPE: {
|
|
6
|
+
readonly View: "view";
|
|
7
|
+
readonly Create: "create";
|
|
8
|
+
readonly Edit: "edit";
|
|
9
|
+
};
|
|
10
|
+
export type VALUE_OF_SCREEN_TYPE = (typeof SCREEN_TYPE)[keyof typeof SCREEN_TYPE];
|
|
11
|
+
export type ReadViewBaseProps = {
|
|
12
|
+
value: any;
|
|
13
|
+
options?: any[];
|
|
14
|
+
itemValues?: any;
|
|
6
15
|
readonly?: boolean;
|
|
16
|
+
};
|
|
17
|
+
interface RegularProps {
|
|
18
|
+
message?: string;
|
|
19
|
+
expression?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface GroupConfig {
|
|
22
|
+
groupName: string[];
|
|
23
|
+
handleGroup?: (item?: any) => string;
|
|
24
|
+
}
|
|
25
|
+
export interface FieldProps extends ReadViewBaseProps {
|
|
26
|
+
screenMode?: VALUE_OF_SCREEN_TYPE;
|
|
27
|
+
editMode?: boolean;
|
|
28
|
+
name?: string;
|
|
29
|
+
page?: any;
|
|
30
|
+
labelAlign?: IScreenLabelProps;
|
|
31
|
+
labelWidth?: number;
|
|
32
|
+
hiddenLabel?: boolean;
|
|
33
|
+
readonly?: boolean;
|
|
34
|
+
apply?: string;
|
|
35
|
+
validation?: RegularProps;
|
|
36
|
+
userData?: Record<string, any>;
|
|
37
|
+
searchComponent?: boolean;
|
|
38
|
+
allowNull?: boolean;
|
|
39
|
+
isGroup?: boolean;
|
|
40
|
+
groupConfig?: GroupConfig;
|
|
41
|
+
onGroupFetch?: (key: string) => any;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
itemId?: string;
|
|
44
|
+
fieldKey?: string;
|
|
45
|
+
extraNode?: React.ReactNode;
|
|
46
|
+
hasExtraNode?: boolean;
|
|
7
47
|
}
|
|
8
48
|
export type IScreenLabelProps = 'left' | 'right' | 'top';
|
|
49
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IScreenLabelProps } from './types';
|
|
2
|
-
export declare const getFieldWidthStyle: (labelWidth: number, labelAlign: IScreenLabelProps, hiddenLabel: boolean, apply: string) => any;
|
|
2
|
+
export declare const getFieldWidthStyle: (labelWidth: number, labelAlign: IScreenLabelProps, hiddenLabel: boolean, apply: string, hasExtraNode?: boolean) => any;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
const getFieldWidthStyle = (labelWidth, labelAlign, hiddenLabel, apply) => {
|
|
1
|
+
const getFieldWidthStyle = (labelWidth, labelAlign, hiddenLabel, apply, hasExtraNode = false) => {
|
|
2
2
|
if (hiddenLabel) {
|
|
3
3
|
labelWidth = 0;
|
|
4
4
|
}
|
|
5
|
+
if (hasExtraNode) {
|
|
6
|
+
return { flex: 1 };
|
|
7
|
+
}
|
|
5
8
|
if (apply !== 'cell' && labelAlign !== 'top') {
|
|
6
9
|
return { width: `calc(100% - ${labelWidth}px)` };
|
|
7
10
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { InputProps } from 'antd';
|
|
2
3
|
import type { FieldProps } from '../base-component/types';
|
|
4
|
+
export declare const BASE_FIELD_WIDTH = 104;
|
|
3
5
|
export type BaseFieldProps = InputProps & FieldProps & {
|
|
4
6
|
userData?: any;
|
|
5
7
|
label?: string;
|
|
@@ -13,3 +15,5 @@ export type BaseFieldProps = InputProps & FieldProps & {
|
|
|
13
15
|
searchComponent?: boolean;
|
|
14
16
|
fieldType?: 'longText' | 'text';
|
|
15
17
|
};
|
|
18
|
+
declare const _default: React.NamedExoticComponent<BaseFieldProps>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useEffect, useCallback, memo } from 'react';
|
|
3
|
+
import { Overlay } from 'react-overlays';
|
|
4
|
+
import { ClassNames } from '@emotion/react';
|
|
5
|
+
import { message, Col, Input } from 'antd';
|
|
6
|
+
import { noop } from 'lodash-es';
|
|
7
|
+
import Expand, { EXPAND_TYPE_ENUM } from '../../common/expand-component/index.js';
|
|
8
|
+
import OverflowTooltip from '../../common/overflow-tooltip/OverflowTooltip.js';
|
|
9
|
+
import { isRegExp, toRegExp, isPropsEqual } from '../../common/utils.js';
|
|
10
|
+
import useI18n from '../../../lib/hooks/useI18n.js';
|
|
11
|
+
import EmptyField from '../../common/EmptyField.js';
|
|
12
|
+
import { getFieldWidthStyle } from '../base-component/utils.js';
|
|
13
|
+
import useViewClass from '../hooks/useViewClass.js';
|
|
14
|
+
import { textStyle, hiddenHoverClass } from './style.js';
|
|
15
|
+
|
|
16
|
+
const BASE_FIELD_WIDTH = 104;
|
|
17
|
+
const Text = props => {
|
|
18
|
+
const { t } = useI18n();
|
|
19
|
+
const { readonly = false, placeholder, editMode = false, labelWidth = BASE_FIELD_WIDTH, labelAlign, value: propsValue, onChange = noop, apply, hiddenLabel, addonBefore = '', addonAfter = '', validation = {}, maxline = 1, screenMode, hasExtraNode, ...defaultProps } = props;
|
|
20
|
+
const [editing, setEditing] = useState(false);
|
|
21
|
+
const containerRef = useRef(null);
|
|
22
|
+
const targetRef = useRef(null);
|
|
23
|
+
const [value, setValue] = useState('');
|
|
24
|
+
const { isView, viewClassNames } = useViewClass({ screenMode, readonly, editing });
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setValue(typeof propsValue === 'string' ? propsValue : '');
|
|
27
|
+
}, [propsValue]);
|
|
28
|
+
const handleClick = useCallback(e => {
|
|
29
|
+
if (readonly)
|
|
30
|
+
return;
|
|
31
|
+
if ('tooltip' === e.target.role)
|
|
32
|
+
return;
|
|
33
|
+
setEditing(true);
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
if (!readonly && !editMode) {
|
|
36
|
+
targetRef.current && targetRef.current.focus();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}, [readonly, editMode]);
|
|
40
|
+
const handleBlur = useCallback(e => {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
var _a;
|
|
43
|
+
const value = (_a = e.target.value) === null || _a === void 0 ? void 0 : _a.trim();
|
|
44
|
+
if (!editMode) {
|
|
45
|
+
setEditing(false);
|
|
46
|
+
const { expression, message: expressionMessage } = validation;
|
|
47
|
+
const isExpressionRegExp = isRegExp(expression);
|
|
48
|
+
if (expression && isExpressionRegExp && value) {
|
|
49
|
+
const regExp = toRegExp(expression);
|
|
50
|
+
if (regExp && !regExp.test(value)) {
|
|
51
|
+
message.error(expressionMessage || t('global.error'));
|
|
52
|
+
setValue(propsValue);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, [editMode, onChange, propsValue, validation, t]);
|
|
67
|
+
const handleChange = e => {
|
|
68
|
+
setValue(e.target.value);
|
|
69
|
+
};
|
|
70
|
+
const style = getFieldWidthStyle(labelWidth, labelAlign, hiddenLabel, apply, hasExtraNode);
|
|
71
|
+
const hiddenHover = readonly || editing || editMode || apply === 'cell' || defaultProps.name === 'name-view' || isView;
|
|
72
|
+
return (jsx(ClassNames, { children: ({ cx, css }) => (jsxs(Col, { style: style, ref: containerRef, className: cx(css(textStyle()), 'field-value', viewClassNames, { [hiddenHoverClass]: hiddenHover }), onClick: handleClick, children: [(readonly || (!editMode && !editing)) &&
|
|
73
|
+
(value ? (isView ? (jsxs(Expand, { readonly: readonly, editing: editing, expandType: EXPAND_TYPE_ENUM.TEXT, children: [addonBefore, value, addonAfter] })) : (jsxs(OverflowTooltip, { enterable: true, title: `${addonBefore}${value}${addonAfter}`, maxline: maxline, children: [addonBefore, value, addonAfter] }))) : (jsx(EmptyField, { readonly: readonly }))), !readonly && (editMode || editing) && containerRef && (jsx(Overlay, { show: true, flip: true, rootClose: true, container: containerRef, target: containerRef, onHide: noop, children: () => (jsx("div", { className: "field-value-overlay", children: jsx(Input, { ...defaultProps, className: 'field-value-overlay-component', ref: targetRef, value: value, onChange: handleChange, onBlur: handleBlur, placeholder: placeholder, addonBefore: addonBefore, addonAfter: addonAfter }) })) }))] })) }));
|
|
74
|
+
};
|
|
75
|
+
Text.displayName = 'TextBaseField';
|
|
76
|
+
var BaseField = memo(Text, isPropsEqual);
|
|
77
|
+
|
|
78
|
+
export { BASE_FIELD_WIDTH, BaseField as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CellProps } from '../base-component/types';
|
|
3
|
+
import { BaseFieldProps } from './BaseField';
|
|
4
|
+
export type TextProps = BaseFieldProps & CellProps;
|
|
5
|
+
declare const Text: React.ForwardRefExoticComponent<import("antd").InputProps & import("../base-component/types").FieldProps & {
|
|
6
|
+
userData?: any;
|
|
7
|
+
label?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
value?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
onChange?: (e: React.MouseEvent) => void;
|
|
13
|
+
onBlur?: (e: React.MouseEvent) => void;
|
|
14
|
+
maxline?: 1 | 2 | 3 | 4 | 5;
|
|
15
|
+
searchComponent?: boolean;
|
|
16
|
+
fieldType?: "longText" | "text";
|
|
17
|
+
} & CellProps & React.RefAttributes<any>>;
|
|
18
|
+
export default Text;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { Row } from 'antd';
|
|
4
|
+
import BaseField from './BaseField.js';
|
|
5
|
+
|
|
6
|
+
const Text = React__default.forwardRef((props, ref) => {
|
|
7
|
+
return (jsx(Row, { ref: ref, className: 'field-cell-layout', children: jsx(BaseField, { ...props, apply: "cell" }) }));
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { Text as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { randomClassName } from '../../../style/common.js';
|
|
2
|
+
import { hoverStyle } from '../../common/style/mixin.js';
|
|
3
|
+
|
|
4
|
+
const hiddenHoverClass = randomClassName('hidden-hover');
|
|
5
|
+
const textStyle = () => `
|
|
6
|
+
width: 100%;
|
|
7
|
+
|
|
8
|
+
&:not(.${hiddenHoverClass}) :hover {
|
|
9
|
+
${hoverStyle}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export { hiddenHoverClass, textStyle };
|
|
@@ -33,6 +33,7 @@ import StatusReadView from '../fields/status/ReadView.js';
|
|
|
33
33
|
import StoryPointReadView from '../fields/story-point/ReadView.js';
|
|
34
34
|
import TagReadView from '../fields/tag/ReadView.js';
|
|
35
35
|
import TeamReadView from '../fields/team/ReadView.js';
|
|
36
|
+
import Text from '../fields/text/Cell.js';
|
|
36
37
|
import TextReadView from '../fields/text/ReadView.js';
|
|
37
38
|
import TreeReadView from '../fields/tree/ReadView.js';
|
|
38
39
|
import UpdatedAtReadView from '../fields/updated-at/ReadView.js';
|
|
@@ -99,6 +100,7 @@ const getStandardEditComponents = () => {
|
|
|
99
100
|
[FIELD_TYPE_KEY_MAPPINGS.Status]: StatusCell,
|
|
100
101
|
[FIELD_TYPE_KEY_MAPPINGS.Dropdown]: DropdownCell,
|
|
101
102
|
[FIELD_TYPE_KEY_MAPPINGS.Priority]: PriorityCell,
|
|
103
|
+
[FIELD_TYPE_KEY_MAPPINGS.Text]: Text,
|
|
102
104
|
};
|
|
103
105
|
};
|
|
104
106
|
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { default as StatusReadView } from './components/fields/status/ReadView';
|
|
|
35
35
|
export { default as StoryPointReadView } from './components/fields/story-point/ReadView';
|
|
36
36
|
export { default as TagReadView } from './components/fields/tag/ReadView';
|
|
37
37
|
export { default as TeamReadView } from './components/fields/team/ReadView';
|
|
38
|
+
export { default as TextCell } from './components/fields/text/Cell';
|
|
38
39
|
export { default as TextReadView } from './components/fields/text/ReadView';
|
|
39
40
|
export { default as TreeReadView } from './components/fields/tree/ReadView';
|
|
40
41
|
export { default as UpdatedAtReadView } from './components/fields/updated-at/ReadView';
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { default as StatusReadView } from './components/fields/status/ReadView.j
|
|
|
35
35
|
export { default as StoryPointReadView } from './components/fields/story-point/ReadView.js';
|
|
36
36
|
export { default as TagReadView } from './components/fields/tag/ReadView.js';
|
|
37
37
|
export { default as TeamReadView } from './components/fields/team/ReadView.js';
|
|
38
|
+
export { default as TextCell } from './components/fields/text/Cell.js';
|
|
38
39
|
export { default as TextReadView } from './components/fields/text/ReadView.js';
|
|
39
40
|
export { default as TreeReadView } from './components/fields/tree/ReadView.js';
|
|
40
41
|
export { default as UpdatedAtReadView } from './components/fields/updated-at/ReadView.js';
|