Browse Source

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>
pull/41371/head
lijianan 2 years ago
committed by GitHub
parent
commit
f6c235462e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/calendar/generateCalendar.tsx
  2. 5
      components/date-picker/__tests__/other.test.tsx
  3. 2
      components/date-picker/generatePicker/generateRangePicker.tsx
  4. 2
      components/date-picker/generatePicker/generateSinglePicker.tsx
  5. 2
      components/empty/index.tsx
  6. 2
      components/form/FormItemLabel.tsx
  7. 6
      components/locale-provider/LocaleReceiver.ts
  8. 6
      components/locale-provider/index.ts
  9. 0
      components/locale/__tests__/__snapshots__/index.test.tsx.snap
  10. 4
      components/locale/__tests__/cached-context.test.tsx
  11. 2
      components/locale/__tests__/config.test.tsx
  12. 4
      components/locale/__tests__/index.test.tsx
  13. 2
      components/locale/index.tsx
  14. 1
      components/locale/my_MM.ts
  15. 2
      components/modal/ConfirmDialog.tsx
  16. 2
      components/modal/PurePanel.tsx
  17. 2
      components/pagination/Pagination.tsx
  18. 2
      components/popconfirm/PurePanel.tsx
  19. 2
      components/qrcode/index.tsx
  20. 2
      components/time-picker/locale/my_MM.ts
  21. 2
      components/tour/panelRender.tsx
  22. 2
      components/transfer/ListItem.tsx
  23. 2
      components/transfer/index.tsx
  24. 2
      components/upload/Upload.tsx
  25. 2
      docs/react/i18n.zh-CN.md
  26. 1
      docs/react/migration-v5.en-US.md
  27. 1
      docs/react/migration-v5.zh-CN.md
  28. 2
      index-with-locales.js
  29. 2
      scripts/check-cssinjs.js
  30. 2
      scripts/collect-token-statistic.js

2
components/calendar/generateCalendar.tsx

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

5
components/date-picker/__tests__/other.test.tsx

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

2
components/date-picker/generatePicker/generateRangePicker.tsx

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

2
components/date-picker/generatePicker/generateSinglePicker.tsx

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

2
components/empty/index.tsx

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

2
components/form/FormItemLabel.tsx

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

6
components/locale-provider/LocaleReceiver.ts

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

6
components/locale-provider/index.ts

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

0
components/locale-provider/__tests__/__snapshots__/index.test.tsx.snap → components/locale/__tests__/__snapshots__/index.test.tsx.snap

4
components/locale-provider/__tests__/cached-context.test.tsx → components/locale/__tests__/cached-context.test.tsx

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

2
components/locale-provider/__tests__/config.test.tsx → components/locale/__tests__/config.test.tsx

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

4
components/locale-provider/__tests__/index.test.tsx → components/locale/__tests__/index.test.tsx

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

2
components/locale/index.tsx

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

1
components/locale/my_MM.ts

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

2
components/modal/ConfirmDialog.tsx

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

2
components/modal/PurePanel.tsx

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

2
components/pagination/Pagination.tsx

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

2
components/popconfirm/PurePanel.tsx

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

2
components/qrcode/index.tsx

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

2
components/time-picker/locale/my_MM.ts

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

2
components/tour/panelRender.tsx

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

2
components/transfer/ListItem.tsx

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

2
components/transfer/index.tsx

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

2
components/upload/Upload.tsx

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

2
docs/react/i18n.zh-CN.md

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

1
docs/react/migration-v5.en-US.md

@ -122,6 +122,7 @@ This document will help you upgrade from antd `4.x` version to antd `5.x` versio
#### Component refactoring and removal #### 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 Comment component into `@ant-design/compatible`.
- Move PageHeader component into `@ant-design/pro-components`. - Move PageHeader component into `@ant-design/pro-components`.

1
docs/react/migration-v5.zh-CN.md

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

2
index-with-locales.js

@ -1,6 +1,6 @@
const antd = require('./components'); 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 = {}; antd.locales = {};

2
scripts/check-cssinjs.js

@ -30,7 +30,7 @@ const EmptyElement = React.createElement('div');
const styleFiles = glob.globSync( const styleFiles = glob.globSync(
path.join( path.join(
process.cwd(), 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)',
), ),
); );

2
scripts/collect-token-statistic.js

@ -18,7 +18,7 @@ const EmptyElement = React.createElement('div');
const styleFiles = glob.globSync( const styleFiles = glob.globSync(
path.join( path.join(
process.cwd(), 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)',
), ),
); );

Loading…
Cancel
Save