mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-01 06:49:32 +08:00
38474628fd
* fix: prepend use-client directive for with Next.js App Router * Update components/affix/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/badge/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/divider/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/cascader/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/list/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/qrcode/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/select/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/steps/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/time-picker/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/transfer/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/tree-select/index.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
102 lines
2.7 KiB
TypeScript
102 lines
2.7 KiB
TypeScript
'use client';
|
|
|
|
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
|
import * as React from 'react';
|
|
import warning from '../_util/warning';
|
|
import type { PickerLocale as DatePickerLocale } from '../date-picker/generatePicker';
|
|
import type { TransferLocale as TransferLocaleForEmpty } from '../empty';
|
|
import type { ModalLocale } from '../modal/locale';
|
|
import { changeConfirmLocale } from '../modal/locale';
|
|
import type { PaginationLocale } from '../pagination/Pagination';
|
|
import type { PopconfirmLocale } from '../popconfirm/PurePanel';
|
|
import type { TableLocale } from '../table/interface';
|
|
import type { TourLocale } from '../tour/interface';
|
|
import type { TransferLocale } from '../transfer';
|
|
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 {
|
|
locale: string;
|
|
Pagination?: PaginationLocale;
|
|
DatePicker?: DatePickerLocale;
|
|
TimePicker?: Record<string, any>;
|
|
Calendar?: Record<string, any>;
|
|
Table?: TableLocale;
|
|
Modal?: ModalLocale;
|
|
Tour?: TourLocale;
|
|
Popconfirm?: PopconfirmLocale;
|
|
Transfer?: TransferLocale;
|
|
Select?: Record<string, any>;
|
|
Upload?: UploadLocale;
|
|
Empty?: TransferLocaleForEmpty;
|
|
global?: Record<string, any>;
|
|
PageHeader?: { back: string };
|
|
Icon?: Record<string, any>;
|
|
Text?: {
|
|
edit?: any;
|
|
copy?: any;
|
|
copied?: any;
|
|
expand?: any;
|
|
};
|
|
Form?: {
|
|
optional?: string;
|
|
defaultValidateMessages: ValidateMessages;
|
|
};
|
|
Image?: {
|
|
preview: string;
|
|
};
|
|
QRCode?: {
|
|
expired: string;
|
|
refresh: string;
|
|
};
|
|
ColorPicker?: {
|
|
presetEmpty: string;
|
|
};
|
|
}
|
|
|
|
export interface LocaleProviderProps {
|
|
locale: Locale;
|
|
children?: React.ReactNode;
|
|
/** @internal */
|
|
_ANT_MARK__?: string;
|
|
}
|
|
|
|
const LocaleProvider: React.FC<LocaleProviderProps> = (props) => {
|
|
const { locale = {} as Locale, children, _ANT_MARK__ } = props;
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
warning(
|
|
_ANT_MARK__ === ANT_MARK,
|
|
'LocaleProvider',
|
|
'`LocaleProvider` is deprecated. Please use `locale` with `ConfigProvider` instead: http://u.ant.design/locale',
|
|
);
|
|
}
|
|
|
|
React.useEffect(() => {
|
|
changeConfirmLocale(locale && locale.Modal);
|
|
return () => {
|
|
changeConfirmLocale();
|
|
};
|
|
}, [locale]);
|
|
|
|
const getMemoizedContextValue = React.useMemo<LocaleContextProps>(
|
|
() => ({ ...locale, exist: true }),
|
|
[locale],
|
|
);
|
|
|
|
return (
|
|
<LocaleContext.Provider value={getMemoizedContextValue}>{children}</LocaleContext.Provider>
|
|
);
|
|
};
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
LocaleProvider.displayName = 'LocaleProvider';
|
|
}
|
|
|
|
export default LocaleProvider;
|