'use client'; import * as React from 'react'; import { useMergeProps } from '../../hooks/useMergeProps'; import { warnOnce } from '../../lib/warnOnce'; import type { HasDataAttribute, HasRootRef } from '../../types'; import { Button, type VKUIButtonProps } from '../Button/Button'; import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden'; const warn = warnOnce('File'); export interface FileProps extends Omit, Omit, 'type' | 'size'>, HasRootRef { /** * @deprecated Since 7.9.0. Вместо этого используйте `slotProps={ input: { getRootRef: ... } }`. */ getRef?: React.Ref; /** * Свойства, которые можно прокинуть внутрь компонента: * - `root`: свойства для прокидывания в корень компонента; * - `input`: свойства для прокидывания в скрытый `input`. */ slotProps?: { root?: Omit, 'children'> & HasRootRef & HasDataAttribute; input?: Omit, 'type' | 'size'> & HasRootRef & HasDataAttribute; }; } /** * @see https://vkui.io/components/file */ export const File = ({ getRootRef, className, style, children = 'Выберите файл', align = 'left', size, mode, stretched, before, after, loading, getRef, appearance, slotProps, ...restProps }: FileProps): React.ReactNode => { /* istanbul ignore if: не проверяем в тестах */ if (process.env.NODE_ENV === 'development' && getRef) { warn('Свойство `getRef` устаревшее, используйте `slotProps={ input: { getRootRef: ... } }`'); } const rootProps = useMergeProps( { className, style, getRootRef: getRootRef as React.Ref, }, slotProps?.root, ); const inputRest = useMergeProps({ getRootRef: getRef, ...restProps }, slotProps?.input); return ( ); };