diff --git a/components/descriptions/DescriptionsContext.ts b/components/descriptions/DescriptionsContext.ts new file mode 100644 index 0000000000..fdff05b6be --- /dev/null +++ b/components/descriptions/DescriptionsContext.ts @@ -0,0 +1,10 @@ +import React from 'react'; + +export interface DescriptionsContextProps { + labelStyle?: React.CSSProperties; + contentStyle?: React.CSSProperties; +} + +const DescriptionsContext = React.createContext({}); + +export default DescriptionsContext; diff --git a/components/descriptions/Row.tsx b/components/descriptions/Row.tsx index 28ac218ece..230925993d 100644 --- a/components/descriptions/Row.tsx +++ b/components/descriptions/Row.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import type { DescriptionsContextProps } from '.'; -import { DescriptionsContext } from '.'; import Cell from './Cell'; +import type { DescriptionsContextProps } from './DescriptionsContext'; +import DescriptionsContext from './DescriptionsContext'; import type { DescriptionsItemProps } from './Item'; interface CellConfig { diff --git a/components/descriptions/index.tsx b/components/descriptions/index.tsx index 2b5445e8db..fcca116429 100644 --- a/components/descriptions/index.tsx +++ b/components/descriptions/index.tsx @@ -8,17 +8,11 @@ import useResponsiveObserver, { responsiveArray } from '../_util/responsiveObser import warning from '../_util/warning'; import { ConfigContext } from '../config-provider'; import useSize from '../config-provider/hooks/useSize'; +import DescriptionsContext from './DescriptionsContext'; import DescriptionsItem from './Item'; import Row from './Row'; import useStyle from './style'; -export interface DescriptionsContextProps { - labelStyle?: React.CSSProperties; - contentStyle?: React.CSSProperties; -} - -export const DescriptionsContext = React.createContext({}); - const DEFAULT_COLUMN_MAP: Record = { xxl: 3, xl: 3, @@ -213,6 +207,9 @@ if (process.env.NODE_ENV !== 'production') { Descriptions.displayName = 'Descriptions'; } +export type { DescriptionsContextProps } from './DescriptionsContext'; +export { DescriptionsContext }; + Descriptions.Item = DescriptionsItem; export default Descriptions;