|
@@ -5,6 +5,7 @@ import type { Elements, OnLoadParams } from 'react-flow-renderer'
|
|
import { transformElements } from '@/components/Flow/src/shared/transformer'
|
|
import { transformElements } from '@/components/Flow/src/shared/transformer'
|
|
import { FlowTreeNode } from '@/components/Flow/src/type'
|
|
import { FlowTreeNode } from '@/components/Flow/src/type'
|
|
import { DrawerAction } from '@/components/Drawer'
|
|
import { DrawerAction } from '@/components/Drawer'
|
|
|
|
+import { EventEmitter } from '@/utils/emit/event'
|
|
|
|
|
|
export type FlowContextState = {
|
|
export type FlowContextState = {
|
|
dataID: string
|
|
dataID: string
|
|
@@ -15,6 +16,7 @@ export type FlowContextState = {
|
|
executorList: API.ExecutorItem[]
|
|
executorList: API.ExecutorItem[]
|
|
matterList: API.MatterItem[]
|
|
matterList: API.MatterItem[]
|
|
conditionValueToMap: Record<string, string>
|
|
conditionValueToMap: Record<string, string>
|
|
|
|
+ event$: EventEmitter<unknown>
|
|
}
|
|
}
|
|
type FlowContextProviderProps = {
|
|
type FlowContextProviderProps = {
|
|
children: React.ReactNode
|
|
children: React.ReactNode
|
|
@@ -22,6 +24,7 @@ type FlowContextProviderProps = {
|
|
dataID: string
|
|
dataID: string
|
|
executorList: API.ExecutorItem[]
|
|
executorList: API.ExecutorItem[]
|
|
matterList: API.MatterItem[]
|
|
matterList: API.MatterItem[]
|
|
|
|
+ event$: EventEmitter<unknown>
|
|
}
|
|
}
|
|
|
|
|
|
export type DispatchAction = Dispatch<{
|
|
export type DispatchAction = Dispatch<{
|
|
@@ -32,14 +35,15 @@ export type DispatchAction = Dispatch<{
|
|
const FlowContext = createContext<{ flowStore: FlowContextState; dispatch: DispatchAction }>({})
|
|
const FlowContext = createContext<{ flowStore: FlowContextState; dispatch: DispatchAction }>({})
|
|
|
|
|
|
const FlowContextProvider: React.FC<FlowContextProviderProps> = props => {
|
|
const FlowContextProvider: React.FC<FlowContextProviderProps> = props => {
|
|
- const { children, initialProcess = [], dataID, executorList = [], matterList = [] } = props
|
|
|
|
|
|
+ const { children, initialProcess = [], dataID, executorList = [], matterList = [], event$ } = props
|
|
const [flowStore, dispatch] = useReducer(reducer, {
|
|
const [flowStore, dispatch] = useReducer(reducer, {
|
|
process: initialProcess,
|
|
process: initialProcess,
|
|
elements: transformElements(initialProcess),
|
|
elements: transformElements(initialProcess),
|
|
dataID,
|
|
dataID,
|
|
executorList,
|
|
executorList,
|
|
matterList,
|
|
matterList,
|
|
- conditionValueToMap: {}
|
|
|
|
|
|
+ conditionValueToMap: {},
|
|
|
|
+ event$
|
|
})
|
|
})
|
|
return <FlowContext.Provider value={{ flowStore, dispatch }}>{children}</FlowContext.Provider>
|
|
return <FlowContext.Provider value={{ flowStore, dispatch }}>{children}</FlowContext.Provider>
|
|
}
|
|
}
|