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 4.08 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,1);const u=Symbol(`yak`);var d=class{constructor(e){this.value=e||``}add(e){this.value+=(this.value&&` `)+e}has(e){return(` `+this.value+` `).includes(` `+e+` `)}delete(e){this.has(e)&&(this.value=this.value.split(` `).filter(t=>t!==e).join(` `))}};function f(...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(m(e,i)):n[t]=String(i)}});return n.length===0?Object.assign((e,n)=>{t&&n.add(t)},{$dynamic:!1}):Object.assign((e,r,i)=>{t&&r.add(t);for(let t=0;t<n.length;t++)p(e,n[t],r,i)},{$dynamic:!0})}const p=(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}},m=(e,t)=>{let n=t(e);if(typeof n==`function`)return m(e,n);if(typeof n!=`string`&&typeof n!=`number`&&!(n instanceof String)&&process.env.NODE_ENV===`development`)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},h=(...e)=>{let t=new d,n=[];for(let r of e)typeof r==`string`?t.add(r):typeof r==`function`&&n.push(r);return f(t.value,...n)},g=(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++)_(e,n[t]);return{className:``,style:void 0}})};function _(e,t){let n=new Set,r={},i=t(e,n,r);for(;typeof i==`function`;)i=i(e,n,r);return i}const v=(e,...t)=>``,y=`$__a`,b=(e,t)=>e?t?e+` `+t:e:t||void 0,x=e=>Object.assign(S(e),{attrs:t=>S(e,t)}),S=(e,t)=>{let n=typeof e!=`string`&&u in e,[,r,i,a]=n?e[u]:[],o=n?a:e,s=T(t,r),p=s?.$sa;return(e,...t)=>{let n=E(f(e,...t),i),r=e=>{if((!s||p)&&!n.$dynamic){let t=p&&!(`$__a`in e)?w({...e,[y]:!0},p):e,r=C(t);if(!(`$__r`in t)){let e=new d(t.className);n(t,e,void 0),r.className=e.value||void 0}let i=o;return l.default.createElement(i,r)}let t=(0,c.useTheme)(),r=`$__a`in e?{theme:t,...e}:w({theme:t,...e,[y]:!0},s?.({theme:t,...e}));if(!(`$__r`in r)){let e=new d(r.className),t=n.$dynamic?{...r.style}:r.style;n(r,e,t),r.$__r=!0,r.className=e.value||void 0,t!==r.style&&(r.style=t)}let{theme:i,...a}=r,u=C(i===t?a:r),f=o;return l.default.createElement(f,u)},a=r;return a[u]=[r,s,n,o],a}},C=e=>{let t={};for(let n in e)!n.startsWith(`$`)&&e[n]!==void 0&&(t[n]=e[n]);return t},w=(e,t)=>t?(e.className===t.className||!t.className)&&(e.style===t.style||!t.style)?{...e,...t}:{...e,...t,className:b(e.className,t.className),style:{...e.style,...t.style}}:e,T=(e,t)=>{let n=e&&(typeof e==`function`?e:()=>e);return n&&t?e=>{let r=t(e);return w(r,n(w(e,r)))}:n&&typeof e!=`function`?Object.assign(n,{$sa:e}):n||t},E=(e,t)=>e&&t?Object.assign((n,r,i)=>{t(n,r,i),e(n,r,i)},{$dynamic:e.$dynamic||t.$dynamic}):e||t,D=new Proxy(x,{get(e,t){return e(t)}}),O=(e,...t)=>{};Object.defineProperty(exports,"YakThemeProvider",{enumerable:!0,get:function(){return c.YakThemeProvider}}),exports.atoms=h,exports.css=g,exports.globalStyle=O,exports.keyframes=v,exports.styled=D,Object.defineProperty(exports,"useTheme",{enumerable:!0,get:function(){return c.useTheme}}); //# sourceMappingURL=index.cjs.map