@@ -2,6 +2,7 @@ import { hiddenPropertyView, showDataLoadingIndicatorsPropertyView } from "comps
2
2
import {
3
3
ArrayOrJSONObjectControl ,
4
4
NumberControl ,
5
+ StringControl ,
5
6
} from "comps/controls/codeControl" ;
6
7
import { dropdownControl } from "comps/controls/dropdownControl" ;
7
8
import { BoolControl } from "comps/controls/boolControl" ;
@@ -19,6 +20,9 @@ import {
19
20
import { defaultLottie } from "./jsonConstants" ;
20
21
import { EditorContext } from "comps/editorState" ;
21
22
import { IconScoutAssetType , IconscoutControl } from "@lowcoder-ee/comps/controls/iconscoutControl" ;
23
+ import { isEmpty } from "lodash" ;
24
+ import IconscoutApi from "@lowcoder-ee/api/iconscoutApi" ;
25
+ import { changeValueAction , multiChangeAction } from "lowcoder-core" ;
22
26
23
27
const Player = lazy (
24
28
( ) => import ( '@lottiefiles/react-lottie-player' )
@@ -98,7 +102,8 @@ let JsonLottieTmpComp = (function () {
98
102
JSON . stringify ( defaultLottie , null , 2 )
99
103
) ,
100
104
srcIconScout : IconscoutControl ( IconScoutAssetType . LOTTIE ) ,
101
- valueIconScout : ArrayOrJSONObjectControl ,
105
+ uuidIconScout : StringControl ,
106
+ valueIconScout : withDefault ( ArrayOrJSONObjectControl , JSON . stringify ( { } ) ) ,
102
107
speed : dropdownControl ( speedOptions , "1" ) ,
103
108
width : withDefault ( NumberControl , 100 ) ,
104
109
height : withDefault ( NumberControl , 100 ) ,
@@ -108,11 +113,38 @@ let JsonLottieTmpComp = (function () {
108
113
loop : dropdownControl ( loopOptions , "single" ) ,
109
114
keepLastFrame : BoolControl . DEFAULT_TRUE ,
110
115
} ;
111
- return new UICompBuilder ( childrenMap , ( props ) => {
112
- console . log ( props . srcIconScout ) ;
116
+ return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
117
+
118
+ const downloadAsset = async ( uuid : string ) => {
119
+ try {
120
+ const result = await IconscoutApi . download ( uuid , {
121
+ format : 'ai' ,
122
+ } ) ;
123
+ if ( result && result . download_url ) {
124
+ const json = await IconscoutApi . downloadJSON ( result . download_url ) ;
125
+ dispatch (
126
+ multiChangeAction ( {
127
+ uuidIconScout : changeValueAction ( uuid , true ) ,
128
+ valueIconScout : changeValueAction ( JSON . stringify ( json , null , 2 ) , true )
129
+ } )
130
+ )
131
+ }
132
+ } catch ( error ) {
133
+ console . error ( error ) ;
134
+ }
135
+
136
+ }
137
+ useEffect ( ( ) => {
138
+ if ( props . srcIconScout ?. uuid && props . srcIconScout ?. uuid !== props . uuidIconScout ) {
139
+ // get asset download link
140
+ downloadAsset ( props . srcIconScout ?. uuid ) ;
141
+ }
142
+ } , [ props . srcIconScout ] ) ;
143
+
113
144
return (
114
145
< div
115
146
style = { {
147
+ height : '100%' ,
116
148
padding : `${ props . container . margin } ` ,
117
149
animation : props . animationStyle . animation ,
118
150
animationDelay : props . animationStyle . animationDelay ,
@@ -139,7 +171,11 @@ let JsonLottieTmpComp = (function () {
139
171
hover = { props . animationStart === "on hover" && true }
140
172
loop = { props . loop === "single" ? false : true }
141
173
speed = { Number ( props . speed ) }
142
- src = { props . value }
174
+ src = {
175
+ props . sourceMode === 'advanced'
176
+ ? ( isEmpty ( props . valueIconScout ) ? '' : props . valueIconScout )
177
+ : props . value
178
+ }
143
179
style = { {
144
180
height : "100%" ,
145
181
width : "100%" ,
0 commit comments