diff --git a/web/src/beta/features/Visualizer/Crust/Infobox/Block/builtin/PropertyList/ListEditor/Item.tsx b/web/src/beta/features/Visualizer/Crust/Infobox/Block/builtin/PropertyList/ListEditor/Item.tsx index 440f2d507..cf09567c3 100644 --- a/web/src/beta/features/Visualizer/Crust/Infobox/Block/builtin/PropertyList/ListEditor/Item.tsx +++ b/web/src/beta/features/Visualizer/Crust/Infobox/Block/builtin/PropertyList/ListEditor/Item.tsx @@ -1,30 +1,39 @@ import { Button, Icon, TextInput } from "@reearth/beta/lib/reearth-ui"; import { useT } from "@reearth/services/i18n"; -import { styled } from "@reearth/services/theme"; +import { styled, useTheme } from "@reearth/services/theme"; import { FC, useCallback, useState } from "react"; import { PropertyListItem } from "."; type Props = { item: PropertyListItem; + isEditKey: boolean; + isEditValue: boolean; handleClassName?: string; onKeyBlur: (newValue?: string) => void; onValueBlur: (newValue?: string) => void; onItemRemove: () => void; + onDoubleClick?: (field: string) => void; }; const EditorItem: FC = ({ item, handleClassName, + isEditKey, + isEditValue, onKeyBlur, onValueBlur, - onItemRemove + onItemRemove, + onDoubleClick }) => { - const [currentKeyValue, setCurrentKeyValue] = useState(item.key); - const [currentValue, setCurrentValue] = useState(item.value); + const t = useT(); + const theme = useTheme(); + + const [currentKeyItem, setCurrentKeyItem] = useState(item.key); + const [currentValueItem, setCurrentValueItem] = useState(item.value); const handleKeyChange = useCallback((newValue: string) => { - setCurrentKeyValue(newValue); + setCurrentKeyItem(newValue); }, []); const handleKeyBlur = useCallback( @@ -35,7 +44,7 @@ const EditorItem: FC = ({ ); const handleValueChange = useCallback((newValue: string) => { - setCurrentValue(newValue); + setCurrentValueItem(newValue); }, []); const handleValueBlur = useCallback( @@ -45,25 +54,45 @@ const EditorItem: FC = ({ [onValueBlur] ); - const t = useT(); - return ( - - - + + {item.key === "" || isEditKey ? ( + + ) : ( + onDoubleClick?.("key")}> + {currentKeyItem} + + )} + + + {item.value === "" || isEditValue ? ( + + ) : ( + onDoubleClick?.("value")}> + {currentValueItem} + + )} + +