56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import { PencilIcon } from 'lucide-react'
|
|
import Text from '@/components/ui/Text'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
interface PropertyNameProps {
|
|
name: string
|
|
}
|
|
|
|
export const PropertyName = ({ name }: PropertyNameProps) => {
|
|
const { t } = useTranslation()
|
|
|
|
const getPropertyNameTranslation = (propName: string) => {
|
|
const translationKey = `graphPanel.propertiesView.node.propertyNames.${propName}`
|
|
const translation = t(translationKey)
|
|
return translation === translationKey ? propName : translation
|
|
}
|
|
|
|
return (
|
|
<span className="text-primary/60 tracking-wide whitespace-nowrap">
|
|
{getPropertyNameTranslation(name)}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
interface EditIconProps {
|
|
onClick: () => void
|
|
}
|
|
|
|
export const EditIcon = ({ onClick }: EditIconProps) => (
|
|
<div>
|
|
<PencilIcon
|
|
className="h-3 w-3 text-gray-500 hover:text-gray-700 cursor-pointer"
|
|
onClick={onClick}
|
|
/>
|
|
</div>
|
|
)
|
|
|
|
interface PropertyValueProps {
|
|
value: any
|
|
onClick?: () => void
|
|
tooltip?: string
|
|
}
|
|
|
|
export const PropertyValue = ({ value, onClick, tooltip }: PropertyValueProps) => (
|
|
<div className="flex items-center gap-1">
|
|
<Text
|
|
className="hover:bg-primary/20 rounded p-1 overflow-hidden text-ellipsis"
|
|
tooltipClassName="max-w-80"
|
|
text={value}
|
|
tooltip={tooltip || (typeof value === 'string' ? value : JSON.stringify(value, null, 2))}
|
|
side="left"
|
|
onClick={onClick}
|
|
/>
|
|
</div>
|
|
)
|