wwf
2 天以前 a430284aa21e3ae1f0d5654e55b2ad2852519cc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use client'
import type { FC } from 'react'
import React from 'react'
import { useStore } from '@/app/components/workflow/store'
 
type Props = {
  isInNode?: boolean
  isExpand: boolean
  className: string
  style: React.CSSProperties
  children: React.ReactNode
}
 
// It doesn't has workflow store
const WrapInWebApp = ({
  className,
  style,
  children,
}: Props) => {
  return <div className={className} style={style}>{children}</div>
}
 
const Wrap = ({
  className,
  style,
  isExpand,
  children,
}: Props) => {
  const panelWidth = useStore(state => state.panelWidth)
  const wrapStyle = (() => {
    if (isExpand) {
      return {
        ...style,
        width: panelWidth - 1,
      }
    }
    return style
  })()
  return <div className={className} style={wrapStyle}>{children}</div>
}
 
const Main: FC<Props> = ({
  isInNode,
  ...otherProps
}: Props) => {
  return isInNode ? <Wrap {...otherProps} /> : <WrapInWebApp {...otherProps} />
}
export default React.memo(Main)