@ant-design/pro-components 3.1.9-0 → 3.1.11-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/dist/pro-components.min.js +1 -1
- package/es/descriptions/index.d.ts +7 -1
- package/es/descriptions/index.js +1 -1
- package/es/field/components/ColorPicker/index.d.ts +1 -1
- package/es/field/components/Percent/util.d.ts +1 -1
- package/es/form/components/Digit/DigitRange.d.ts +1 -1
- package/es/form/components/UploadButton/index.d.ts +3 -2
- package/es/form/components/UploadButton/index.js +9 -4
- package/es/form/components/UploadDragger/index.d.ts +1 -1
- package/es/form/components/UploadDragger/index.js +10 -5
- package/es/form/layouts/ProForm/index.d.ts +2 -2
- package/es/layout/utils/getBreadcrumbProps.d.ts +1 -2
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +1 -1
- package/es/utils/components/InlineErrorFormItem/index.js +22 -6
- package/es/utils/genCopyable/index.d.ts +5 -4
- package/es/utils/genCopyable/index.js +34 -15
- package/lib/descriptions/index.d.ts +7 -1
- package/lib/descriptions/index.js +1 -1
- package/lib/field/components/ColorPicker/index.d.ts +1 -1
- package/lib/field/components/Percent/util.d.ts +1 -1
- package/lib/form/components/Digit/DigitRange.d.ts +1 -1
- package/lib/form/components/UploadButton/index.d.ts +3 -2
- package/lib/form/components/UploadButton/index.js +9 -4
- package/lib/form/components/UploadDragger/index.d.ts +1 -1
- package/lib/form/components/UploadDragger/index.js +10 -5
- package/lib/form/layouts/ProForm/index.d.ts +2 -2
- package/lib/layout/utils/getBreadcrumbProps.d.ts +1 -2
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +1 -1
- package/lib/utils/components/InlineErrorFormItem/index.js +21 -5
- package/lib/utils/genCopyable/index.d.ts +5 -4
- package/lib/utils/genCopyable/index.js +34 -15
- package/package.json +17 -24
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DescriptionsProps, FormProps } from 'antd';
|
|
2
|
+
import type { Breakpoint } from 'antd/es/_util/responsiveObserver';
|
|
3
|
+
import { CellSemanticClassNames, CellSemanticStyles } from 'antd/es/descriptions/DescriptionsContext';
|
|
2
4
|
import React from 'react';
|
|
3
5
|
import type { ProFieldFCMode } from '../provider';
|
|
4
6
|
import type { ProCoreActionType, ProEllipsis, ProFieldValueType, ProSchema, ProSchemaComponentTypes, RowEditableConfig, UseEditableMapUtilType } from '../utils';
|
|
@@ -9,8 +11,12 @@ export interface DescriptionsItemProps {
|
|
|
9
11
|
className?: string;
|
|
10
12
|
style?: React.CSSProperties;
|
|
11
13
|
label?: React.ReactNode;
|
|
14
|
+
classNames?: CellSemanticClassNames;
|
|
15
|
+
styles?: CellSemanticStyles;
|
|
12
16
|
children: React.ReactNode;
|
|
13
|
-
span?: number
|
|
17
|
+
span?: number | 'filled' | {
|
|
18
|
+
[key in Breakpoint]?: number;
|
|
19
|
+
};
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* 定义列表属性的类型定义,用于定义列表的一列
|
package/es/descriptions/index.js
CHANGED
|
@@ -209,7 +209,7 @@ const schemaToDescriptionsItem = (items, entity, action, editableUtils, emptyTex
|
|
|
209
209
|
const fieldMode = mode || isEditable ? 'edit' : 'read';
|
|
210
210
|
const showEditIcon = editableUtils && fieldMode === 'read' && editable !== false && editable?.(text, entity, index) !== false;
|
|
211
211
|
const Component = showEditIcon ? Space : React.Fragment;
|
|
212
|
-
const contentDom = fieldMode === 'edit' ? text : genCopyable(text, item, text);
|
|
212
|
+
const contentDom = fieldMode === 'edit' ? text : genCopyable(text, item, text, defaultData);
|
|
213
213
|
const key = restItem.key || restItem.label?.toString() || index;
|
|
214
214
|
const label = (title || restItem.label || restItem.tooltip) && /*#__PURE__*/_jsx(LabelIconTip, {
|
|
215
215
|
label: title || restItem.label,
|
|
@@ -3,5 +3,5 @@ import React from 'react';
|
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<import("src/provider").BaseProFieldFC & import("src/provider").ProRenderFieldPropsType & {
|
|
4
4
|
text: string;
|
|
5
5
|
mode?: "update" | "read" | "edit" | undefined;
|
|
6
|
-
} & Partial<Omit<ColorPickerProps, "
|
|
6
|
+
} & Partial<Omit<ColorPickerProps, "mode" | "value">> & React.RefAttributes<any>>;
|
|
7
7
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** 获取展示符号 */
|
|
2
2
|
export declare function getSymbolByRealValue(realValue: number): "-" | "+" | null;
|
|
3
3
|
/** 获取颜色 */
|
|
4
|
-
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#52c41a" | "#
|
|
4
|
+
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#52c41a" | "#ff4d4f" | "#595959";
|
|
5
5
|
/** 获取到最后展示的数字 */
|
|
6
6
|
export declare function getRealTextWithPrecision(realValue: number, precision?: number): string | number;
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@ export type ProFormDigitRangeProps = ProFormFieldItemProps<RangeInputNumberProps
|
|
|
13
13
|
separatorWidth?: number;
|
|
14
14
|
};
|
|
15
15
|
declare const ForwardRefProFormDigit: React.ForwardRefExoticComponent<{
|
|
16
|
-
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "
|
|
16
|
+
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "defaultValue" | "onChange" | "value" | "placeholder"> & {
|
|
17
17
|
value?: ValuePair | undefined;
|
|
18
18
|
defaultValue?: ValuePair | undefined;
|
|
19
19
|
onChange?: ((value?: ValuePair) => void) | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ButtonProps, ImageProps, UploadProps } from 'antd';
|
|
2
|
+
import type { UploadRef } from 'antd/es/upload';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import type { ProFormFieldItemProps } from '../../typing';
|
|
4
|
-
type PickUploadProps = Pick<UploadProps
|
|
5
|
-
export type ProFormUploadButtonProps = ProFormFieldItemProps<UploadProps
|
|
5
|
+
type PickUploadProps = Pick<UploadProps, 'listType' | 'action' | 'accept' | 'fileList' | 'onChange'>;
|
|
6
|
+
export type ProFormUploadButtonProps = ProFormFieldItemProps<UploadProps, UploadRef> & {
|
|
6
7
|
/**
|
|
7
8
|
* @name 上传文件的图标
|
|
8
9
|
* @default UploadOutlined
|
|
@@ -49,6 +49,11 @@ const BaseProFormUploadButton = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
// 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮
|
|
50
50
|
const showUploadButton = (max === undefined || !value || value?.length < max) && mode !== 'read';
|
|
51
51
|
const isPictureCard = (listType ?? fieldProps?.listType) === 'picture-card';
|
|
52
|
+
// 参考 antd:不传 id 给 Upload,避免点击 label 触发 file input 打开文件选择器
|
|
53
|
+
const {
|
|
54
|
+
id: _id,
|
|
55
|
+
...uploadFieldProps
|
|
56
|
+
} = fieldProps || {};
|
|
52
57
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
53
58
|
children: [/*#__PURE__*/_jsx(Upload, {
|
|
54
59
|
action: action,
|
|
@@ -57,15 +62,15 @@ const BaseProFormUploadButton = /*#__PURE__*/React.forwardRef(({
|
|
|
57
62
|
listType: listType || 'picture',
|
|
58
63
|
fileList: value,
|
|
59
64
|
onPreview: handlePreview,
|
|
60
|
-
...
|
|
61
|
-
name:
|
|
65
|
+
...uploadFieldProps,
|
|
66
|
+
name: uploadFieldProps?.name ?? 'file',
|
|
62
67
|
onChange: info => {
|
|
63
|
-
|
|
68
|
+
uploadFieldProps?.onChange?.(info);
|
|
64
69
|
},
|
|
65
70
|
children: showUploadButton && (isPictureCard ? /*#__PURE__*/_jsxs("span", {
|
|
66
71
|
children: [icon, " ", title]
|
|
67
72
|
}) : /*#__PURE__*/_jsxs(Button, {
|
|
68
|
-
disabled: disabled ||
|
|
73
|
+
disabled: disabled || uploadFieldProps?.disabled,
|
|
69
74
|
...buttonProps,
|
|
70
75
|
children: [icon, title]
|
|
71
76
|
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DraggerProps, UploadProps } from 'antd
|
|
1
|
+
import type { DraggerProps, UploadProps } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ProFormFieldItemProps } from '../../typing';
|
|
4
4
|
export type ProFormUploadDraggerProps = ProFormFieldItemProps<DraggerProps> & {
|
|
@@ -29,24 +29,29 @@ const BaseProFormUploadDragger = /*#__PURE__*/React.forwardRef(({
|
|
|
29
29
|
const baseClassName = context.getPrefixCls('upload');
|
|
30
30
|
// 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮
|
|
31
31
|
const showUploadButton = (max === undefined || !value || value?.length < max) && mode !== 'read' && proFieldProps?.readonly !== true;
|
|
32
|
+
// 参考 antd:不传 id 给 Upload,避免点击 label 触发 file input 打开文件选择器
|
|
33
|
+
const {
|
|
34
|
+
id: _id,
|
|
35
|
+
...uploadFieldProps
|
|
36
|
+
} = fieldProps || {};
|
|
32
37
|
return /*#__PURE__*/_jsxs(Upload.Dragger, {
|
|
33
38
|
ref: ref,
|
|
34
39
|
name: "files",
|
|
35
40
|
action: action,
|
|
36
41
|
accept: accept,
|
|
37
42
|
fileList: value,
|
|
38
|
-
...
|
|
43
|
+
...uploadFieldProps,
|
|
39
44
|
onChange: info => {
|
|
40
45
|
onChange?.(info);
|
|
41
|
-
if (
|
|
42
|
-
|
|
46
|
+
if (uploadFieldProps?.onChange) {
|
|
47
|
+
uploadFieldProps?.onChange(info);
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
style: {
|
|
46
51
|
flexDirection: 'column',
|
|
47
52
|
alignItems: 'center',
|
|
48
|
-
...
|
|
49
|
-
display: !showUploadButton ? 'none' :
|
|
53
|
+
...uploadFieldProps?.style,
|
|
54
|
+
display: !showUploadButton ? 'none' : uploadFieldProps?.style?.display || 'flex'
|
|
50
55
|
},
|
|
51
56
|
children: [/*#__PURE__*/_jsx("p", {
|
|
52
57
|
className: `${baseClassName}-drag-icon`,
|
|
@@ -9,12 +9,12 @@ declare namespace ProForm {
|
|
|
9
9
|
var Group: React.FC<import("src/form").GroupProps>;
|
|
10
10
|
var useForm: typeof import("antd/es/form/Form").useForm;
|
|
11
11
|
var Item: React.FC<import("src/form/components/FormItem").ProFormItemProps>;
|
|
12
|
-
var useWatch: typeof import("
|
|
12
|
+
var useWatch: typeof import("antd/es/form/Form").useWatch;
|
|
13
13
|
var ErrorList: React.FC<import("antd/es/form").ErrorListProps>;
|
|
14
14
|
var Provider: React.FC<import("antd/es/form/context").FormProviderProps>;
|
|
15
15
|
var useFormInstance: typeof import("antd/es/form/hooks/useFormInstance").default;
|
|
16
16
|
var EditOrReadOnlyContext: React.Context<{
|
|
17
|
-
mode: "
|
|
17
|
+
mode: "read" | "edit" | "update";
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
20
|
export { ProForm };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BreadcrumbProps } from 'antd';
|
|
2
|
-
import type H from 'history';
|
|
3
2
|
import type { ProSettings } from '../defaultSettings';
|
|
4
3
|
import type { ProLayoutProps } from '../ProLayout';
|
|
5
4
|
import type { MenuDataItem, MessageDescriptor, WithFalse } from '../typing';
|
|
@@ -9,7 +8,7 @@ export type BreadcrumbProLayoutProps = {
|
|
|
9
8
|
href: string;
|
|
10
9
|
}[];
|
|
11
10
|
home?: string;
|
|
12
|
-
location?:
|
|
11
|
+
location?: Location | {
|
|
13
12
|
pathname?: string;
|
|
14
13
|
};
|
|
15
14
|
menu?: ProSettings['menu'];
|
|
@@ -22,7 +22,7 @@ type ColumnRenderInterface<T> = {
|
|
|
22
22
|
*
|
|
23
23
|
* @param item
|
|
24
24
|
*/
|
|
25
|
-
export declare const renderColumnsTitle: (item: ProColumns<any>) => string | number | boolean |
|
|
25
|
+
export declare const renderColumnsTitle: (item: ProColumns<any>) => string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* 默认的 filter 方法
|
|
28
28
|
*
|
|
@@ -102,7 +102,7 @@ export function columnRender({
|
|
|
102
102
|
prefixName,
|
|
103
103
|
editableUtils
|
|
104
104
|
});
|
|
105
|
-
const dom = mode === 'edit' ? textDom : genCopyable(textDom, columnProps, renderTextStr);
|
|
105
|
+
const dom = mode === 'edit' ? textDom : genCopyable(textDom, columnProps, renderTextStr, text);
|
|
106
106
|
|
|
107
107
|
/** 如果是编辑模式,并且 formItemRender 存在直接走 formItemRender */
|
|
108
108
|
if (mode === 'edit') {
|
|
@@ -5,8 +5,8 @@ import { clsx } from 'clsx';
|
|
|
5
5
|
import React, { useContext, useEffect, useState } from 'react';
|
|
6
6
|
import { useStyle } from "./style";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
8
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const FIX_INLINE_STYLE = {
|
|
11
11
|
marginBlockStart: -5,
|
|
12
12
|
marginBlockEnd: -5,
|
|
@@ -21,7 +21,10 @@ const InlineErrorFormItemPopover = ({
|
|
|
21
21
|
popoverProps
|
|
22
22
|
}) => {
|
|
23
23
|
const [open, setOpen] = useState(false);
|
|
24
|
-
const [
|
|
24
|
+
const [messages, setMessages] = useState({
|
|
25
|
+
errors: [],
|
|
26
|
+
warnings: []
|
|
27
|
+
});
|
|
25
28
|
const {
|
|
26
29
|
getPrefixCls
|
|
27
30
|
} = useContext(ConfigProvider.ConfigContext);
|
|
@@ -33,12 +36,25 @@ const InlineErrorFormItemPopover = ({
|
|
|
33
36
|
} = useStyle(`${prefixCls}-form-item-with-help`);
|
|
34
37
|
useEffect(() => {
|
|
35
38
|
if (inputProps.validateStatus !== 'validating') {
|
|
36
|
-
|
|
39
|
+
setMessages({
|
|
40
|
+
errors: inputProps.errors ?? [],
|
|
41
|
+
warnings: inputProps.warnings ?? []
|
|
42
|
+
});
|
|
37
43
|
}
|
|
38
|
-
}, [inputProps.errors, inputProps.validateStatus]);
|
|
44
|
+
}, [inputProps.errors, inputProps.warnings, inputProps.validateStatus]);
|
|
39
45
|
const loading = inputProps.validateStatus === 'validating';
|
|
46
|
+
const hasMessages = (messages.errors?.length ?? 0) + (messages.warnings?.length ?? 0) >= 1;
|
|
47
|
+
const renderMessageContent = () => /*#__PURE__*/_jsxs(_Fragment, {
|
|
48
|
+
children: [messages.errors?.map((error, index) => /*#__PURE__*/_jsx("div", {
|
|
49
|
+
className: clsx(`${prefixCls}-form-item-explain-error`, hashId),
|
|
50
|
+
children: error
|
|
51
|
+
}, `error-${index}`)), messages.warnings?.map((warning, index) => /*#__PURE__*/_jsx("div", {
|
|
52
|
+
className: clsx(`${prefixCls}-form-item-explain-warning`, hashId),
|
|
53
|
+
children: warning
|
|
54
|
+
}, `warning-${index}`))]
|
|
55
|
+
});
|
|
40
56
|
return /*#__PURE__*/_jsx(Popover, {
|
|
41
|
-
open:
|
|
57
|
+
open: !hasMessages ? false : open,
|
|
42
58
|
onOpenChange: changeOpen => {
|
|
43
59
|
if (changeOpen === open) return;
|
|
44
60
|
setOpen(changeOpen);
|
|
@@ -55,7 +71,7 @@ const InlineErrorFormItemPopover = ({
|
|
|
55
71
|
},
|
|
56
72
|
children: /*#__PURE__*/_jsxs("div", {
|
|
57
73
|
className: clsx(`${prefixCls}-form-item-with-help`, hashId, token.hashId),
|
|
58
|
-
children: [loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : null, errorList]
|
|
74
|
+
children: [loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : null, hasMessages ? renderMessageContent() : errorList]
|
|
59
75
|
})
|
|
60
76
|
})),
|
|
61
77
|
...popoverProps,
|
|
@@ -8,8 +8,9 @@ export type ProEllipsis = ProEllipsisTooltip | boolean;
|
|
|
8
8
|
/**
|
|
9
9
|
* 生成 Copyable 或 Ellipsis 的 dom
|
|
10
10
|
*
|
|
11
|
-
* @param dom
|
|
12
|
-
* @param item
|
|
13
|
-
* @param text
|
|
11
|
+
* @param dom 渲染后的 DOM 节点
|
|
12
|
+
* @param item 列配置
|
|
13
|
+
* @param text renderText 的返回值,可能是 string/number 或 React 元素
|
|
14
|
+
* @param copyText 用于复制的原始文本,当 renderText 返回 JSX 时避免复制 [object Object]
|
|
14
15
|
*/
|
|
15
|
-
export declare const genCopyable: (dom: React.ReactNode, item: any, text: string) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
16
|
+
export declare const genCopyable: (dom: React.ReactNode, item: any, text: string | React.ReactNode, copyText?: unknown) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -23,23 +23,39 @@ const normalizeCopyText = text => {
|
|
|
23
23
|
// (e.g. some browsers may include Typography's copy separator whitespace)
|
|
24
24
|
return text === null || text === undefined ? '' : String(text).trimEnd();
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const isReactElement = value => /*#__PURE__*/React.isValidElement(value);
|
|
27
|
+
const genEllipsis = (dom, item, text, rawText) => {
|
|
27
28
|
const ellipsis = getEllipsis(item);
|
|
28
|
-
if (!ellipsis
|
|
29
|
+
if (!ellipsis) {
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
31
32
|
/** 有些 valueType 需要设置copy的为string */
|
|
32
33
|
const needTranText = isNeedTranText(item);
|
|
33
34
|
|
|
34
|
-
//
|
|
35
|
-
|
|
35
|
+
// renderText 返回 React 元素时,使用 dom 作为 tooltip 避免 [object Object]
|
|
36
|
+
const isRenderTextReturningJsx = isReactElement(rawText);
|
|
37
|
+
|
|
38
|
+
// 支持一下 tooltip 的关闭,合并 ellipsis.tooltip 自定义属性(placement 等)
|
|
39
|
+
if ((needTranText || isRenderTextReturningJsx) && item?.tooltip !== false) {
|
|
40
|
+
const tooltipTitle = /*#__PURE__*/_jsx("div", {
|
|
41
|
+
className: "pro-table-tooltip-text",
|
|
42
|
+
children: dom
|
|
43
|
+
});
|
|
44
|
+
if (isObject(ellipsis) && isObject(ellipsis.tooltip)) {
|
|
45
|
+
return {
|
|
46
|
+
tooltip: {
|
|
47
|
+
title: tooltipTitle,
|
|
48
|
+
...ellipsis.tooltip
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
36
52
|
return {
|
|
37
|
-
tooltip:
|
|
38
|
-
className: "pro-table-tooltip-text",
|
|
39
|
-
children: dom
|
|
40
|
-
})
|
|
53
|
+
tooltip: tooltipTitle
|
|
41
54
|
};
|
|
42
55
|
}
|
|
56
|
+
if (!text) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
43
59
|
|
|
44
60
|
// 如果 ellipsis 是对象且包含 tooltip 属性,合并 tooltip 的属性
|
|
45
61
|
if (isObject(ellipsis) && isObject(ellipsis.tooltip)) {
|
|
@@ -58,14 +74,17 @@ const genEllipsis = (dom, item, text) => {
|
|
|
58
74
|
/**
|
|
59
75
|
* 生成 Copyable 或 Ellipsis 的 dom
|
|
60
76
|
*
|
|
61
|
-
* @param dom
|
|
62
|
-
* @param item
|
|
63
|
-
* @param text
|
|
77
|
+
* @param dom 渲染后的 DOM 节点
|
|
78
|
+
* @param item 列配置
|
|
79
|
+
* @param text renderText 的返回值,可能是 string/number 或 React 元素
|
|
80
|
+
* @param copyText 用于复制的原始文本,当 renderText 返回 JSX 时避免复制 [object Object]
|
|
64
81
|
*/
|
|
65
|
-
export const genCopyable = (dom, item, text) => {
|
|
82
|
+
export const genCopyable = (dom, item, text, copyText) => {
|
|
66
83
|
if (!item.copyable && !item.ellipsis) return dom;
|
|
67
84
|
const normalizedText = normalizeCopyText(text);
|
|
68
|
-
|
|
85
|
+
// renderText 返回 JSX 时使用原始文本避免复制 [object Object]
|
|
86
|
+
const resolvedCopyText = copyText !== undefined ? normalizeCopyText(copyText) : normalizedText;
|
|
87
|
+
const ellipsis = genEllipsis(dom, item, normalizedText, text);
|
|
69
88
|
|
|
70
89
|
// `Typography.Text` with `copyable` will render an internal separator whitespace
|
|
71
90
|
// between text and icon. When users "multi-click to select all" in a table cell,
|
|
@@ -88,7 +107,7 @@ export const genCopyable = (dom, item, text) => {
|
|
|
88
107
|
title: "",
|
|
89
108
|
ellipsis: ellipsis,
|
|
90
109
|
children: dom
|
|
91
|
-
}),
|
|
110
|
+
}), resolvedCopyText ? /*#__PURE__*/_jsx("span", {
|
|
92
111
|
style: {
|
|
93
112
|
flex: 'none',
|
|
94
113
|
userSelect: 'none'
|
|
@@ -101,7 +120,7 @@ export const genCopyable = (dom, item, text) => {
|
|
|
101
120
|
// Render icon only; no extra selectable separator text nodes.
|
|
102
121
|
,
|
|
103
122
|
copyable: {
|
|
104
|
-
text:
|
|
123
|
+
text: resolvedCopyText,
|
|
105
124
|
tooltips: ['', '']
|
|
106
125
|
}
|
|
107
126
|
})
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DescriptionsProps, FormProps } from 'antd';
|
|
2
|
+
import type { Breakpoint } from 'antd/es/_util/responsiveObserver';
|
|
3
|
+
import { CellSemanticClassNames, CellSemanticStyles } from 'antd/es/descriptions/DescriptionsContext';
|
|
2
4
|
import React from 'react';
|
|
3
5
|
import type { ProFieldFCMode } from '../provider';
|
|
4
6
|
import type { ProCoreActionType, ProEllipsis, ProFieldValueType, ProSchema, ProSchemaComponentTypes, RowEditableConfig, UseEditableMapUtilType } from '../utils';
|
|
@@ -9,8 +11,12 @@ export interface DescriptionsItemProps {
|
|
|
9
11
|
className?: string;
|
|
10
12
|
style?: React.CSSProperties;
|
|
11
13
|
label?: React.ReactNode;
|
|
14
|
+
classNames?: CellSemanticClassNames;
|
|
15
|
+
styles?: CellSemanticStyles;
|
|
12
16
|
children: React.ReactNode;
|
|
13
|
-
span?: number
|
|
17
|
+
span?: number | 'filled' | {
|
|
18
|
+
[key in Breakpoint]?: number;
|
|
19
|
+
};
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* 定义列表属性的类型定义,用于定义列表的一列
|
|
@@ -216,7 +216,7 @@ const schemaToDescriptionsItem = (items, entity, action, editableUtils, emptyTex
|
|
|
216
216
|
const fieldMode = mode || isEditable ? 'edit' : 'read';
|
|
217
217
|
const showEditIcon = editableUtils && fieldMode === 'read' && editable !== false && editable?.(text, entity, index) !== false;
|
|
218
218
|
const Component = showEditIcon ? _antd.Space : _react.default.Fragment;
|
|
219
|
-
const contentDom = fieldMode === 'edit' ? text : (0, _utils.genCopyable)(text, item, text);
|
|
219
|
+
const contentDom = fieldMode === 'edit' ? text : (0, _utils.genCopyable)(text, item, text, defaultData);
|
|
220
220
|
const key = restItem.key || restItem.label?.toString() || index;
|
|
221
221
|
const label = (title || restItem.label || restItem.tooltip) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.LabelIconTip, {
|
|
222
222
|
label: title || restItem.label,
|
|
@@ -3,5 +3,5 @@ import React from 'react';
|
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<import("src/provider").BaseProFieldFC & import("src/provider").ProRenderFieldPropsType & {
|
|
4
4
|
text: string;
|
|
5
5
|
mode?: "update" | "read" | "edit" | undefined;
|
|
6
|
-
} & Partial<Omit<ColorPickerProps, "
|
|
6
|
+
} & Partial<Omit<ColorPickerProps, "mode" | "value">> & React.RefAttributes<any>>;
|
|
7
7
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** 获取展示符号 */
|
|
2
2
|
export declare function getSymbolByRealValue(realValue: number): "-" | "+" | null;
|
|
3
3
|
/** 获取颜色 */
|
|
4
|
-
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#52c41a" | "#
|
|
4
|
+
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#52c41a" | "#ff4d4f" | "#595959";
|
|
5
5
|
/** 获取到最后展示的数字 */
|
|
6
6
|
export declare function getRealTextWithPrecision(realValue: number, precision?: number): string | number;
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@ export type ProFormDigitRangeProps = ProFormFieldItemProps<RangeInputNumberProps
|
|
|
13
13
|
separatorWidth?: number;
|
|
14
14
|
};
|
|
15
15
|
declare const ForwardRefProFormDigit: React.ForwardRefExoticComponent<{
|
|
16
|
-
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "
|
|
16
|
+
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "defaultValue" | "onChange" | "value" | "placeholder"> & {
|
|
17
17
|
value?: ValuePair | undefined;
|
|
18
18
|
defaultValue?: ValuePair | undefined;
|
|
19
19
|
onChange?: ((value?: ValuePair) => void) | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ButtonProps, ImageProps, UploadProps } from 'antd';
|
|
2
|
+
import type { UploadRef } from 'antd/es/upload';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import type { ProFormFieldItemProps } from '../../typing';
|
|
4
|
-
type PickUploadProps = Pick<UploadProps
|
|
5
|
-
export type ProFormUploadButtonProps = ProFormFieldItemProps<UploadProps
|
|
5
|
+
type PickUploadProps = Pick<UploadProps, 'listType' | 'action' | 'accept' | 'fileList' | 'onChange'>;
|
|
6
|
+
export type ProFormUploadButtonProps = ProFormFieldItemProps<UploadProps, UploadRef> & {
|
|
6
7
|
/**
|
|
7
8
|
* @name 上传文件的图标
|
|
8
9
|
* @default UploadOutlined
|
|
@@ -55,6 +55,11 @@ const BaseProFormUploadButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
55
55
|
// 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮
|
|
56
56
|
const showUploadButton = (max === undefined || !value || value?.length < max) && mode !== 'read';
|
|
57
57
|
const isPictureCard = (listType ?? fieldProps?.listType) === 'picture-card';
|
|
58
|
+
// 参考 antd:不传 id 给 Upload,避免点击 label 触发 file input 打开文件选择器
|
|
59
|
+
const {
|
|
60
|
+
id: _id,
|
|
61
|
+
...uploadFieldProps
|
|
62
|
+
} = fieldProps || {};
|
|
58
63
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
59
64
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Upload, {
|
|
60
65
|
action: action,
|
|
@@ -63,15 +68,15 @@ const BaseProFormUploadButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
63
68
|
listType: listType || 'picture',
|
|
64
69
|
fileList: value,
|
|
65
70
|
onPreview: handlePreview,
|
|
66
|
-
...
|
|
67
|
-
name:
|
|
71
|
+
...uploadFieldProps,
|
|
72
|
+
name: uploadFieldProps?.name ?? 'file',
|
|
68
73
|
onChange: info => {
|
|
69
|
-
|
|
74
|
+
uploadFieldProps?.onChange?.(info);
|
|
70
75
|
},
|
|
71
76
|
children: showUploadButton && (isPictureCard ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
72
77
|
children: [icon, " ", title]
|
|
73
78
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Button, {
|
|
74
|
-
disabled: disabled ||
|
|
79
|
+
disabled: disabled || uploadFieldProps?.disabled,
|
|
75
80
|
...buttonProps,
|
|
76
81
|
children: [icon, title]
|
|
77
82
|
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DraggerProps, UploadProps } from 'antd
|
|
1
|
+
import type { DraggerProps, UploadProps } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ProFormFieldItemProps } from '../../typing';
|
|
4
4
|
export type ProFormUploadDraggerProps = ProFormFieldItemProps<DraggerProps> & {
|
|
@@ -36,24 +36,29 @@ const BaseProFormUploadDragger = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
36
36
|
const baseClassName = context.getPrefixCls('upload');
|
|
37
37
|
// 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮
|
|
38
38
|
const showUploadButton = (max === undefined || !value || value?.length < max) && mode !== 'read' && proFieldProps?.readonly !== true;
|
|
39
|
+
// 参考 antd:不传 id 给 Upload,避免点击 label 触发 file input 打开文件选择器
|
|
40
|
+
const {
|
|
41
|
+
id: _id,
|
|
42
|
+
...uploadFieldProps
|
|
43
|
+
} = fieldProps || {};
|
|
39
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Upload.Dragger, {
|
|
40
45
|
ref: ref,
|
|
41
46
|
name: "files",
|
|
42
47
|
action: action,
|
|
43
48
|
accept: accept,
|
|
44
49
|
fileList: value,
|
|
45
|
-
...
|
|
50
|
+
...uploadFieldProps,
|
|
46
51
|
onChange: info => {
|
|
47
52
|
onChange?.(info);
|
|
48
|
-
if (
|
|
49
|
-
|
|
53
|
+
if (uploadFieldProps?.onChange) {
|
|
54
|
+
uploadFieldProps?.onChange(info);
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
style: {
|
|
53
58
|
flexDirection: 'column',
|
|
54
59
|
alignItems: 'center',
|
|
55
|
-
...
|
|
56
|
-
display: !showUploadButton ? 'none' :
|
|
60
|
+
...uploadFieldProps?.style,
|
|
61
|
+
display: !showUploadButton ? 'none' : uploadFieldProps?.style?.display || 'flex'
|
|
57
62
|
},
|
|
58
63
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
59
64
|
className: `${baseClassName}-drag-icon`,
|
|
@@ -9,12 +9,12 @@ declare namespace ProForm {
|
|
|
9
9
|
var Group: React.FC<import("src/form").GroupProps>;
|
|
10
10
|
var useForm: typeof import("antd/es/form/Form").useForm;
|
|
11
11
|
var Item: React.FC<import("src/form/components/FormItem").ProFormItemProps>;
|
|
12
|
-
var useWatch: typeof import("
|
|
12
|
+
var useWatch: typeof import("antd/es/form/Form").useWatch;
|
|
13
13
|
var ErrorList: React.FC<import("antd/es/form").ErrorListProps>;
|
|
14
14
|
var Provider: React.FC<import("antd/es/form/context").FormProviderProps>;
|
|
15
15
|
var useFormInstance: typeof import("antd/es/form/hooks/useFormInstance").default;
|
|
16
16
|
var EditOrReadOnlyContext: React.Context<{
|
|
17
|
-
mode: "
|
|
17
|
+
mode: "read" | "edit" | "update";
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
20
|
export { ProForm };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BreadcrumbProps } from 'antd';
|
|
2
|
-
import type H from 'history';
|
|
3
2
|
import type { ProSettings } from '../defaultSettings';
|
|
4
3
|
import type { ProLayoutProps } from '../ProLayout';
|
|
5
4
|
import type { MenuDataItem, MessageDescriptor, WithFalse } from '../typing';
|
|
@@ -9,7 +8,7 @@ export type BreadcrumbProLayoutProps = {
|
|
|
9
8
|
href: string;
|
|
10
9
|
}[];
|
|
11
10
|
home?: string;
|
|
12
|
-
location?:
|
|
11
|
+
location?: Location | {
|
|
13
12
|
pathname?: string;
|
|
14
13
|
};
|
|
15
14
|
menu?: ProSettings['menu'];
|
|
@@ -22,7 +22,7 @@ type ColumnRenderInterface<T> = {
|
|
|
22
22
|
*
|
|
23
23
|
* @param item
|
|
24
24
|
*/
|
|
25
|
-
export declare const renderColumnsTitle: (item: ProColumns<any>) => string | number | boolean |
|
|
25
|
+
export declare const renderColumnsTitle: (item: ProColumns<any>) => string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* 默认的 filter 方法
|
|
28
28
|
*
|
|
@@ -112,7 +112,7 @@ function columnRender({
|
|
|
112
112
|
prefixName,
|
|
113
113
|
editableUtils
|
|
114
114
|
});
|
|
115
|
-
const dom = mode === 'edit' ? textDom : (0, _utils.genCopyable)(textDom, columnProps, renderTextStr);
|
|
115
|
+
const dom = mode === 'edit' ? textDom : (0, _utils.genCopyable)(textDom, columnProps, renderTextStr, text);
|
|
116
116
|
|
|
117
117
|
/** 如果是编辑模式,并且 formItemRender 存在直接走 formItemRender */
|
|
118
118
|
if (mode === 'edit') {
|
|
@@ -26,7 +26,10 @@ const InlineErrorFormItemPopover = ({
|
|
|
26
26
|
popoverProps
|
|
27
27
|
}) => {
|
|
28
28
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
29
|
-
const [
|
|
29
|
+
const [messages, setMessages] = (0, _react.useState)({
|
|
30
|
+
errors: [],
|
|
31
|
+
warnings: []
|
|
32
|
+
});
|
|
30
33
|
const {
|
|
31
34
|
getPrefixCls
|
|
32
35
|
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
@@ -38,12 +41,25 @@ const InlineErrorFormItemPopover = ({
|
|
|
38
41
|
} = (0, _style.useStyle)(`${prefixCls}-form-item-with-help`);
|
|
39
42
|
(0, _react.useEffect)(() => {
|
|
40
43
|
if (inputProps.validateStatus !== 'validating') {
|
|
41
|
-
|
|
44
|
+
setMessages({
|
|
45
|
+
errors: inputProps.errors ?? [],
|
|
46
|
+
warnings: inputProps.warnings ?? []
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
|
-
}, [inputProps.errors, inputProps.validateStatus]);
|
|
49
|
+
}, [inputProps.errors, inputProps.warnings, inputProps.validateStatus]);
|
|
44
50
|
const loading = inputProps.validateStatus === 'validating';
|
|
51
|
+
const hasMessages = (messages.errors?.length ?? 0) + (messages.warnings?.length ?? 0) >= 1;
|
|
52
|
+
const renderMessageContent = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
53
|
+
children: [messages.errors?.map((error, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
54
|
+
className: (0, _clsx.clsx)(`${prefixCls}-form-item-explain-error`, hashId),
|
|
55
|
+
children: error
|
|
56
|
+
}, `error-${index}`)), messages.warnings?.map((warning, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
57
|
+
className: (0, _clsx.clsx)(`${prefixCls}-form-item-explain-warning`, hashId),
|
|
58
|
+
children: warning
|
|
59
|
+
}, `warning-${index}`))]
|
|
60
|
+
});
|
|
45
61
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Popover, {
|
|
46
|
-
open:
|
|
62
|
+
open: !hasMessages ? false : open,
|
|
47
63
|
onOpenChange: changeOpen => {
|
|
48
64
|
if (changeOpen === open) return;
|
|
49
65
|
setOpen(changeOpen);
|
|
@@ -60,7 +76,7 @@ const InlineErrorFormItemPopover = ({
|
|
|
60
76
|
},
|
|
61
77
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
62
78
|
className: (0, _clsx.clsx)(`${prefixCls}-form-item-with-help`, hashId, token.hashId),
|
|
63
|
-
children: [loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}) : null, errorList]
|
|
79
|
+
children: [loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}) : null, hasMessages ? renderMessageContent() : errorList]
|
|
64
80
|
})
|
|
65
81
|
})),
|
|
66
82
|
...popoverProps,
|
|
@@ -8,8 +8,9 @@ export type ProEllipsis = ProEllipsisTooltip | boolean;
|
|
|
8
8
|
/**
|
|
9
9
|
* 生成 Copyable 或 Ellipsis 的 dom
|
|
10
10
|
*
|
|
11
|
-
* @param dom
|
|
12
|
-
* @param item
|
|
13
|
-
* @param text
|
|
11
|
+
* @param dom 渲染后的 DOM 节点
|
|
12
|
+
* @param item 列配置
|
|
13
|
+
* @param text renderText 的返回值,可能是 string/number 或 React 元素
|
|
14
|
+
* @param copyText 用于复制的原始文本,当 renderText 返回 JSX 时避免复制 [object Object]
|
|
14
15
|
*/
|
|
15
|
-
export declare const genCopyable: (dom: React.ReactNode, item: any, text: string) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
16
|
+
export declare const genCopyable: (dom: React.ReactNode, item: any, text: string | React.ReactNode, copyText?: unknown) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|