mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
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:
parent
f829e40110
commit
f6c235462e
@ -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,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();
|
||||||
});
|
});
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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';
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop
|
|
||||||
import useLocale from '../locale/useLocale';
|
|
||||||
|
|
||||||
export * from '../locale/useLocale';
|
|
||||||
|
|
||||||
export default useLocale;
|
|
@ -1,6 +0,0 @@
|
|||||||
// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop
|
|
||||||
import locale from '../locale';
|
|
||||||
|
|
||||||
export * from '../locale';
|
|
||||||
|
|
||||||
export default locale;
|
|
@ -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,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(() => {
|
@ -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,
|
@ -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 {
|
||||||
|
@ -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 = {
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
@ -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 {
|
||||||
|
@ -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> = {
|
||||||
|
@ -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';
|
||||||
|
@ -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';
|
||||||
|
@ -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`.
|
||||||
|
|
||||||
|
@ -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` 中维护。
|
||||||
|
|
||||||
|
@ -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 = {};
|
||||||
|
|
||||||
|
@ -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)',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -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…
Reference in New Issue
Block a user