// Rôle : encapsule l'input fichier JSON derrière un bouton d'import réutilisable.
import { useRef } from "react";
import { Icon } from "./Icon.jsx";
import { Tooltip } from "./Tooltip.jsx";
export function ImportButton({ className, label, title, ariaLabel, icon, onFile, onKeyDown, tabIndex = 0, tooltip = "", tooltipPosition = "top", ...props }) {
const inputRef = useRef(null);
const buttonProps = {
...props,
role: "button",
tabIndex,
onKeyDown: (event) => {
onKeyDown?.(event);
if (event.defaultPrevented || (event.key !== "Enter" && event.key !== " ")) return;
event.preventDefault();
inputRef.current?.click();
}
};
const children = <>
{icon && }
{label}
{
const file = event.target.files?.[0];
if (file) await onFile(file);
event.target.value = "";
}} />
>;
if (tooltip) {
return {children};
}
return ;
}