Skip to content

Commit 9ce02a8

Browse files
committed
删除 兼容代码
1 parent 7715438 commit 9ce02a8

File tree

64 files changed

+157
-611
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+157
-611
lines changed

packages/card/src/components/StatisticCard/index.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import type { StatisticProps } from '../Statistic';
99
import Statistic from '../Statistic';
1010
import { useStyle } from './style';
1111

12-
import 'antd/lib/divider/style';
13-
import 'antd/lib/statistic/style';
14-
1512
export type StatisticCardProps = {
1613
/** 图表配置 */
1714
chart?: React.ReactNode;

packages/card/src/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import type { ProCardProps } from './ProCard';
1414
import ProCard from './ProCard';
1515
import type { ProCardTabsProps } from './typing';
1616

17-
import 'antd/lib/card/style';
18-
1917
export { CheckCard, ProCard, Statistic, StatisticCard };
2018
export type {
2119
CheckCardGroupProps,

packages/descriptions/src/index.tsx

+7-17
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,23 @@ import {
1313
ErrorBoundary,
1414
InlineErrorFormItem,
1515
LabelIconTip,
16-
compareVersions,
1716
genCopyable,
1817
getFieldPropsOrFormItemProps,
1918
stringify,
2019
useEditableMap,
2120
} from '@ant-design/pro-utils';
2221
import type { DescriptionsProps, FormInstance, FormProps } from 'antd';
23-
import { ConfigProvider, Descriptions, Space, version } from 'antd';
22+
import { ConfigProvider, Descriptions, Space } from 'antd';
2423
import type { LabelTooltipType } from 'antd/lib/form/FormItemLabel';
2524
import toArray from 'rc-util/lib/Children/toArray';
2625
import get from 'rc-util/lib/utils/get';
2726
import React, { useContext, useEffect } from 'react';
2827
import type { RequestData } from './useFetchData';
2928
import useFetchData from './useFetchData';
3029

31-
// 兼容代码-----------
3230
import type { ProFieldFCMode } from '@ant-design/pro-provider';
3331
import { proTheme } from '@ant-design/pro-provider';
3432
import type { DescriptionsItemType } from 'antd/es/descriptions';
35-
import 'antd/lib/descriptions/style';
36-
//----------------------
3733

3834
// todo remove it
3935
export interface DescriptionsItemProps {
@@ -328,16 +324,13 @@ const schemaToDescriptionsItem = (
328324
emptyText?: React.ReactNode,
329325
) => {
330326
const options: JSX.Element[] = [];
331-
const isBigger58 = compareVersions(version, '5.8.0') >= 0;
332327
// 因为 Descriptions 只是个语法糖,children 是不会执行的,所以需要这里处理一下
333328
const children = items
334329
?.map?.((item, index) => {
335330
if (React.isValidElement(item)) {
336-
return isBigger58
337-
? {
338-
children: item,
339-
}
340-
: item;
331+
return {
332+
children: item,
333+
};
341334
}
342335
const {
343336
valueEnum,
@@ -389,7 +382,7 @@ const schemaToDescriptionsItem = (
389382
fieldMode === 'edit' ? text : genCopyable(text, item, text);
390383

391384
const field: DescriptionsItemType | JSX.Element =
392-
isBigger58 && valueType !== 'option'
385+
valueType !== 'option'
393386
? ({
394387
...restItem,
395388
key: restItem.key || restItem.label?.toString() || index,
@@ -623,7 +616,6 @@ const ProDescriptions = <
623616
}
624617

625618
const className = context.getPrefixCls('pro-descriptions');
626-
const isBigger58 = compareVersions(version, '5.8.0') >= 0;
627619
return (
628620
<ErrorBoundary>
629621
<FormComponent
@@ -651,10 +643,8 @@ const ProDescriptions = <
651643
)
652644
}
653645
title={title}
654-
items={isBigger58 ? (children as DescriptionsItemType[]) : undefined}
655-
>
656-
{isBigger58 ? null : (children as JSX.Element[])}
657-
</Descriptions>
646+
items={children as DescriptionsItemType[]}
647+
/>
658648
</FormComponent>
659649
</ErrorBoundary>
660650
);

packages/field/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"@ant-design/pro-provider": "2.13.5",
3434
"@ant-design/pro-utils": "2.15.4",
3535
"@babel/runtime": "^7.18.0",
36-
"@chenshuai2144/sketch-color": "^1.0.8",
3736
"classnames": "^2.3.2",
3837
"dayjs": "^1.11.10",
3938
"lodash.tonumber": "^4.0.3",

packages/field/src/components/Cascader/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import type { ProFieldFC } from '../../index';
2020
import type { FieldSelectProps } from '../Select';
2121
import { useFieldFetchData } from '../Select';
2222

23-
// 兼容代码-----------
24-
import 'antd/lib/cascader/style';
25-
//----------------------
26-
2723
export type GroupProps = {
2824
options?: RadioGroupProps['options'];
2925
radioType?: 'button' | 'radio';

packages/field/src/components/Checkbox/index.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {
1+
import { useToken } from '@ant-design/pro-provider';
2+
import {
23
objectToMap,
34
proFieldParsingText,
45
useStyle,
@@ -15,10 +16,6 @@ export type GroupProps = {
1516
options?: CheckboxGroupProps['options'];
1617
} & FieldSelectProps;
1718

18-
// 兼容代码-----------
19-
import { useToken } from '@ant-design/pro-provider';
20-
import 'antd/lib/checkbox/style';
21-
//----------------------
2219
/**
2320
* 多选组件
2421
*

packages/field/src/components/Code/index.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Input } from 'antd';
22
import React from 'react';
33
import type { ProFieldFC } from '../../index';
44

5-
// 兼容代码-----------
65
import { proTheme } from '@ant-design/pro-provider';
7-
import 'antd/lib/input/style';
8-
//----------------------
96

107
const languageFormat = (text: string, language: string) => {
118
if (typeof text !== 'string') {

packages/field/src/components/ColorPicker/index.tsx

+9-41
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { compareVersions } from '@ant-design/pro-utils';
2-
import type { ColorPickerProps } from 'antd';
3-
import { ColorPicker as ColorPickerV5, ConfigProvider, version } from 'antd';
1+
import type { ColorPickerProps } from 'antd';
2+
import { ColorPicker, ConfigProvider } from 'antd';
43
import classNames from 'classnames';
5-
import React, { useContext, useMemo } from 'react';
4+
import React, { useContext } from 'react';
65
import type { ProFieldFC } from '../../index';
7-
import { ColorPicker as ColorPickerV4 } from './old';
8-
// https://ant.design/components/color-picker-cn 示例颜色
6+
97
const DEFAULT_PRESETS = {
108
label: 'Recommended',
119
colors: [
@@ -31,25 +29,7 @@ const DEFAULT_PRESETS = {
3129
'#EB2F964D',
3230
],
3331
};
34-
/**
35-
* 判断是否是 5.5.0 以上的版本
36-
* @returns
37-
*/
38-
function IsIt_Render_V5() {
39-
return compareVersions(version, '5.5.0') > -1;
40-
}
41-
/**
42-
* 获取颜色组件
43-
* @param {boolean} [old=false] 是否使用旧版本
44-
* @return {*}
45-
*/
46-
function getColorPicker(old: boolean = false) {
47-
if ((typeof old === 'undefined' || old === false) && IsIt_Render_V5()) {
48-
return ColorPickerV5;
49-
}
50-
return ColorPickerV4;
51-
}
52-
// const ColorPicker = getColorPicker();
32+
5333
/**
5434
* 颜色组件
5535
* Antd > 5.5.0 的版本 使用 antd 的 ColorPicker
@@ -60,28 +40,16 @@ function getColorPicker(old: boolean = false) {
6040
const FieldColorPicker: ProFieldFC<
6141
{
6242
text: string;
63-
/** 是否使用旧版本 */
64-
old?: boolean;
6543
} & Partial<ColorPickerProps>
66-
> = (
67-
{ text, mode: type, render, renderFormItem, fieldProps, old },
68-
ref: any,
69-
) => {
44+
> = ({ text, mode: type, render, renderFormItem, fieldProps }, ref: any) => {
7045
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
71-
const ColorPicker = React.useMemo(() => getColorPicker(old), [old]);
7246
const prefixCls = getPrefixCls('pro-field-color-picker');
73-
// 5.5.0 以上版本追加 className
74-
const className = useMemo(() => {
75-
if (old) return '';
76-
return classNames({ [prefixCls]: IsIt_Render_V5() });
77-
}, [prefixCls, old]);
47+
7848
if (type === 'read') {
7949
const dom = (
8050
<ColorPicker
8151
value={text}
82-
mode="read"
83-
ref={ref}
84-
className={className}
52+
className={classNames({ [prefixCls]: true })}
8553
// 设置无法 open
8654
open={false}
8755
/>
@@ -100,7 +68,7 @@ const FieldColorPicker: ProFieldFC<
10068
presets={[DEFAULT_PRESETS]}
10169
{...fieldProps}
10270
style={style}
103-
className={className}
71+
className={classNames({ [prefixCls]: true })}
10472
/>
10573
);
10674
if (renderFormItem) {

packages/field/src/components/DatePicker/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
1010
import React, { useState } from 'react';
1111
import type { ProFieldFC, ProFieldLightProps } from '../../index';
1212

13-
// 兼容代码-----------
14-
import 'antd/lib/date-picker/style';
15-
//----------------------
16-
1713
dayjs.extend(weekOfYear);
1814

1915
const formatDate = (text: any, format: any) => {

packages/field/src/components/Digit/index.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1+
import { useIntl } from '@ant-design/pro-provider';
12
import { isNil } from '@ant-design/pro-utils';
23
import { InputNumber } from 'antd';
34
import omit from 'omit.js';
45
import React, { useCallback } from 'react';
56
import type { ProFieldFC } from '../../index';
67

7-
// 兼容代码-----------
8-
import { useIntl } from '@ant-design/pro-provider';
9-
import 'antd/lib/input-number/style';
10-
//----------------------
11-
128
export type FieldDigitProps = {
139
text: number;
1410
placeholder?: string;

packages/field/src/components/DigitRange/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
44
import React from 'react';
55
import type { ProFieldFC } from '../../index';
66

7-
// 兼容代码-----------
8-
import 'antd/lib/input-number/style';
9-
//----------------------
10-
117
export type Value = string | number | undefined | null;
128

139
export type ValuePair = Value[];

packages/field/src/components/FromNow/index.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ import { parseValueToDay } from '@ant-design/pro-utils';
33
import { DatePicker, Tooltip } from 'antd';
44
import dayjs from 'dayjs';
55
import relativeTime from 'dayjs/plugin/relativeTime';
6-
import type { ProFieldFC } from '../../index';
7-
8-
// 兼容代码-----------
9-
import 'antd/lib/date-picker/style';
106
import React from 'react';
11-
//----------------------
7+
import type { ProFieldFC } from '../../index';
128

139
dayjs.extend(relativeTime);
1410
/**

packages/field/src/components/Image/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { Image, Input } from 'antd';
33
import React from 'react';
44
import type { ProFieldFC } from '../../index';
55

6-
// 兼容代码-----------
7-
import 'antd/lib/image/style';
8-
//----------------------
9-
106
export type FieldImageProps = {
117
text: string;
128
width?: number;

packages/field/src/components/Money/index.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
66
import React, { useCallback, useMemo } from 'react';
77
import type { ProFieldFC } from '../../index';
88

9-
// 兼容代码-----------
10-
import 'antd/lib/input-number/style';
11-
import 'antd/lib/popover/style';
12-
//----------------------
13-
14-
import { openVisibleCompatible } from '@ant-design/pro-utils';
15-
169
export type FieldMoneyProps = {
1710
text: number;
1811
moneySymbol?: boolean;
@@ -252,12 +245,10 @@ const InputNumberPopover = React.forwardRef<
252245
value,
253246
});
254247

255-
const props = openVisibleCompatible(dom ? open : false);
256-
257248
return (
258249
<Popover
259250
placement="topLeft"
260-
{...props}
251+
open={dom ? open : false}
261252
trigger={['focus', 'click']}
262253
content={dom}
263254
getPopupContainer={(triggerNode) => {

packages/field/src/components/Options/index.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1+
import { proTheme } from '@ant-design/pro-provider';
12
import { ConfigProvider } from 'antd';
23
import React, { useContext, useImperativeHandle } from 'react';
34
import type { ProFieldFC } from '../../index';
45

5-
// 兼容代码-----------
6-
import { proTheme } from '@ant-design/pro-provider';
7-
import 'antd/lib/space/style';
8-
//----------------------
9-
106
const addArrayKeys = (doms: React.ReactNode[]) =>
117
doms.map((dom, index) => {
128
if (!React.isValidElement(dom)) {

packages/field/src/components/Password/index.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
55
import React from 'react';
66
import type { ProFieldFC } from '../../index';
77

8-
// 兼容代码-----------
9-
import 'antd/lib/input/style';
10-
import 'antd/lib/space/style';
11-
//----------------------
12-
138
/**
149
* 最基本的组件,就是个普通的 Input.Password
1510
*

packages/field/src/components/Percent/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import {
1010
getSymbolByRealValue,
1111
} from './util';
1212

13-
// 兼容代码-----------
14-
import 'antd/lib/input-number/style';
15-
//------------
16-
1713
export type PercentPropInt = {
1814
prefix?: ReactNode;
1915
suffix?: ReactNode;

packages/field/src/components/Progress/index.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import toNumber from 'lodash.tonumber';
44
import React, { useMemo } from 'react';
55
import type { ProFieldFC } from '../../index';
66

7-
// 兼容代码-----------
8-
import 'antd/lib/input-number/style';
9-
import 'antd/lib/progress/style';
10-
//------------
11-
127
export function getProgressStatus(
138
text: number,
149
): 'success' | 'exception' | 'normal' | 'active' {

packages/field/src/components/Radio/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import type { ProFieldFC } from '../../index';
1111
import type { FieldSelectProps } from '../Select';
1212
import { useFieldFetchData } from '../Select';
1313

14-
// 兼容代码-----------
15-
import 'antd/lib/radio/style';
16-
//------------
17-
1814
export type GroupProps = {
1915
options?: RadioGroupProps['options'];
2016
radioType?: RadioGroupProps['optionType'];

packages/field/src/components/RangePicker/index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import dayjs from 'dayjs';
99
import React, { useCallback } from 'react';
1010
import type { ProFieldFC, ProFieldLightProps } from '../../index';
1111

12-
// 兼容代码-----------
13-
import 'antd/lib/date-picker/style';
14-
//------------
15-
1612
/**
1713
* 日期范围选择组件
1814
*

0 commit comments

Comments
 (0)