mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
* feat(InputNumber): spinner mode * feat(InputNumber): spinner mode * docs: re-order * docs: semantic support action * chore: adjust focus util * chore: update * test: update snapshot * chore: fix style * docs: style * chore: fix style * feat: warning style * chore: fix demo * chore: clean up * test: fix test case * chore: fix test ts * test: all * test: update snapshot * chore: coverage * chore: adjust style --------- Co-authored-by: 遇见同学 <1875694521@qq.com> Co-authored-by: 二货机器人 <smith3816@gmail.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { clsx } from 'clsx';
|
|
|
|
import { getStatusClassNames } from '../_util/statusUtils';
|
|
import type { InputStatus } from '../_util/statusUtils';
|
|
import { ConfigContext } from '../config-provider';
|
|
import type { Variant } from '../config-provider';
|
|
import { useCompactItemContext } from './Compact';
|
|
import useStyle from './style/addon';
|
|
|
|
export interface SpaceCompactCellProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
children: React.ReactNode;
|
|
prefixCls?: string;
|
|
variant?: Variant;
|
|
disabled?: boolean;
|
|
status?: InputStatus;
|
|
}
|
|
|
|
const SpaceAddon = React.forwardRef<HTMLDivElement, SpaceCompactCellProps>((props, ref) => {
|
|
const {
|
|
className,
|
|
children,
|
|
style,
|
|
prefixCls: customizePrefixCls,
|
|
variant = 'outlined',
|
|
disabled,
|
|
status,
|
|
...restProps
|
|
} = props;
|
|
const { getPrefixCls, direction: directionConfig } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('space-addon', customizePrefixCls);
|
|
const [hashId, cssVarCls] = useStyle(prefixCls);
|
|
const { compactItemClassnames, compactSize } = useCompactItemContext(prefixCls, directionConfig);
|
|
|
|
const statusCls = getStatusClassNames(prefixCls, status);
|
|
|
|
const classes = clsx(
|
|
prefixCls,
|
|
hashId,
|
|
compactItemClassnames,
|
|
cssVarCls,
|
|
`${prefixCls}-variant-${variant}`,
|
|
statusCls,
|
|
{
|
|
[`${prefixCls}-${compactSize}`]: compactSize,
|
|
[`${prefixCls}-disabled`]: disabled,
|
|
},
|
|
className,
|
|
);
|
|
|
|
return (
|
|
<div ref={ref} className={classes} style={style} {...restProps}>
|
|
{children}
|
|
</div>
|
|
);
|
|
});
|
|
|
|
export default SpaceAddon;
|