@@ -2,6 +2,7 @@ import { hiddenPropertyView, showDataLoadingIndicatorsPropertyView } from "comps
22import {
33 ArrayOrJSONObjectControl ,
44 NumberControl ,
5+ StringControl ,
56} from "comps/controls/codeControl" ;
67import { dropdownControl } from "comps/controls/dropdownControl" ;
78import { BoolControl } from "comps/controls/boolControl" ;
@@ -19,6 +20,9 @@ import {
1920import { defaultLottie } from "./jsonConstants" ;
2021import { EditorContext } from "comps/editorState" ;
2122import { 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" ;
2226
2327const Player = lazy (
2428 ( ) => import ( '@lottiefiles/react-lottie-player' )
@@ -98,7 +102,8 @@ let JsonLottieTmpComp = (function () {
98102 JSON . stringify ( defaultLottie , null , 2 )
99103 ) ,
100104 srcIconScout : IconscoutControl ( IconScoutAssetType . LOTTIE ) ,
101- valueIconScout : ArrayOrJSONObjectControl ,
105+ uuidIconScout : StringControl ,
106+ valueIconScout : withDefault ( ArrayOrJSONObjectControl , JSON . stringify ( { } ) ) ,
102107 speed : dropdownControl ( speedOptions , "1" ) ,
103108 width : withDefault ( NumberControl , 100 ) ,
104109 height : withDefault ( NumberControl , 100 ) ,
@@ -108,11 +113,38 @@ let JsonLottieTmpComp = (function () {
108113 loop : dropdownControl ( loopOptions , "single" ) ,
109114 keepLastFrame : BoolControl . DEFAULT_TRUE ,
110115 } ;
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+
113144 return (
114145 < div
115146 style = { {
147+ height : '100%' ,
116148 padding : `${ props . container . margin } ` ,
117149 animation : props . animationStyle . animation ,
118150 animationDelay : props . animationStyle . animationDelay ,
@@ -139,7 +171,11 @@ let JsonLottieTmpComp = (function () {
139171 hover = { props . animationStart === "on hover" && true }
140172 loop = { props . loop === "single" ? false : true }
141173 speed = { Number ( props . speed ) }
142- src = { props . value }
174+ src = {
175+ props . sourceMode === 'advanced'
176+ ? ( isEmpty ( props . valueIconScout ) ? '' : props . valueIconScout )
177+ : props . value
178+ }
143179 style = { {
144180 height : "100%" ,
145181 width : "100%" ,
0 commit comments