import { Button, ButtonProps, VIEW } from '@cloud-ru/ds-button'; import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/ds-icons/interface/system'; import { Droplist, DroplistProps } from '@cloud-ru/ds-list'; import { useValueControl } from '@cloud-ru/ds-utils'; import { useMemo } from 'react'; export type ButtonDroplistProps = { button: | (Omit & { buttonType?: 'filled' }) | (Omit & { buttonType?: 'function' }); list: Pick; }; export function ButtonDroplist({ button, list }: ButtonDroplistProps) { const [open = false, onOpenChange] = useValueControl({ onChange: list.onOpenChange, value: list.open }); const Icon = open ? ChevronUpSVG : ChevronDownSVG; const buttonType = button.buttonType ?? 'function'; const buttonProps: ButtonProps = useMemo( () => buttonType === 'filled' ? { ...button, view: VIEW.Filled, appearance: 'primary' } : { ...button, view: VIEW.Function, appearance: 'neutral', icon: , iconPosition: 'after' }, [buttonType, button, Icon], ); return (