Browse Source

refactor: solve circular reference of Description (#42812)

* refactor: solve circular reference of Description

* refactor: solve circular reference of Table

* Revert "refactor: solve circular reference of Table"

This reverts commit 7664b01645.

* chore: add export
pull/43176/head
Zack Chang 1 year ago
committed by GitHub
parent
commit
875a221c62
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      components/descriptions/DescriptionsContext.ts
  2. 4
      components/descriptions/Row.tsx
  3. 11
      components/descriptions/index.tsx

10
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<DescriptionsContextProps>({});
export default DescriptionsContext;

4
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 {

11
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<DescriptionsContextProps>({});
const DEFAULT_COLUMN_MAP: Record<Breakpoint, number> = {
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;

Loading…
Cancel
Save