2019-12-19 11:56:50 +08:00
|
|
|
import classNames from 'classnames';
|
2022-06-22 14:57:09 +08:00
|
|
|
import omit from 'rc-util/lib/omit';
|
2023-05-05 20:52:44 +08:00
|
|
|
import React from 'react';
|
2022-06-22 14:57:09 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { SkeletonElementProps } from './Element';
|
|
|
|
import Element from './Element';
|
2019-12-19 11:56:50 +08:00
|
|
|
|
2022-03-29 20:55:44 +08:00
|
|
|
import useStyle from './style';
|
2019-12-19 11:56:50 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
export interface SkeletonInputProps extends Omit<SkeletonElementProps, 'size' | 'shape'> {
|
2019-12-19 11:56:50 +08:00
|
|
|
size?: 'large' | 'small' | 'default';
|
2022-01-11 15:12:03 +08:00
|
|
|
block?: boolean;
|
2019-12-19 11:56:50 +08:00
|
|
|
}
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const SkeletonInput: React.FC<SkeletonInputProps> = (props) => {
|
2023-01-20 11:03:50 +08:00
|
|
|
const {
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
className,
|
|
|
|
rootClassName,
|
|
|
|
active,
|
|
|
|
block,
|
|
|
|
size = 'default',
|
|
|
|
} = props;
|
2022-03-25 20:11:33 +08:00
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
2022-03-29 20:55:44 +08:00
|
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
2022-03-25 20:11:33 +08:00
|
|
|
|
|
|
|
const otherProps = omit(props, ['prefixCls']);
|
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-element`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
[`${prefixCls}-block`]: block,
|
|
|
|
},
|
|
|
|
className,
|
2023-01-20 11:03:50 +08:00
|
|
|
rootClassName,
|
2022-03-29 20:55:44 +08:00
|
|
|
hashId,
|
2022-03-25 20:11:33 +08:00
|
|
|
);
|
2022-03-29 20:55:44 +08:00
|
|
|
|
|
|
|
return wrapSSR(
|
2022-03-25 20:11:33 +08:00
|
|
|
<div className={cls}>
|
2022-09-27 09:57:36 +08:00
|
|
|
<Element prefixCls={`${prefixCls}-input`} size={size} {...otherProps} />
|
2022-03-29 20:55:44 +08:00
|
|
|
</div>,
|
2022-03-25 20:11:33 +08:00
|
|
|
);
|
2020-04-14 10:30:14 +08:00
|
|
|
};
|
2019-12-19 11:56:50 +08:00
|
|
|
|
|
|
|
export default SkeletonInput;
|