added input text view + moved things
This commit is contained in:
1 parent
9694ffb238
commit
54c1edba0c
17 files changed
+166
-121
No files matched your search
File renamed without changes.
@@ -1,4 +1,3 @@
|
||||
import { SelectHTMLAttributes } from "react";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useToolTip } from "../tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
@@ -11,7 +10,6 @@ export default function InputNumber({
|
||||
value=0,
|
||||
onChange,
|
||||
}: Props) {
|
||||
const tooltip = useToolTip();
|
||||
return <InputWrapper label={label}>
|
||||
<input
|
||||
type="number"
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useToolTip } from "../tooltip/context";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
@@ -27,7 +27,7 @@ export default function InputText({
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
textInput: value,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
@@ -0,0 +1,56 @@
|
||||
import { useRef, useState, useEffect } from "react";
|
||||
import CheckMarkIcon from "~/icons/checkmark";
|
||||
import PencilIcon from "~/icons/pencil";
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
additionalTooltipFilters?: Record<string, string>;
|
||||
}
|
||||
export default function InputViewEdit({
|
||||
label,
|
||||
textBoxFor,
|
||||
value="",
|
||||
onChange,
|
||||
additionalTooltipFilters={},
|
||||
}: Props) {
|
||||
const tooltip = useToolTip();
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const onChangeWrapped = (t: string) => {
|
||||
onChange(t);
|
||||
setIsEditing(false);
|
||||
}
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
useEffect(() => {
|
||||
if (isEditing && inputRef.current) {
|
||||
inputRef.current.focus()
|
||||
}
|
||||
}, [inputRef.current, isEditing])
|
||||
return <InputWrapper label={label}>
|
||||
{isEditing ? <input
|
||||
ref={inputRef}
|
||||
value={value}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChangeWrapped(e.target.value)
|
||||
}}
|
||||
onFocus={e => textBoxFor && tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChangeWrapped
|
||||
)}
|
||||
/>:<div className="input-view">
|
||||
{value}
|
||||
</div>}
|
||||
<PencilIcon onClick={() => setIsEditing(!isEditing)} className={`icon pencil ${isEditing ? 'opened' : ''}`}/>
|
||||
<CheckMarkIcon onClick={() => setIsEditing(!isEditing)} className={`icon checkmark ${isEditing ? 'opened' : ''}`}/>
|
||||
</InputWrapper>
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
Whitespace-only changes.
Reference in new issue
Block a user