@@ -14,14 +14,15 @@ import { JSONObject } from "util/jsonTypes";
14
14
import { QueryTutorials } from "util/tutorialUtils" ;
15
15
import { SimpleNameComp } from "./simpleNameComp" ;
16
16
import { markdownCompCss , TacoMarkDown } from "lowcoder-design" ;
17
+ import { evalAndReduce } from "../utils" ;
17
18
18
19
const TemporaryStateItemCompBase = new MultiCompBuilder (
19
- {
20
- name : SimpleNameComp ,
21
- value : jsonValueStateControl ( null ) ,
22
- } ,
23
- ( ) => null
24
- )
20
+ {
21
+ name : SimpleNameComp ,
22
+ value : jsonValueStateControl ( null ) ,
23
+ } ,
24
+ ( ) => null
25
+ )
25
26
. setPropertyViewFn ( ( children ) => {
26
27
return (
27
28
< BottomTabs
@@ -80,7 +81,10 @@ const TemporaryStateItemCompWithMethodExpose = withMethodExposing(TemporaryState
80
81
description : "" ,
81
82
} ,
82
83
execute : async ( comp , params ) => {
83
- comp . children . value . change ( params ?. [ 0 ] ) ;
84
+ return new Promise ( async ( resolve ) => {
85
+ await comp . children . value . change ( params ?. [ 0 ] ) ;
86
+ resolve ( params ?. [ 0 ] )
87
+ } )
84
88
} ,
85
89
} ,
86
90
{
@@ -99,24 +103,27 @@ const TemporaryStateItemCompWithMethodExpose = withMethodExposing(TemporaryState
99
103
description : "" ,
100
104
} ,
101
105
execute : async ( comp , params ) => {
102
- const { value : prev , onChange } = comp . children . value . getView ( ) ;
103
- const [ path , value ] = params ;
104
- if (
105
- ! Array . isArray ( path ) ||
106
- ! path . every ( ( i ) => typeof i === "string" || typeof i === "number" )
107
- ) {
108
- throw new Error ( trans ( "temporaryState.pathTypeError" ) ) ;
109
- }
110
- if ( ! _ . isPlainObject ( prev ) && ! Array . isArray ( prev ) ) {
111
- throw new Error (
112
- trans ( "temporaryState.unStructuredError" , {
113
- path : JSON . stringify ( path ) ,
114
- prev : JSON . stringify ( prev ) ,
115
- } )
116
- ) ;
117
- }
118
- const nextValue = _ . set ( _ . cloneDeep ( prev as JSONObject ) , path as ( string | number ) [ ] , value ) ;
119
- onChange ( nextValue ) ;
106
+ return new Promise ( async ( resolve ) => {
107
+ const { value : prev , onChange } = comp . children . value . getView ( ) ;
108
+ const [ path , value ] = params ;
109
+ if (
110
+ ! Array . isArray ( path ) ||
111
+ ! path . every ( ( i ) => typeof i === "string" || typeof i === "number" )
112
+ ) {
113
+ throw new Error ( trans ( "temporaryState.pathTypeError" ) ) ;
114
+ }
115
+ if ( ! _ . isPlainObject ( prev ) && ! Array . isArray ( prev ) ) {
116
+ throw new Error (
117
+ trans ( "temporaryState.unStructuredError" , {
118
+ path : JSON . stringify ( path ) ,
119
+ prev : JSON . stringify ( prev ) ,
120
+ } )
121
+ ) ;
122
+ }
123
+ const nextValue = _ . set ( _ . cloneDeep ( prev as JSONObject ) , path as ( string | number ) [ ] , value ) ;
124
+ await onChange ( nextValue ) ;
125
+ resolve ( nextValue ) ;
126
+ } )
120
127
} ,
121
128
} ,
122
129
] ) ;
0 commit comments