You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

feat: prepend use-client directive for with Next.js App Router (#43573) * fix: prepend use-client directive for with Next.js App Router * Update components/affix/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/badge/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/divider/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/cascader/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/list/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/qrcode/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/select/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/steps/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/time-picker/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/transfer/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/tree-select/index.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
1 year ago
'use client';
import StarFilled from '@ant-design/icons/StarFilled';
import classNames from 'classnames';
9 years ago
import RcRate from 'rc-rate';
import type { RateRef, RateProps as RcRateProps } from 'rc-rate/lib/Rate';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import Tooltip from '../tooltip';
import useStyle from './style';
9 years ago
export interface RateProps extends RcRateProps {
rootClassName?: string;
tooltips?: Array<string>;
}
interface RateNodeProps {
index: number;
}
const Rate = React.forwardRef<RateRef, RateProps>((props, ref) => {
const {
prefixCls,
className,
rootClassName,
style,
tooltips,
character = <StarFilled />,
...rest
} = props;
const characterRender = (node: React.ReactElement, { index }: RateNodeProps) => {
if (!tooltips) {
return node;
}
return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
};
const { getPrefixCls, direction, rate } = React.useContext(ConfigContext);
const ratePrefixCls = getPrefixCls('rate', prefixCls);
// Style
const [wrapSSR, hashId] = useStyle(ratePrefixCls);
const mergedStyle: React.CSSProperties = { ...rate?.style, ...style };
return wrapSSR(
<RcRate
ref={ref}
character={character}
characterRender={characterRender}
{...rest}
className={classNames(className, rootClassName, hashId, rate?.className)}
style={mergedStyle}
prefixCls={ratePrefixCls}
direction={direction}
/>,
);
});
if (process.env.NODE_ENV !== 'production') {
Rate.displayName = 'Rate';
}
export default Rate;