UNPKG

@lordicon/react

Version:

This library allows you to easily integrate the playback of Lordicon icons into a React application.

3 lines (2 loc) 1.02 kB
import{deepClone as t,readProperties as o,isNil as e,parseColors as n,parseColor as r,hexToLottieColor as s,updateProperties as c,isObjectLike as i}from"@lordicon/helpers";function f(t,o){const e=[];for(const n of Object.keys(t)){const r=t[n];i(r)&&e.push(...f(r,o))}return t.x&&"string"==typeof t.x&&t.x.includes(o)&&e.push(t),e}function a(i){let a,l,u=[],p=[];if(i.icon&&(a=t(i.icon)),a){if(p=o(a),u=(a.markers||[]).map((t=>{const[o,n]=t.cm.split(":"),r={time:t.tm,duration:t.dr,name:n||o,default:!(!n||!o.includes("default"))};return(r.name===i.state||r.default&&e(i.state))&&(l=r),r})),u.length){const t=u[0],o=u[u.length-1];a.ip=t.time,a.op=o.time+o.duration+1}i.colors&&function(t,o,e){for(const n of Object.keys(e)){const i=r(e[n]),a=f(t,`effect('${n}')('Color')`),l=s(i);for(const t of a)t.k=[...l,1];for(const e of o)e.name===n&&(c(t,[e],l),e.value=l)}}(a,p.filter((t=>"color"===t.type)),n(i.colors))}return{properties:p,iconData:a,states:u,state:l}}export{a as h}; //# sourceMappingURL=helpers-CE3Eu4wb.js.map