Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import type { FC } from 'react'
  2. import {
  3. useCallback,
  4. useMemo,
  5. } from 'react'
  6. import { debounce } from 'lodash-es'
  7. import { useStore } from '../store'
  8. import { useResizePanel } from '../nodes/_base/hooks/use-resize-panel'
  9. import Panel from './panel'
  10. import cn from '@/utils/classnames'
  11. const VariableInspectPanel: FC = () => {
  12. const showVariableInspectPanel = useStore(s => s.showVariableInspectPanel)
  13. const workflowCanvasHeight = useStore(s => s.workflowCanvasHeight)
  14. const variableInspectPanelHeight = useStore(s => s.variableInspectPanelHeight)
  15. const setVariableInspectPanelHeight = useStore(s => s.setVariableInspectPanelHeight)
  16. const maxHeight = useMemo(() => {
  17. if (!workflowCanvasHeight)
  18. return 480
  19. return workflowCanvasHeight - 60
  20. }, [workflowCanvasHeight])
  21. const handleResize = useCallback((width: number, height: number) => {
  22. localStorage.setItem('workflow-variable-inpsect-panel-height', `${height}`)
  23. setVariableInspectPanelHeight(height)
  24. }, [setVariableInspectPanelHeight])
  25. const {
  26. triggerRef,
  27. containerRef,
  28. } = useResizePanel({
  29. direction: 'vertical',
  30. triggerDirection: 'top',
  31. minHeight: 120,
  32. maxHeight,
  33. onResize: debounce(handleResize),
  34. })
  35. if (!showVariableInspectPanel)
  36. return null
  37. return (
  38. <div className={cn('relative pb-1')}>
  39. <div
  40. ref={triggerRef}
  41. className='absolute -top-1 left-0 flex h-1 w-full cursor-row-resize resize-y items-center justify-center'>
  42. <div className='h-0.5 w-10 rounded-sm bg-state-base-handle hover:w-full hover:bg-state-accent-solid active:w-full active:bg-state-accent-solid'></div>
  43. </div>
  44. <div
  45. ref={containerRef}
  46. className={cn('overflow-hidden rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl')}
  47. style={{ height: `${variableInspectPanelHeight}px` }}
  48. >
  49. <Panel />
  50. </div>
  51. </div>
  52. )
  53. }
  54. export default VariableInspectPanel