1
- import { useEffect , useState } from 'react' ;
1
+ import { useEffect , useMemo , useState } from 'react' ;
2
2
import { ObjectCloner , Step , StepsConfiguration , ToolboxConfiguration , ValidatorConfiguration } from 'sequential-workflow-designer' ;
3
3
import { SequentialWorkflowDesigner , wrapDefinition } from 'sequential-workflow-designer-react' ;
4
4
import { RootEditor } from './RootEditor' ;
@@ -14,21 +14,28 @@ const startDefinition: WorkflowDefinition = {
14
14
sequence : [ createTaskStep ( ) , createSwitchStep ( ) ]
15
15
} ;
16
16
17
- const toolboxConfiguration : ToolboxConfiguration = {
18
- groups : [ { name : 'Steps' , steps : [ createTaskStep ( ) , createSwitchStep ( ) ] } ]
19
- } ;
20
-
21
- const stepsConfiguration : StepsConfiguration = {
22
- iconUrlProvider : ( ) => null
23
- } ;
24
-
25
- const validatorConfiguration : ValidatorConfiguration = {
26
- step : ( step : Step ) => Boolean ( step . name ) ,
27
- root : ( definition : WorkflowDefinition ) => Boolean ( definition . properties . alfa )
28
- } ;
29
-
30
17
export function Playground ( ) {
31
18
const controller = useSequentialWorkflowDesignerController ( ) ;
19
+ const toolboxConfiguration : ToolboxConfiguration = useMemo (
20
+ ( ) => ( {
21
+ groups : [ { name : 'Steps' , steps : [ createTaskStep ( ) , createSwitchStep ( ) ] } ]
22
+ } ) ,
23
+ [ ]
24
+ ) ;
25
+ const stepsConfiguration : StepsConfiguration = useMemo (
26
+ ( ) => ( {
27
+ iconUrlProvider : ( ) => null
28
+ } ) ,
29
+ [ ]
30
+ ) ;
31
+ const validatorConfiguration : ValidatorConfiguration = useMemo (
32
+ ( ) => ( {
33
+ step : ( step : Step ) => Boolean ( step . name ) ,
34
+ root : ( definition : WorkflowDefinition ) => Boolean ( definition . properties . alfa )
35
+ } ) ,
36
+ [ ]
37
+ ) ;
38
+
32
39
const [ isVisible , setIsVisible ] = useState ( true ) ;
33
40
const [ isToolboxCollapsed , setIsToolboxCollapsed ] = useState ( false ) ;
34
41
const [ isEditorCollapsed , setIsEditorCollapsed ] = useState ( false ) ;
0 commit comments