/*
 * @Author: Gui
 * @Date: 2023-10-09 16:19:59
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-10-12 16:32:56
 * @Description: kxs files
 * @filePath:
 */
export const TableEdit = props => {
  return (
    <div
      onDblclick={() => {
        document.querySelector(".el" + props.data).style.display = "none";
        document.querySelector(".input" + props.data).style.display = "block";
        document.querySelector(".input" + props.data).value =
          document.querySelector(".el" + props.data).innerHTML;
      }}
    >
      <div class={"el" + props.data}>{props.data}</div>
      <input
        style="display:none;"
        class={"input" + props.data}
        onInput={() => {
          document.querySelector(".el" + props.data).innerHTML =
            document.querySelector(".input" + props.data).value;
        }}
        onBlur={() => {
          document.querySelector(".el" + props.data).style.display = "block";
          document.querySelector(".input" + props.data).style.display = "none";
          props.submitfunc(
            props.row,
            document.querySelector(".el" + props.data).innerHTML
          );
        }}
      />
    </div>
  );
};
