列表综合筛选
This commit is contained in:
@@ -15,6 +15,7 @@ export interface BubbleProps {
|
||||
options: BubbleOption[];
|
||||
value?: string | number | (string | number)[];
|
||||
onChange?: (
|
||||
name: string,
|
||||
value: string | number | (string | number)[],
|
||||
option: BubbleOption | BubbleOption[]
|
||||
) => void;
|
||||
@@ -26,6 +27,7 @@ export interface BubbleProps {
|
||||
itemClassName?: string;
|
||||
style?: React.CSSProperties;
|
||||
disabled?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const Bubble: React.FC<BubbleProps> = ({
|
||||
@@ -40,6 +42,7 @@ const Bubble: React.FC<BubbleProps> = ({
|
||||
itemClassName = "",
|
||||
style = {},
|
||||
disabled = false,
|
||||
name,
|
||||
}) => {
|
||||
const [selectedValues, setSelectedValues] = useState<(string | number)[]>([]);
|
||||
|
||||
@@ -74,9 +77,9 @@ const Bubble: React.FC<BubbleProps> = ({
|
||||
const selectedOptions = options.filter((opt) =>
|
||||
newSelectedValues.includes(opt.value)
|
||||
);
|
||||
onChange(newSelectedValues, selectedOptions);
|
||||
onChange(name, newSelectedValues, selectedOptions);
|
||||
} else {
|
||||
onChange(option.value, option);
|
||||
onChange(name, option.value, option);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user