1
- import { styleControl } from "comps/controls/styleControl" ;
2
- import { SelectStyle } from "comps/controls/styleControlConstants" ;
3
1
import { trans } from "i18n" ;
4
2
import {
5
- CommonNameConfig , MultiBaseComp ,
3
+ CommonNameConfig ,
4
+ MultiBaseComp ,
6
5
NameConfig ,
7
6
stringExposingStateControl ,
8
7
UICompBuilder ,
@@ -13,54 +12,57 @@ import { baseSelectRefMethods, TourChildrenMap, TourPropertyView } from "./tourC
13
12
import { TourInputCommonConfig } from "./tourInputConstants" ;
14
13
import { Tour , TourProps } from "antd" ;
15
14
import { PlacementType } from "@lowcoder-ee/comps/controls/tourStepControl" ;
16
- import { useContext } from "react" ;
15
+ import React , { Suspense , useContext } from "react" ;
17
16
import { EditorContext } from "@lowcoder-ee/comps/editorState" ;
18
17
import { GridItemComp } from "@lowcoder-ee/comps/comps/gridItemComp" ;
19
18
import { HookComp } from "@lowcoder-ee/comps/hooks/hookComp" ;
20
19
import { TemporaryStateItemComp } from "@lowcoder-ee/comps/comps/temporaryStateComp" ;
21
- import { delay } from "redux-saga/effects" ;
22
20
23
21
/**
24
22
* This component builds the Property Panel and the fake 'UI' for the Tour component
25
23
*/
26
- let TourBasicComp = ( function ( ) {
24
+ let TourBasicComp = ( function ( ) {
27
25
const childrenMap = {
28
26
...TourChildrenMap ,
29
27
defaultValue : stringExposingStateControl ( "defaultValue" ) ,
30
- value : stringExposingStateControl ( "value" ) ,
28
+ value : stringExposingStateControl ( "value" )
31
29
// style: styleControl(SelectStyle),
32
30
} ;
33
31
return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
34
32
const editorState = useContext ( EditorContext ) ;
35
33
const compMap : ( GridItemComp | HookComp | InstanceType < typeof TemporaryStateItemComp > ) [ ] = Object . values ( editorState . getAllUICompMap ( ) ) ;
36
-
37
- const steps : TourProps [ ' steps' ] = props . options . map ( ( step ) => {
34
+
35
+ const steps : TourProps [ " steps" ] = props . options . map ( ( step ) => {
38
36
const targetName = step . target ;
39
37
let target = undefined ;
40
38
const compListItem = compMap . find ( ( compItem ) => compItem . children . name . getView ( ) === targetName ) ;
41
39
if ( compListItem ) {
42
- console . log ( `setting selected comp to ${ compListItem } ` )
40
+ console . log ( `setting selected comp to ${ compListItem } ` ) ;
43
41
try {
44
- target = ( ( compListItem as MultiBaseComp ) . children . comp as GridItemComp ) . getRef ( ) ;
42
+ target = ( ( compListItem as MultiBaseComp ) . children . comp as GridItemComp ) . getRef ?. ( ) ;
45
43
} catch ( e ) {
46
- target = ( ( compListItem as MultiBaseComp ) . children . comp as HookComp ) . getRef ( ) ;
44
+ target = ( ( compListItem as MultiBaseComp ) . children . comp as HookComp ) . getRef ?. ( ) ;
47
45
}
48
46
}
49
-
47
+
50
48
return {
51
49
title : step . title ,
52
50
description : step . description ,
53
51
target : target ?. current ,
54
52
arrow : step . arrow || true ,
55
- placement : step . placement as PlacementType ,
56
- }
57
- } )
53
+ placement : step . placement as PlacementType
54
+ } ;
55
+ } ) ;
58
56
59
- return ( < Tour
60
- steps = { steps }
61
- open = { props . open . value }
62
- onClose = { ( ) => props . open . onChange ( false ) }
63
- /> )
57
+ return (
58
+ < Suspense fallback = { < div > loading</ div > } >
59
+ < Tour
60
+ steps = { steps }
61
+ open = { props . open . value }
62
+ onClose = { ( ) => props . open . onChange ( false ) }
63
+ />
64
+ </ Suspense >
65
+ ) ;
64
66
} )
65
67
. setPropertyViewFn ( ( children ) => < TourPropertyView { ...children } /> )
66
68
. setExposeMethodConfigs ( baseSelectRefMethods )
@@ -72,17 +74,17 @@ TourBasicComp = withMethodExposing(TourBasicComp, [
72
74
method : {
73
75
name : "startTour" ,
74
76
description : "Triggers the tour to start" ,
75
- params : [ ] ,
77
+ params : [ ]
76
78
} ,
77
79
execute : ( comp , values ) => {
78
- comp . children . open . getView ( ) . onChange ( true )
80
+ comp . children . open . getView ( ) . onChange ( true ) ;
79
81
}
80
82
}
81
- ] )
83
+ ] ) ;
82
84
83
85
export const TourComp = withExposingConfigs ( TourBasicComp , [
84
86
new NameConfig ( "value" , trans ( "selectInput.valueDesc" ) ) ,
85
87
new NameConfig ( "inputValue" , trans ( "select.inputValueDesc" ) ) ,
86
88
...TourInputCommonConfig ,
87
- ...CommonNameConfig ,
89
+ ...CommonNameConfig
88
90
] ) ;
0 commit comments