add-row.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import type { MetadataItemWithEdit } from '../types'
  5. import cn from '@/utils/classnames'
  6. import Label from './label'
  7. import InputCombined from './input-combined'
  8. import { RiIndeterminateCircleLine } from '@remixicon/react'
  9. type Props = {
  10. className?: string
  11. payload: MetadataItemWithEdit
  12. onChange: (value: MetadataItemWithEdit) => void
  13. onRemove: () => void
  14. }
  15. const AddRow: FC<Props> = ({
  16. className,
  17. payload,
  18. onChange,
  19. onRemove,
  20. }) => {
  21. return (
  22. <div className={cn('flex h-6 items-center space-x-0.5', className)}>
  23. <Label text={payload.name} />
  24. <InputCombined
  25. type={payload.type}
  26. value={payload.value}
  27. onChange={value => onChange({ ...payload, value })}
  28. />
  29. <div
  30. className={
  31. cn(
  32. 'cursor-pointer rounded-md p-1 text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive',
  33. )
  34. }
  35. onClick={onRemove}
  36. >
  37. <RiIndeterminateCircleLine className='size-4' />
  38. </div>
  39. </div>
  40. )
  41. }
  42. export default React.memo(AddRow)