kubai-icons 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/duotone.js +1 -1
- package/package.json +1 -1
package/dist/duotone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _="0 0 16 16",B={square:1.0833333333333333},y=t=>+t.toFixed(3),T="var(--kd-b,color-mix(in srgb,currentColor 40%,#fff))";function H(t,{colors:o}={}){const
|
|
1
|
+
const _="0 0 16 16",B={square:1.0833333333333333},y=t=>+t.toFixed(3),T="var(--kd-b,color-mix(in srgb,currentColor 40%,#fff))";function H(t,{colors:o}={}){const s=B[t.key]||1,u="__K__",n=!!o,c=n?t.layers.filter(e=>!/^[ca]\d+$/.test(String(e.n))):t.layers,a=e=>o?e.tone==="b"?o.b:o.a:e.tone==="b"?null:e.part==="badge"?"var(--ki-b, currentColor)":"currentColor",$=[],d=(e,r,p=0,m=!1)=>{const b=r===null?` style="${e.sw?"stroke":"fill"}:${T}"`:"",l=r??"#000";return e.sw?`<path d="${e.d}" fill="none" stroke="${l}"${b} stroke-width="${y((e.sw+p)/s)}" stroke-linecap="round" stroke-linejoin="round"${m?' pathLength="1"':""}/>`:p?`<path d="${e.d}" fill="${l}" stroke="${l}" stroke-width="${y(p/s)}" stroke-linejoin="round"/>`:`<path d="${e.d}" fill="${l}"${b}/>`},i='maskUnits="userSpaceOnUse" x="-2" y="-2" width="20" height="20"><rect x="-2" y="-2" width="20" height="20" fill="#fff"/>',h=[],g=e=>{const r=t.moves?.[e];if(n||!r?.rest)return"";const p=A(r);let m=` transform="${M(r,p)}"`;return r.rest.a!==void 0&&(m+=` opacity="${w(p.a)}"`),r.rest.w!==void 0&&(m+=` stroke-dasharray="${w(p.w)} 2" stroke-opacity="${p.w<.01?0:1}"`),m},k=(e,r,p)=>`<g data-l="${e.n??r}"${g(e.n??r)}>${p}</g>`;c.forEach((e,r)=>{const p=e.part??`#${r}`;if(e.gap){$.push(`<mask id="${u}-g${r}" ${i}${k(e,r,d(e,"#000",e.gap*2,!0))}</mask>`);for(const l of h)l.part!==p&&(l.svg=`<g mask="url(#${u}-g${r})">${l.svg}</g>`)}e.clip&&$.push(`<clipPath id="${u}-c${r}" clipPathUnits="userSpaceOnUse"><path d="${e.clip}"/></clipPath>`),e.cut?.length&&$.push(`<mask id="${u}-x${r}" ${i}${e.cut.map(l=>d(l,"#000")).join("")}</mask>`);const m=l=>(e.clip&&(l=`<g clip-path="url(#${u}-c${r})">${l}</g>`),e.cut?.length?`<g mask="url(#${u}-x${r})">${l}</g>`:l);let b=d(e,a(e),0,!0);if(o?.light!==void 0&&e.tone==="b"){b=b.replace("<path ",`<path opacity="${o.light}" `),h.length&&$.push(`<mask id="${u}-o${r}" ${i}${m(d(e,"#000"))}</mask>`);for(const l of h)l.svg=`<g mask="url(#${u}-o${r})">${l.svg}</g>`}h.push({part:p,svg:k(e,r,m(b))})});let f=`<g data-l="all"${g("all")}>${h.map(e=>e.svg).join("")}</g>`;return s!==1&&(f=`<g transform="translate(8 8) scale(${y(s)}) translate(-8 -8)">${f}</g>`),($.length?`<defs>${$.join("")}</defs>`:"")+f}const N=(t,o,s,u,n)=>({name:t,markup:o,viewBox:_,style:"duotone",moves:s,...u?{ms:u}:{},...n?{tone:n}:{},tap:!1}),F=480,q=110,C=360;function E(t,o,s,u){const n=3*t,c=3*(s-t)-n,a=1-n-c,$=3*o,d=3*(u-o)-$,i=1-$-d,h=f=>((a*f+c)*f+n)*f,g=f=>((i*f+d)*f+$)*f,k=f=>(3*a*f+2*c)*f+n;return f=>{if(f<=0)return 0;if(f>=1)return 1;let e=f;for(let r=0;r<8;r++){const p=h(e)-f;if(Math.abs(p)<1e-5)break;const m=k(e);if(Math.abs(m)<1e-6)break;e-=p/m}return g(e)}}const P=E(.34,1.56,.64,1),I=E(.33,1,.68,1),x={x:0,y:0,r:0,s:1,sx:1,sy:1,a:1,w:1},j=Object.keys(x),K=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,A=t=>({...x,...t.rest||{}});function L(t,o,s,u){const n=[t,...Array.isArray(o)?o:[o]],c=n.length-1;if(c===1)return t+(n[1]-t)*u(s);const a=Math.min(c-1e-9,Math.max(0,s*c)),$=Math.floor(a),d=a-$;return n[$]+(n[$+1]-n[$])*($===c-1?u(d):K(d))}const R=t=>Math.max(1,...j.filter(o=>Array.isArray(t[o])).map(o=>t[o].length)),z=t=>t.ms??F+q*(Math.max(1,...Object.values(t.moves||{}).map(R))-1);function v(t,o,s,u){const n=A(t),c={};for(const a of j)(a in t||t.rest&&a in t.rest)&&(c[a]=L((s||n)[a]??n[a],u&&a in t?t[a]:n[a],o,u?P:I));return c}const w=t=>y(Math.min(1,Math.max(0,t)));function M(t,o){const s=a=>a in o?o[a]:x[a],[u,n]=t.o||[8,8],c=s("s");return`translate(${y(s("x")+u)} ${y(s("y")+n)}) rotate(${y(s("r"))}) scale(${y(c*s("sx"))} ${y(c*s("sy"))}) translate(${-u} ${-n})`}function Q(t,o){const s={};for(const[u,n]of Object.entries(t.moves||{})){const c=v(n,o,null,!0),a={transform:M(n,c)};"a"in c&&(a.opacity=w(c.a)),"w"in c&&(a["stroke-dasharray"]=`${w(c.w)} 2`,a["stroke-opacity"]=c.w<.01?0:1),s[u]=a}return s}let O=null;try{O=matchMedia("(prefers-reduced-motion: reduce)")}catch{}const G=()=>!!(O&&O.matches),D=t=>typeof requestAnimationFrame=="function"?requestAnimationFrame(t):setTimeout(()=>t(Date.now()),16),S=t=>typeof cancelAnimationFrame=="function"?cancelAnimationFrame(t):clearTimeout(t),U=()=>typeof performance<"u"?performance.now():Date.now();function V(t,o){const s=Object.keys(o.moves||{}).map(i=>({p:o.moves[i],list:[...t.querySelectorAll(`[data-l="${i}"]`)],cur:A(o.moves[i])})),u=z(o);let n=!1,c=0,a=!1;const $=i=>{const h=M(i.p,i.cur);for(const g of i.list)g.setAttribute("transform",h),("a"in i.p||i.p.rest?.a!==void 0)&&g.setAttribute("opacity",w(i.cur.a)),"w"in i.p&&(g.setAttribute("stroke-dasharray",`${w(i.cur.w)} 2`),g.setAttribute("stroke-opacity",i.cur.w<.01?0:1))};for(const i of s)i.p.rest&&$(i);const d=i=>{S(c);const h=s.map(e=>({...e.cur}));if(i||G()){s.forEach((e,r)=>{e.cur={...e.cur,...v(e.p,1,h[r],n)},$(e)});return}const g=n?u:C,k=U(),f=e=>{if(a)return;const r=Math.min(1,Math.max(0,((typeof e=="number"?e:U())-k)/g));s.forEach((p,m)=>{p.cur={...p.cur,...v(p.p,r,h[m],n)},$(p)}),r<1&&(c=D(f))};c=D(f)};return{hover(i,h){!!i!==n&&s.length&&(n=!!i,d(h))},state(){},get hovered(){return n},get active(){return!1},svg:t,destroy(){a=!0,S(c)}}}export{C as DUO_BACK,F as DUO_DURATION,q as DUO_STEP,_ as DUO_VIEWBOX,V as animateDuotone,N as duo,z as duoDuration,H as duoMarkup,Q as duoPose};
|
package/package.json
CHANGED