您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.tsx 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {
  2. memo,
  3. useCallback,
  4. } from 'react'
  5. import { useTranslation } from 'react-i18next'
  6. import type { NodeProps } from 'reactflow'
  7. import { RiAddLine } from '@remixicon/react'
  8. import cn from '@/utils/classnames'
  9. import Button from '@/app/components/base/button'
  10. import BlockSelector from '@/app/components/workflow/block-selector'
  11. import { useReplaceDataSourceNode } from './hooks'
  12. const DataSourceEmptyNode = ({ id, data }: NodeProps) => {
  13. const { t } = useTranslation()
  14. const { handleReplaceNode } = useReplaceDataSourceNode(id)
  15. const renderTrigger = useCallback(() => {
  16. return (
  17. <Button
  18. variant='primary'
  19. className='w-full'
  20. >
  21. <RiAddLine className='mr-1 h-4 w-4' />
  22. {t('workflow.nodes.dataSource.add')}
  23. </Button>
  24. )
  25. }, [])
  26. return (
  27. <div
  28. className={cn(
  29. 'relative flex rounded-2xl border',
  30. 'border-transparent',
  31. )}
  32. style={{
  33. width: data.width,
  34. height: data.height,
  35. }}
  36. >
  37. <div className='absolute inset-[-2px] top-[-22px] z-[-1] rounded-[18px] bg-node-data-source-bg p-0.5 backdrop-blur-[6px]'>
  38. <div className='system-2xs-semibold-uppercase flex h-5 items-center px-2.5 text-text-tertiary'>
  39. {t('workflow.blocks.datasource')}
  40. </div>
  41. </div>
  42. <div
  43. className={cn(
  44. 'group relative shadow-xs',
  45. 'rounded-[15px] border border-transparent',
  46. 'w-[240px] bg-workflow-block-bg',
  47. )}
  48. >
  49. <div className={cn(
  50. 'flex items-center rounded-t-2xl p-3',
  51. )}>
  52. <BlockSelector
  53. asChild
  54. onSelect={handleReplaceNode}
  55. trigger={renderTrigger}
  56. noBlocks
  57. noTools
  58. popupClassName='w-[320px]'
  59. placement='bottom-start'
  60. offset={{
  61. mainAxis: 4,
  62. crossAxis: 0,
  63. }}
  64. />
  65. </div>
  66. </div>
  67. </div>
  68. )
  69. }
  70. export default memo(DataSourceEmptyNode)