chore: Remove locale-provider (#41289)

* chore: rm locale-receiver

* chore: export useLocale in locale

* chore: comment

* chore: rm locale-provider dir

* docs: rm locale-provider in migration document

* chore: fix regexp

---------

Co-authored-by: MadCcc <1075746765@qq.com>
This commit is contained in:
lijianan 2023-03-21 13:08:43 +08:00 committed by GitHub
parent f829e40110
commit f6c235462e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 30 additions and 40 deletions

View File

@ -10,7 +10,7 @@ import type {
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import CalendarHeader from './Header';
import enUS from './locale/en_US';

View File

@ -5,7 +5,6 @@ import React from 'react';
import DatePicker from '..';
import ConfigProvider from '../../config-provider';
import type { Locale } from '../../locale';
import LocaleProvider from '../../locale';
import locale from '../../locale/zh_CN';
import jaJP from '../../locale/ja_JP';
import zhTW from '../locale/zh_TW';
@ -31,9 +30,9 @@ describe('Picker format by locale', () => {
function matchPicker(name: string, Picker: typeof MonthPicker | typeof WeekPicker, props?: any) {
it(name, () => {
const { container } = render(
<LocaleProvider locale={myLocale as Locale}>
<ConfigProvider locale={myLocale as Locale}>
<Picker value={date} {...props} />
</LocaleProvider>,
</ConfigProvider>,
);
expect(container.firstChild).toMatchSnapshot();
});

View File

@ -13,7 +13,7 @@ import { ConfigContext } from '../../config-provider';
import DisabledContext from '../../config-provider/DisabledContext';
import SizeContext from '../../config-provider/SizeContext';
import { FormItemInputContext } from '../../form/context';
import useLocale from '../../locale/useLocale';
import { useLocale } from '../../locale';
import { useCompactItemContext } from '../../space/Compact';
import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils';
import warning from '../../_util/warning';

View File

@ -13,7 +13,7 @@ import { ConfigContext } from '../../config-provider';
import DisabledContext from '../../config-provider/DisabledContext';
import SizeContext from '../../config-provider/SizeContext';
import { FormItemInputContext } from '../../form/context';
import useLocale from '../../locale/useLocale';
import { useLocale } from '../../locale';
import { useCompactItemContext } from '../../space/Compact';
import type { InputStatus } from '../../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils';

View File

@ -1,7 +1,7 @@
import classNames from 'classnames';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import DefaultEmptyImg from './empty';
import SimpleEmptyImg from './simple';

View File

@ -4,7 +4,7 @@ import * as React from 'react';
import type { ColProps } from '../grid/col';
import Col from '../grid/col';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import type { TooltipProps } from '../tooltip';
import Tooltip from '../tooltip';
import type { FormContextProps } from './context';

View File

@ -1,6 +0,0 @@
// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop
import useLocale from '../locale/useLocale';
export * from '../locale/useLocale';
export default useLocale;

View File

@ -1,6 +0,0 @@
// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop
import locale from '../locale';
export * from '../locale';
export default locale;

View File

@ -1,7 +1,7 @@
import React, { memo, useContext } from 'react';
import { fireEvent, pureRender } from '../../../tests/utils';
import LocaleProvider from '../../locale';
import LocaleContext from '../../locale/context';
import LocaleProvider from '..';
import LocaleContext from '../context';
let innerCount = 0;
let outerCount = 0;

View File

@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { Modal } from '../..';
import { waitFakeTimer, render, fireEvent } from '../../../tests/utils';
import ConfigProvider from '../../config-provider';
import zhCN from '../../locale/zh_CN';
import zhCN from '../zh_CN';
const Demo: React.FC<{ type: string }> = ({ type }) => {
useEffect(() => {

View File

@ -68,8 +68,8 @@ import preParsePostFormat from 'dayjs/plugin/preParsePostFormat';
import MockDate from 'mockdate';
import React from 'react';
import { render } from '../../../tests/utils';
import type { Locale } from '../../locale';
import LocaleProvider from '../../locale';
import type { Locale } from '..';
import LocaleProvider from '..';
import {
Calendar,
DatePicker,

View File

@ -14,6 +14,8 @@ import type { UploadLocale } from '../upload/interface';
import type { LocaleContextProps } from './context';
import LocaleContext from './context';
export { default as useLocale } from './useLocale';
export const ANT_MARK = 'internalMark';
export interface Locale {

View File

@ -5,7 +5,6 @@ import DatePicker from '../date-picker/locale/my_MM';
import type { Locale } from '.';
import TimePicker from '../time-picker/locale/my_MM';
const typeTemplate = '${label} သည် တရားဝင် ${type} မဟုတ်ပါ';
const localeValues: Locale = {

View File

@ -5,7 +5,7 @@ import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';
import classNames from 'classnames';
import * as React from 'react';
import ConfigProvider from '../config-provider';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import ActionButton from '../_util/ActionButton';
import { getTransitionName } from '../_util/motion';
import warning from '../_util/warning';

View File

@ -7,7 +7,7 @@ import * as React from 'react';
import Button from '../button';
import { convertLegacyProps } from '../button/button';
import { ConfigContext } from '../config-provider';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import { ConfirmContent } from './ConfirmDialog';
import { getConfirmLocale } from './locale';
import type { ModalFuncProps, ModalProps } from './Modal';

View File

@ -9,7 +9,7 @@ import enUS from 'rc-pagination/lib/locale/en_US';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import useBreakpoint from '../grid/hooks/useBreakpoint';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import { MiddleSelect, MiniSelect } from './Select';
import useStyle from './style';

View File

@ -6,7 +6,7 @@ import Button from '../button';
import { convertLegacyProps } from '../button/button';
import { ConfigContext } from '../config-provider';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import PopoverPurePanel from '../popover/PurePanel';
import ActionButton from '../_util/ActionButton';
import { getRenderPropValue } from '../_util/getRenderPropValue';

View File

@ -6,7 +6,7 @@ import warning from '../_util/warning';
import Button from '../button';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import Spin from '../spin';
import theme from '../theme';
import type { QRCodeProps, QRPropsCanvas } from './interface';

View File

@ -5,4 +5,4 @@ const locale: TimePickerLocale = {
rangePlaceholder: ['စတင်ချိန်', 'ကုန်ဆုံးချိန်'],
};
export default locale;
export default locale;

View File

@ -5,7 +5,7 @@ import React from 'react';
import type { ButtonProps } from '../button';
import Button from '../button';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import type { TourStepProps } from './interface';
function isValidNode(node: ReactNode): boolean {

View File

@ -4,7 +4,7 @@ import * as React from 'react';
import type { KeyWiseTransferItem } from '.';
import Checkbox from '../checkbox';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import TransButton from '../_util/transButton';
type ListItemProps<RecordType> = {

View File

@ -11,7 +11,7 @@ import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import type { FormItemStatusContextProps } from '../form/context';
import { FormItemInputContext } from '../form/context';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import type { PaginationType } from './interface';
import type { TransferListProps } from './list';
import List from './list';

View File

@ -7,7 +7,7 @@ import { flushSync } from 'react-dom';
import { ConfigContext } from '../config-provider';
import DisabledContext from '../config-provider/DisabledContext';
import defaultLocale from '../locale/en_US';
import useLocale from '../locale/useLocale';
import { useLocale } from '../locale';
import warning from '../_util/warning';
import type { RcFile, ShowUploadListInterface, UploadChangeParam, UploadFile } from './interface';
import { UploadProps } from './interface';

View File

@ -94,7 +94,7 @@ return (
| 简体中文 | zh_CN |
| 繁体中文(中国香港) | zh_HK |
| 繁体中文(中国台湾) | zh_TW |
| 缅甸语 | my_MM |
| 缅甸语 | my_MM |
具体的使用方法请参考 [ConfigProvider 文档](/components/config-provider-cn)。

View File

@ -122,6 +122,7 @@ This document will help you upgrade from antd `4.x` version to antd `5.x` versio
#### Component refactoring and removal
- Remove `locale-provider` Directory. `LocaleProvider` was removed in v4, please use `ConfigProvider` instead.
- Move Comment component into `@ant-design/compatible`.
- Move PageHeader component into `@ant-design/pro-components`.

View File

@ -114,6 +114,7 @@ title: 从 v4 到 v5
#### 组件重构与移除
- 移除 `locale-provider` 目录。`LocaleProvider` 在 v4 中已移除,请使用 `ConfigProvider` 替代。
- 移除 Comment 组件,移至 `@ant-design/compatible` 中维护。
- 移除 PageHeader 组件,移至 `@ant-design/pro-components` 中维护。

View File

@ -1,6 +1,6 @@
const antd = require('./components');
const req = require.context('./components', true, /^\.\/locale\/.+_.+\.tsx?$/);
const req = require.context('./components', true, /^\.\/locale\/[A-Za-z]+_[A-Za-z]+\.tsx?$/);
antd.locales = {};

View File

@ -30,7 +30,7 @@ const EmptyElement = React.createElement('div');
const styleFiles = glob.globSync(
path.join(
process.cwd(),
'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)',
'components/!(version|config-provider|icon|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)',
),
);

View File

@ -18,7 +18,7 @@ const EmptyElement = React.createElement('div');
const styleFiles = glob.globSync(
path.join(
process.cwd(),
'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)',
'components/!(version|config-provider|icon|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)',
),
);