Skip to content

Commit 7279f00

Browse files
author
liquanwei.lqw
committed
fix: descriptions test
1 parent 84516d8 commit 7279f00

File tree

3 files changed

+155
-35
lines changed

3 files changed

+155
-35
lines changed

packages/descriptions/src/index.tsx

+34-30
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import type { RequestData } from './useFetchData';
2828
import useFetchData from './useFetchData';
2929

3030
import type { ProFieldFCMode } from '@ant-design/pro-provider';
31-
import { proTheme } from '@ant-design/pro-provider';
31+
import ProConfigContext, { ProConfigProvider, proTheme } from '@ant-design/pro-provider';
3232
import type { DescriptionsItemType } from 'antd/es/descriptions';
33+
import ValueTypeToComponent from '../../field/src/ValueTypeToComponent';
3334

3435
// todo remove it
3536
export interface DescriptionsItemProps {
@@ -496,6 +497,7 @@ const ProDescriptions = <
496497
...rest
497498
} = props;
498499

500+
const proContext = useContext(ProConfigContext);
499501
const context = useContext(ConfigProvider.ConfigContext);
500502

501503
const action = useFetchData<RequestData>(
@@ -616,35 +618,37 @@ const ProDescriptions = <
616618
const className = context.getPrefixCls('pro-descriptions');
617619
return (
618620
<ErrorBoundary>
619-
<FormComponent
620-
key="form"
621-
form={props.editable?.form}
622-
component={false}
623-
submitter={false}
624-
{...formProps}
625-
onFinish={undefined}
626-
>
627-
<Descriptions
628-
className={className}
629-
{...rest}
630-
contentStyle={{
631-
minWidth: 0,
632-
...(contentStyle || {}),
633-
}}
634-
extra={
635-
rest.extra ? (
636-
<Space>
637-
{options}
638-
{rest.extra}
639-
</Space>
640-
) : (
641-
options
642-
)
643-
}
644-
title={title}
645-
items={children as DescriptionsItemType[]}
646-
/>
647-
</FormComponent>
621+
<ProConfigProvider valueTypeMap={{...proContext.valueTypeMap, ...ValueTypeToComponent}}>
622+
<FormComponent
623+
key="form"
624+
form={props.editable?.form}
625+
component={false}
626+
submitter={false}
627+
{...formProps}
628+
onFinish={undefined}
629+
>
630+
<Descriptions
631+
className={className}
632+
{...rest}
633+
contentStyle={{
634+
minWidth: 0,
635+
...(contentStyle || {}),
636+
}}
637+
extra={
638+
rest.extra ? (
639+
<Space>
640+
{options}
641+
{rest.extra}
642+
</Space>
643+
) : (
644+
options
645+
)
646+
}
647+
title={title}
648+
items={children as DescriptionsItemType[]}
649+
/>
650+
</FormComponent>
651+
</ProConfigProvider>
648652
</ErrorBoundary>
649653
);
650654
};

