@@ -4,14 +4,14 @@ import {
4
4
getClasses ,
5
5
useWatch ,
6
6
} from '@pkg/shared' ;
7
- import type { CalendarLocale , CalendarProps } from './calendar.types' ;
8
7
import { getStartOfMonth , getClassNames } from '@tool-pack/basic' ;
9
- import { ConfigContext } from '~/config-provider/config.context' ;
10
8
import { CalendarHeader } from '~/calendar/components/Header' ;
9
+ import { useLocale } from '~/config-provider/useLocale' ;
10
+ import type { CalendarProps } from './calendar.types' ;
11
11
import { CalendarTable } from '~/calendar/components' ;
12
12
import type { RequiredPart } from '@tool-pack/types' ;
13
- import React , { useContext , useMemo } from 'react ' ;
14
- import calendarLocale from './locale/en-US ' ;
13
+ import EnUS from './locale/en-US ' ;
14
+ import React from 'react ' ;
15
15
16
16
const cls = getClasses ( 'calendar' , [ 'date-cell' ] , [ 'prev-month' , 'next-month' ] ) ;
17
17
const defaultProps = {
@@ -24,7 +24,6 @@ export const Calendar: React.FC<CalendarProps> = React.forwardRef<
24
24
HTMLDivElement ,
25
25
CalendarProps
26
26
> ( ( props , ref ) => {
27
- const contextLocale = useContext ( ConfigContext ) . locale ;
28
27
const {
29
28
locale : propsLocale ,
30
29
month : propsMonth ,
@@ -38,11 +37,7 @@ export const Calendar: React.FC<CalendarProps> = React.forwardRef<
38
37
value,
39
38
} = props as RequiredPart < CalendarProps , keyof typeof defaultProps > ;
40
39
41
- const locale = useMemo < CalendarLocale > (
42
- ( ) =>
43
- Object . assign ( { } , calendarLocale , contextLocale . calendar , propsLocale ) ,
44
- [ contextLocale . calendar , propsLocale ] ,
45
- ) ;
40
+ const locale = Object . assign ( useLocale ( 'calendar' , EnUS ) , propsLocale ) ;
46
41
47
42
const [ valueRef , setValueRef ] = useStateRef ( value ) ;
48
43
const [ month , setMonth ] = useFollowingState (
0 commit comments