style: multiple selection tag

This commit is contained in:
jialin
2025-06-26 20:39:07 +08:00
parent c68d85096b
commit e2d79a6802
9 changed files with 93 additions and 35 deletions
@@ -1,20 +1,33 @@
import AutoTooltip from '@/components/auto-tooltip';
import React, { useMemo } from 'react';
interface SelectRenderProps {
maxTagWidth?: number;
radius?: number | string;
style?: React.CSSProperties;
filled?: boolean;
}
export default function useSelectRender(config?: SelectRenderProps) {
const { maxTagWidth = 100 } = config || {};
const { maxTagWidth = 100, radius, filled, style } = config || {};
const TagRender = (props: any) => {
const { label } = props;
const labelText = useMemo(() => {
if (!props.isMaxTag) {
return label;
}
return label.slice(0, -3);
}, [label, props.isMaxTag]);
return (
<AutoTooltip
maxWidth={maxTagWidth}
closable={props.closable}
onClose={props.onClose}
radius={radius}
filled={filled}
style={style}
>
{label}
{labelText}
</AutoTooltip>
);
};
+2 -1
View File
@@ -11,7 +11,7 @@ import SelectWrapper from './wrapper/select';
const tag = (props: any) => {
if (props.isMaxTag) {
return props.label;
return props.label?.slice(0, -3);
}
const parent = _.split(props.value, '__RC_CASCADER_SPLIT__')?.[0];
return `${parent} / ${props?.label}`;
@@ -24,6 +24,7 @@ const renderTag = (props: any) => {
closable={props.closable}
onClose={props.onClose}
maxWidth={240}
filled
>
{tag(props)}
</AutoTooltip>