2025-02-20 20:22:05 +03:00
|
|
|
import { type Styling } from '@/components/props';
|
2025-04-11 19:59:08 +03:00
|
|
|
import { ComboBox } from '@/components/ui/combo-box';
|
2025-02-10 01:32:16 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
import { type ILibraryItem } from '../backend/types';
|
2024-07-30 15:59:37 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
interface SelectLibraryItemProps extends Styling {
|
2025-04-10 11:03:55 +03:00
|
|
|
id?: string;
|
2025-02-19 22:32:50 +03:00
|
|
|
value: ILibraryItem | null;
|
|
|
|
onChange: (newValue: ILibraryItem | null) => void;
|
2024-07-30 15:59:37 +03:00
|
|
|
|
2025-02-19 22:32:50 +03:00
|
|
|
items?: ILibraryItem[];
|
2024-07-30 15:59:37 +03:00
|
|
|
placeholder?: string;
|
|
|
|
noBorder?: boolean;
|
|
|
|
}
|
|
|
|
|
2025-04-11 19:59:08 +03:00
|
|
|
export function SelectLibraryItem({ items, placeholder = 'Выберите схему', ...restProps }: SelectLibraryItemProps) {
|
2024-07-30 15:59:37 +03:00
|
|
|
return (
|
2025-04-11 19:59:08 +03:00
|
|
|
<ComboBox
|
|
|
|
items={items}
|
|
|
|
placeholder={placeholder}
|
|
|
|
idFunc={item => String(item.id)}
|
|
|
|
labelValueFunc={item => `${item.alias}: ${item.title}`}
|
|
|
|
labelOptionFunc={item => `${item.alias}: ${item.title}`}
|
|
|
|
{...restProps}
|
|
|
|
/>
|
2024-07-30 15:59:37 +03:00
|
|
|
);
|
|
|
|
}
|