packages/field/src/ValueTypeToComponent.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ const ValueTypeToComponentMap: Record<string, ProRenderFieldPropsType> = {
5252
{...props}
5353
text={text}
5454
fieldProps={{
55-
status: props.status ? props.status : undefined,
55+
...props?.status && {status: props.status},
5656
...pickProProps(props.fieldProps),
5757
}}
5858
/>,
5959
formItemRender: (text, props) => <FieldProgress
6060
{...props}
6161
text={text}
6262
fieldProps={{
63-
status: props.status ? props.status : undefined,
63+
...props?.status && {status: props.status},
6464
...pickProProps(props.fieldProps),
6565
}}
6666
/>,

tests/descriptions/__snapshots__/index.test.tsx.snap

+119-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,34 @@ exports[`descriptions > 🏊 ProDescriptions support order 1`] = `
4949
class="ant-descriptions-item-content"
5050
style="min-width: 0;"
5151
>
52-
40
52+
<div
53+
aria-valuemax="100"
54+
aria-valuemin="0"
55+
aria-valuenow="40"
56+
class="ant-progress ant-progress-status-active ant-progress-line ant-progress-line-align-end ant-progress-line-position-outer ant-progress-show-info ant-progress-small"
57+
role="progressbar"
58+
style="min-width: 100px; max-width: 320px;"
59+
>
60+
<div
61+
class="ant-progress-outer"
62+
style="width: 100%;"
63+
>
64+
<div
65+
class="ant-progress-inner"
66+
>
67+
<div
68+
class="ant-progress-bg ant-progress-bg-outer"
69+
style="width: 40%; height: 6px; --progress-percent: 0.4;"
70+
/>
71+
</div>
72+
<span
73+
class="ant-progress-text ant-progress-text-end ant-progress-text-outer"
74+
title="40%"
75+
>
76+
40%
77+
</span>
78+
</div>
79+
</div>
5380
</span>
5481
</div>
5582
</td>
@@ -69,7 +96,51 @@ exports[`descriptions > 🏊 ProDescriptions support order 1`] = `
6996
class="ant-descriptions-item-content"
7097
style="min-width: 0;"
7198
>
72-
100
99+
<div
100+
aria-valuemax="100"
101+
aria-valuemin="0"
102+
aria-valuenow="100"
103+
class="ant-progress ant-progress-status-success ant-progress-line ant-progress-line-align-end ant-progress-line-position-outer ant-progress-show-info ant-progress-small"
104+
role="progressbar"
105+
style="min-width: 100px; max-width: 320px;"
106+
>
107+
<div
108+
class="ant-progress-outer"
109+
style="width: 100%;"
110+
>
111+
<div
112+
class="ant-progress-inner"
113+
>
114+
<div
115+
class="ant-progress-bg ant-progress-bg-outer"
116+
style="width: 100%; height: 6px; --progress-percent: 1;"
117+
/>
118+
</div>
119+
<span
120+
class="ant-progress-text ant-progress-text-end ant-progress-text-outer"
121+
>
122+
<span
123+
aria-label="check-circle"
124+
class="anticon anticon-check-circle"
125+
role="img"
126+
>
127+
<svg
128+
aria-hidden="true"
129+
data-icon="check-circle"
130+
fill="currentColor"
131+
focusable="false"
132+
height="1em"
133+
viewBox="64 64 896 896"
134+
width="1em"
135+
>
136+
<path
137+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
138+
/>
139+
</svg>
140+
</span>
141+
</span>
142+
</div>
143+
</div>
73144
</span>
74145
</div>
75146
</td>
@@ -93,7 +164,52 @@ exports[`descriptions > 🏊 ProDescriptions support order 1`] = `
93164
class="ant-descriptions-item-content"
94165
style="min-width: 0;"
95166
>
96-
-1
167+
<div
168+
aria-valuemax="100"
169+
aria-valuemin="0"
170+
aria-valuenow="-1"
171+
class="ant-progress ant-progress-status-exception ant-progress-line ant-progress-line-align-end ant-progress-line-position-outer ant-progress-show-info ant-progress-small"
172+
role="progressbar"
173+
style="min-width: 100px; max-width: 320px;"
174+
>
175+
<div
176+
class="ant-progress-outer"
177+
style="width: 100%;"
178+
>
179+
<div
180+
class="ant-progress-inner"
181+
>
182+
<div
183+
class="ant-progress-bg ant-progress-bg-outer"
184+
style="width: 0%; height: 6px; --progress-percent: 0;"
185+
/>
186+
</div>
187+
<span
188+
class="ant-progress-text ant-progress-text-end ant-progress-text-outer"
189+
>
190+
<span
191+
aria-label="close-circle"
192+
class="anticon anticon-close-circle"
193+
role="img"
194+
>
195+
<svg
196+
aria-hidden="true"
197+
data-icon="close-circle"
198+
fill="currentColor"
199+
fill-rule="evenodd"
200+
focusable="false"
201+
height="1em"
202+
viewBox="64 64 896 896"
203+
width="1em"
204+
>
205+
<path
206+
d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"
207+
/>
208+
</svg>
209+
</span>
210+
</span>
211+
</div>
212+
</div>
97213
</span>
98214
</div>
99215
</td>

0 commit comments

Comments
 (0)