2022-06-04 03:13:19 +00:00
|
|
|
import { HTMLProps } from "react";
|
2022-06-10 15:18:36 +00:00
|
|
|
import { BaseEditable } from "./BaseEditable";
|
2022-06-04 03:13:19 +00:00
|
|
|
|
|
|
|
|
2022-06-08 16:00:39 +00:00
|
|
|
/**
|
|
|
|
* Controlled input component which displays an `input[type="text"]` in editing mode, and a `span` displaying the input in preview mode.
|
|
|
|
*/
|
2022-06-08 17:14:00 +00:00
|
|
|
export function EditableText(props: HTMLProps<HTMLInputElement> & { value: string }) {
|
|
|
|
return (
|
2022-06-10 15:18:36 +00:00
|
|
|
<BaseEditable
|
2022-06-08 17:14:00 +00:00
|
|
|
editing={
|
|
|
|
<input type="text" {...props} />
|
|
|
|
}
|
|
|
|
preview={
|
|
|
|
<span>{props.value}</span>
|
|
|
|
}
|
|
|
|
/>
|
2022-06-04 03:13:19 +00:00
|
|
|
)
|
|
|
|
}
|