output-vars.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use client'
  2. import type { FC, ReactNode } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse'
  6. type Props = {
  7. className?: string
  8. title?: string
  9. children: ReactNode
  10. }
  11. const OutputVars: FC<Props> = ({
  12. title,
  13. children,
  14. }) => {
  15. const { t } = useTranslation()
  16. return (
  17. <FieldCollapse title={title || t('workflow.nodes.common.outputVars')}>
  18. {children}
  19. </FieldCollapse>
  20. )
  21. }
  22. type VarItemProps = {
  23. name: string
  24. type: string
  25. description: string
  26. subItems?: {
  27. name: string
  28. type: string
  29. description: string
  30. }[]
  31. }
  32. export const VarItem: FC<VarItemProps> = ({
  33. name,
  34. type,
  35. description,
  36. subItems,
  37. }) => {
  38. return (
  39. <div className='py-1'>
  40. <div className='flex leading-[18px] items-center'>
  41. <div className='code-sm-semibold text-text-secondary'>{name}</div>
  42. <div className='ml-2 system-xs-regular text-text-tertiary'>{type}</div>
  43. </div>
  44. <div className='mt-0.5 system-xs-regular text-text-tertiary'>
  45. {description}
  46. {subItems && (
  47. <div className='ml-2 border-l border-gray-200 pl-2'>
  48. {subItems.map((item, index) => (
  49. <VarItem
  50. key={index}
  51. name={item.name}
  52. type={item.type}
  53. description={item.description}
  54. />
  55. ))}
  56. </div>
  57. )}
  58. </div>
  59. </div>
  60. )
  61. }
  62. export default React.memo(OutputVars)