Skip to content

Commit 8cf44c1

Browse files
authored
refactor: solve picker circular dependency issue (#650)
1 parent cd766da commit 8cf44c1

File tree

9 files changed

+16
-8
lines changed

9 files changed

+16
-8
lines changed

src/panels/DecadePanel/DecadeBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import type { GenerateConfig } from '../../generate';
3-
import { DECADE_DISTANCE_COUNT, DECADE_UNIT_DIFF } from '.';
3+
import { DECADE_DISTANCE_COUNT, DECADE_UNIT_DIFF } from './constant';
44
import PanelBody from '../PanelBody';
55
import type { CellRender, Locale } from '../../interface';
66

src/panels/DecadePanel/DecadeHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import Header from '../Header';
33
import type { GenerateConfig } from '../../generate';
4-
import { DECADE_DISTANCE_COUNT } from '.';
4+
import { DECADE_DISTANCE_COUNT } from './constant';
55
import PanelContext from '../../PanelContext';
66

77
export type YearHeaderProps<DateType> = {

src/panels/DecadePanel/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const DECADE_UNIT_DIFF = 10;
2+
export const DECADE_DISTANCE_COUNT = DECADE_UNIT_DIFF * 10;

src/panels/DecadePanel/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import DecadeHeader from './DecadeHeader';
33
import DecadeBody, { DECADE_COL_COUNT } from './DecadeBody';
44
import type { PanelSharedProps } from '../../interface';
55
import { createKeyDownHandler } from '../../utils/uiUtil';
6+
import { DECADE_DISTANCE_COUNT, DECADE_UNIT_DIFF } from './constant';
67

78
export type DecadePanelProps<DateType> = PanelSharedProps<DateType>;
89

9-
export const DECADE_UNIT_DIFF = 10;
10-
export const DECADE_DISTANCE_COUNT = DECADE_UNIT_DIFF * 10;
10+
export {
11+
DECADE_DISTANCE_COUNT,
12+
DECADE_UNIT_DIFF
13+
};
14+
1115

1216
function DecadePanel<DateType>(props: DecadePanelProps<DateType>) {
1317
const {

src/panels/YearPanel/YearBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import type { GenerateConfig } from '../../generate';
3-
import { YEAR_DECADE_COUNT } from '.';
3+
import { YEAR_DECADE_COUNT } from './constant';
44
import type { CellRender, Locale, NullableDateType } from '../../interface';
55
import useCellClassName from '../../hooks/useCellClassName';
66
import { formatValue, isSameYear } from '../../utils/dateUtil';

src/panels/YearPanel/YearHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import Header from '../Header';
33
import type { GenerateConfig } from '../../generate';
4-
import { YEAR_DECADE_COUNT } from '.';
4+
import { YEAR_DECADE_COUNT } from './constant';
55
import PanelContext from '../../PanelContext';
66

77
export type YearHeaderProps<DateType> = {

src/panels/YearPanel/constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const YEAR_DECADE_COUNT = 10;

src/panels/YearPanel/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import YearHeader from './YearHeader';
33
import YearBody, { YEAR_COL_COUNT } from './YearBody';
44
import type { PanelSharedProps, PanelMode, CellRender } from '../../interface';
55
import { createKeyDownHandler } from '../../utils/uiUtil';
6+
import { YEAR_DECADE_COUNT } from './constant';
67

78
export type YearPanelProps<DateType> = {
89
sourceMode: PanelMode;
910
cellRender?: CellRender<DateType>;
1011
} & PanelSharedProps<DateType>;
1112

12-
export const YEAR_DECADE_COUNT = 10;
13+
export { YEAR_DECADE_COUNT };
1314

1415
function YearPanel<DateType>(props: YearPanelProps<DateType>) {
1516
const {

src/utils/dateUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { DECADE_UNIT_DIFF } from '../panels/DecadePanel/index';
21
import type { PanelMode, NullableDateType, PickerMode, Locale, CustomFormat } from '../interface';
32
import type { GenerateConfig } from '../generate';
3+
import { DECADE_UNIT_DIFF } from '../panels/DecadePanel/constant';
44

55
export const WEEK_DAY_COUNT = 7;
66

0 commit comments

Comments
 (0)