import React, { PropsWithChildren, useLayoutEffect, useRef, useState, } from 'react'; import { Icon, IconTypes } from '../Icon'; export interface WithEditProps { value?: string, onChange?: (value:string) => void, confirm?: (data?:any) => void, className?: string, close?: () => void, } export function WithText(props:PropsWithChildren) { const { value: propsVal, confirm, className, } = props; const inputRef = useRef(); const [value, setValue] = useState(propsVal); useLayoutEffect(() => { inputRef?.current?.focus(); setValue(value); }, [inputRef, propsVal]); const handleChange = (e:React.ChangeEvent) => { setValue(e.target.value); }; const handleConfirm = () => { confirm(value); }; return (
); }