UNPKG

next-yak

Version:

next-yak is a CSS-in-JS solution tailored for Next.js that seamlessly combines the expressive power of styled-components syntax with efficient build-time extraction of CSS using Next.js's built-in CSS configuration

2 lines 3.62 kB
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`next-yak/context`),l=require(`react`);l=s(l);const u=Symbol(`yak`);function d(...e){let t,n=[];for(let r of e)typeof r==`string`?t=r:typeof r==`function`?n.push(r):typeof r==`object`&&`style`in r&&n.push((e,t,n)=>{for(let t in r.style){let i=r.style[t];typeof i==`function`?n[t]=String(p(e,i)):n[t]=String(i)}});return n.length===0?(e,n)=>(t&&n.add(t),()=>{}):(e,r,i)=>{t&&r.add(t);for(let t=0;t<n.length;t++)f(e,n[t],r,i)}}const f=(e,t,n,r)=>{let i=t(e,n,r);for(;i;){if(typeof i==`function`){i=i(e,n,r);continue}else if(typeof i==`object`&&(`className`in i&&i.className&&n.add(i.className),`style`in i&&i.style))for(let e in i.style)r[e]=i.style[e];break}},p=(e,t)=>{let n=t(e);if(typeof n==`function`)return p(e,n);if(process.env.NODE_ENV===`development`&&typeof n!=`string`&&typeof n!=`number`&&!(n instanceof String))throw Error(`Dynamic CSS functions must return a string or number but returned ${JSON.stringify(n)}\n\nDynamic CSS function: ${t.toString()}\n`);return n},m=(...e)=>{let t=[],n=[];for(let r of e)typeof r==`string`?t.push(...r.split(` `)):typeof r==`function`&&n.push(r);return d(...t.length>0?[(e,n)=>{t.forEach(e=>n.add(e))},...n]:n)},h=(e,...t)=>{if(Array.isArray(e)&&`raw`in e){let n=e[0];for(let r=0;r<t.length;r++){let i=t[r];n+=i&&typeof i==`object`&&`__yak`in i?i.__yak:String(i),n+=e[r+1]}return{__yak:n}}let n=[];for(let e of t)typeof e==`function`&&n.push(e);return n.length===0?{className:``,style:void 0}:(e=>{for(let t=0;t<n.length;t++)g(e,n[t]);return{className:``,style:void 0}})};function g(e,t){let n=new Set,r={},i=t(e,n,r);for(;typeof i==`function`;)i=i(e,n,r);return i}const _=(e,...t)=>``,v={},y=e=>Object.assign(b(e),{attrs:t=>b(e,t)}),b=(e,t)=>{let n=typeof e!=`string`&&u in e,[r,i,a]=n?e[u]:[],o=w(t,i);return(t,...i)=>{let s=d(t,...i),f=T(s,a),p=t=>{let i=o||s.length?(0,c.useTheme)():v,a=`$__attrs`in t?{theme:i,...t}:C({theme:i,...t,$__attrs:!0},o?.({theme:i,...t})),u=new Set(`className`in a?a.className?.split(` `):[]),d={...`style`in a?a.style:{}};`$__runtimeStylesProcessed`in a||(f(a,u,d),a.$__runtimeStylesProcessed=!0),a.className=Array.from(u).join(` `)||void 0,a.style=d;let{theme:p,...m}=a,h=p===i?m:a,g=n?h:x(h);return r?r(g):l.default.createElement(e,g)};return Object.assign(p,{[u]:[p,o,f]})}},x=e=>{let t={};for(let n in e)!n.startsWith(`$`)&&e[n]!==void 0&&(t[n]=e[n]);return t},S=(e,t)=>{if(!(!e&&!t))return e?t?e+` `+t:e:t},C=(e,t)=>t?(e.className===t.className||!t.className)&&(e.style===t.style||!t.style)?{...e,...t}:{...e,...t,className:S(e.className,t.className),style:{...e.style,...t.style}}:e,w=(e,t)=>{let n=e&&(typeof e==`function`?e:()=>e);return n&&t?e=>{let r=t(e);return C(r,n(C(e,r)))}:n||t},T=(e,t)=>e&&t?(n,r,i)=>{t(n,r,i),e(n,r,i)}:e||t,E=new Proxy(y,{get(e,t){return e(t)}});Object.defineProperty(exports,`YakThemeProvider`,{enumerable:!0,get:function(){return c.YakThemeProvider}}),exports.atoms=m,exports.css=h,exports.keyframes=_,exports.styled=E,Object.defineProperty(exports,`useTheme`,{enumerable:!0,get:function(){return c.useTheme}}); //# sourceMappingURL=index.cjs.map