2024-06-26 19:00:29 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
import { MiniButton } from '@/components/Control';
|
|
|
|
import { Dropdown, useDropdown } from '@/components/Dropdown';
|
2025-01-28 23:23:42 +03:00
|
|
|
import { IconFolderTree } from '@/components/Icons';
|
2025-02-22 14:04:01 +03:00
|
|
|
import { type Styling } from '@/components/props';
|
2024-06-26 19:00:29 +03:00
|
|
|
import { prefixes } from '@/utils/constants';
|
|
|
|
|
2025-02-19 23:30:35 +03:00
|
|
|
import { SelectLocation } from './SelectLocation';
|
2024-06-26 19:00:29 +03:00
|
|
|
|
2025-02-21 21:15:05 +03:00
|
|
|
interface SelectLocationContextProps extends Styling {
|
2024-06-26 19:00:29 +03:00
|
|
|
value: string;
|
2025-02-04 20:35:55 +03:00
|
|
|
onChange: (newValue: string) => void;
|
2024-09-12 13:27:20 +03:00
|
|
|
title?: string;
|
2025-03-07 02:46:19 +03:00
|
|
|
dropdownHeight?: string;
|
2024-06-26 19:00:29 +03:00
|
|
|
}
|
|
|
|
|
2025-02-12 15:13:37 +03:00
|
|
|
export function SelectLocationContext({
|
2024-09-12 13:27:20 +03:00
|
|
|
value,
|
|
|
|
title = 'Проводник...',
|
|
|
|
onChange,
|
|
|
|
className,
|
2025-03-07 02:46:19 +03:00
|
|
|
dropdownHeight,
|
|
|
|
...restProps
|
2024-09-12 13:27:20 +03:00
|
|
|
}: SelectLocationContextProps) {
|
2024-06-26 19:00:29 +03:00
|
|
|
const menu = useDropdown();
|
|
|
|
|
2025-02-22 14:04:01 +03:00
|
|
|
function handleClick(event: React.MouseEvent<Element>, newValue: string) {
|
2025-02-05 01:27:52 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
menu.hide();
|
|
|
|
onChange(newValue);
|
|
|
|
}
|
2024-06-26 19:00:29 +03:00
|
|
|
|
|
|
|
return (
|
2025-03-10 16:02:53 +03:00
|
|
|
<div ref={menu.ref} className={clsx('relative h-full -mt-1 -ml-6 text-right self-start', className)} {...restProps}>
|
2024-06-26 19:00:29 +03:00
|
|
|
<MiniButton
|
2024-09-12 13:27:20 +03:00
|
|
|
title={title}
|
2024-06-26 19:00:29 +03:00
|
|
|
hideTitle={menu.isOpen}
|
|
|
|
icon={<IconFolderTree size='1.25rem' className='icon-green' />}
|
|
|
|
onClick={() => menu.toggle()}
|
|
|
|
/>
|
2025-03-10 16:02:53 +03:00
|
|
|
<Dropdown isOpen={menu.isOpen} className={clsx('w-80 h-50 z-tooltip', dropdownHeight)}>
|
2024-06-26 19:00:29 +03:00
|
|
|
<SelectLocation
|
|
|
|
value={value}
|
|
|
|
prefix={prefixes.folders_list}
|
|
|
|
dense
|
|
|
|
onClick={(event, target) => handleClick(event, target.getPath())}
|
|
|
|
/>
|
|
|
|
</Dropdown>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|