2019-12-19 11:56:50 +08:00
|
|
|
import * as React from 'react';
|
2021-01-13 21:00:30 +08:00
|
|
|
import omit from 'rc-util/lib/omit';
|
2019-12-19 11:56:50 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import Element, { SkeletonElementProps } from './Element';
|
|
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
const SkeletonInput = (props: SkeletonInputProps) => {
|
|
|
|
const renderSkeletonInput = ({ getPrefixCls }: ConfigConsumerProps) => {
|
2022-01-11 15:12:03 +08:00
|
|
|
const { prefixCls: customizePrefixCls, className, active, block } = props;
|
2019-12-19 11:56:50 +08:00
|
|
|
const prefixCls = getPrefixCls('skeleton', customizePrefixCls);
|
2020-04-14 10:30:14 +08:00
|
|
|
const otherProps = omit(props, ['prefixCls']);
|
2020-09-06 13:07:39 +08:00
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-element`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: active,
|
2022-01-11 15:12:03 +08:00
|
|
|
[`${prefixCls}-block`]: block,
|
2020-09-06 13:07:39 +08:00
|
|
|
},
|
|
|
|
className,
|
|
|
|
);
|
2019-12-19 11:56:50 +08:00
|
|
|
return (
|
|
|
|
<div className={cls}>
|
|
|
|
<Element prefixCls={`${prefixCls}-input`} {...otherProps} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-04-14 10:30:14 +08:00
|
|
|
return <ConfigConsumer>{renderSkeletonInput}</ConfigConsumer>;
|
|
|
|
};
|
2019-12-19 11:56:50 +08:00
|
|
|
|
2020-04-14 10:30:14 +08:00
|
|
|
SkeletonInput.defaultProps = {
|
|
|
|
size: 'default',
|
|
|
|
};
|
2019-12-19 11:56:50 +08:00
|
|
|
|
|
|
|
export default SkeletonInput;
|