import classNames from "classnames"; import { ChangeEventHandler, FocusEventHandler, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, JSX, useRef } from "react"; import { twMerge } from "tailwind-merge"; import { useOptionContext } from "./OptionSpace"; import { useFocusable } from "@noriginmedia/norigin-spatial-navigation"; import { systemApi } from "../../scripts/clientApi"; import { Check, CheckIcon, X } from "lucide-react"; export function OptionInput (data: { name: string; type: HTMLInputTypeAttribute; className?: string; placeholder?: string; icon?: JSX.Element; value?: string; defaultValue?: string | boolean; autocomplete?: HTMLInputAutoCompleteAttribute; onBlur?: FocusEventHandler; onChange?: (value: any) => void; }) { const handlePress = () => { if (data.type === 'checkbox') { inputRef.current?.click(); } else { inputRef.current?.focus(); } }; const { ref, focused } = useFocusable({ focusKey: data.name, onEnterPress: handlePress }); const inputRef = useRef(null); const option = useOptionContext({ onOptionEnterPress: handlePress, }); const handleFocus = () => { option.focus(); if (inputRef.current) { var rect = inputRef.current?.getBoundingClientRect(); systemApi.api.system.show_keyboard.post({ XPosition: rect.x, YPosition: rect.y, Width: rect.width, Height: rect.height }); } }; return ( ); }