Browse Source

chore: code style optimization (#43457)

* chore: Code style optimization

* style: code optimize
pull/43458/head
thinkasany 1 year ago
committed by GitHub
parent
commit
b139dec663
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      components/descriptions/Cell.tsx
  2. 41
      components/descriptions/index.tsx
  3. 3
      components/tooltip/index.tsx

27
components/descriptions/Cell.tsx

@ -19,19 +19,20 @@ export interface CellProps {
colon?: boolean;
}
const Cell: React.FC<CellProps> = ({
itemPrefixCls,
component,
span,
className,
style,
labelStyle,
contentStyle,
bordered,
label,
content,
colon,
}) => {
const Cell: React.FC<CellProps> = (props) => {
const {
itemPrefixCls,
component,
span,
className,
style,
labelStyle,
contentStyle,
bordered,
label,
content,
colon,
} = props;
const Component = component as any;
if (bordered) {

41
components/descriptions/index.tsx

@ -115,23 +115,28 @@ export interface DescriptionsProps {
contentStyle?: React.CSSProperties;
}
function Descriptions({
prefixCls: customizePrefixCls,
title,
extra,
column = DEFAULT_COLUMN_MAP,
colon = true,
bordered,
layout,
children,
className,
rootClassName,
style,
size: customizeSize,
labelStyle,
contentStyle,
...restProps
}: DescriptionsProps) {
type CompoundedComponent = React.FC<DescriptionsProps> & {
Item: typeof DescriptionsItem;
};
const Descriptions: CompoundedComponent = (props) => {
const {
prefixCls: customizePrefixCls,
title,
extra,
column = DEFAULT_COLUMN_MAP,
colon = true,
bordered,
layout,
children,
className,
rootClassName,
style,
size: customizeSize,
labelStyle,
contentStyle,
...restProps
} = props;
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('descriptions', customizePrefixCls);
const [screens, setScreens] = React.useState<ScreenMap>({});
@ -207,7 +212,7 @@ function Descriptions({
</div>
</DescriptionsContext.Provider>,
);
}
};
if (process.env.NODE_ENV !== 'production') {
Descriptions.displayName = 'Descriptions';

3
components/tooltip/index.tsx

@ -10,6 +10,7 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
import type { CSSProperties } from 'react';
import * as React from 'react';
import type { PresetColorType } from '../_util/colors';
import type { RenderFunction } from '../_util/getRenderPropValue';
import { getTransitionName } from '../_util/motion';
import type { AdjustOverflow, PlacementsConfig } from '../_util/placements';
import getPlacements from '../_util/placements';
@ -110,8 +111,6 @@ export interface AbstractTooltipProps extends LegacyTooltipProps {
destroyTooltipOnHide?: boolean | { keepParent?: boolean };
}
export type RenderFunction = () => React.ReactNode;
export interface TooltipPropsWithOverlay extends AbstractTooltipProps {
title?: React.ReactNode | RenderFunction;
overlay?: React.ReactNode | RenderFunction;

Loading…
Cancel
Save