import { useEffect, useRef } from 'preact/hooks' import { hexId } from '../Utils.js' import { Octicon } from './index.js' type BtnInputProps = { icon?: keyof typeof Octicon, label?: string, large?: boolean, larger?: boolean, doSelect?: number, value?: string, placeholder?: string, dataList?: string[], onChange?: (value: string) => unknown, } export function BtnInput({ icon, label, large, larger, doSelect, value, placeholder, dataList, onChange }: BtnInputProps) { const onInput = onChange === undefined ? () => {} : (e: any) => { const value = (e.target as HTMLInputElement).value onChange?.(value) } const ref = useRef(null) useEffect(() => { if (doSelect && ref.current) { ref.current.select() } }, [doSelect]) const dataListId = dataList && hexId() return
e.stopPropagation()}> {icon && Octicon[icon]} {label && {label}} {dataList && {dataList.map(e => }
}