next-yak 5.6.1 → 5.7.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/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var B=Object.create;var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var s in e)m(t,s,{get:e[s],enumerable:!0})},C=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!J.call(t,n)&&n!==s&&m(t,n,{get:()=>e[n],enumerable:!(r=E(e,n))||r.enumerable});return t};var L=(t,e,s)=>(s=t!=null?B(w(t)):{},C(e||!t||!t.__esModule?m(s,"default",{value:t,enumerable:!0}):s,t)),X=t=>C(m({},"__esModule",{value:!0}),t);var V={};H(V,{YakThemeProvider:()=>u.YakThemeProvider,atoms:()=>I,css:()=>k,keyframes:()=>x,styled:()=>j,useTheme:()=>u.useTheme});module.exports=X(V);var u=require("next-yak/context");var I=(...t)=>{let e=t.join(" ");return()=>({className:e})};var k=(t,...e)=>{let s=[];for(let r of e)typeof r=="function"&&s.push(r);return s.length===0?{className:"",style:void 0}:r=>{for(let n=0;n<s.length;n++)$(r,s[n]);return{className:"",style:void 0}}};function $(t,e){let s=e(t);for(;typeof s=="function";)s=s(t);return s}var x=(t,...e)=>"";var y=Symbol("yak");function P(...t){let e=[],s=[],r={};for(let n of t)if(typeof n=="string")e.push(n);else if(typeof n=="function")s.push(n);else if(typeof n=="object"&&"style"in n)for(let o in n.style){let a=n.style[o];typeof a=="function"?s.push(i=>({style:{[o]:String(b(i,a))}})):r[o]=a}if(s.length===0){let n=e.join(" ");return()=>({className:n,style:r})}return n=>{let o=[...e],a={...r};for(let i=0;i<s.length;i++)D(n,s[i],o,a);return{className:o.join(" "),style:a}}}var D=(t,e,s,r)=>{let n=e(t);for(;n;){if(typeof n=="function"){n=n(t);continue}else if(typeof n=="object"&&("className"in n&&n.className&&s.push(n.className),"style"in n&&n.style))for(let o in n.style)r[o]=n.style[o];break}},b=(t,e)=>{let s=e(t);if(typeof s=="function")return b(t,s);if(process.env.NODE_ENV==="development"&&typeof s!="string"&&typeof s!="number"&&!(s instanceof String))throw new Error(`Dynamic CSS functions must return a string or number but returned ${JSON.stringify(s)}
1
+ "use strict";var E=Object.create;var m=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},A=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of D(e))!M.call(t,s)&&s!==n&&m(t,s,{get:()=>e[s],enumerable:!(r=$(e,s))||r.enumerable});return t};var J=(t,e,n)=>(n=t!=null?E(L(t)):{},A(e||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),W=t=>A(m({},"__esModule",{value:!0}),t);var U={};H(U,{YakThemeProvider:()=>f.YakThemeProvider,atoms:()=>h,css:()=>N,keyframes:()=>I,styled:()=>O,useTheme:()=>f.useTheme});module.exports=W(U);var f=require("next-yak/context");var u=Symbol("yak");function p(...t){let e,n=[],r={};for(let s of t)if(typeof s=="string")e=s;else if(typeof s=="function")n.push(s);else if(typeof s=="object"&&"style"in s)for(let o in s.style){let i=s.style[o];typeof i=="function"?n.push(a=>({style:{[o]:String(R(a,i))}})):r[o]=i}return n.length===0?(s,o)=>(e&&o.add(e),()=>{}):(s,o,i)=>{e&&o.add(e);for(let a=0;a<n.length;a++)B(s,n[a],o,i)}}var B=(t,e,n,r)=>{let s=e(t,n,r);for(;s;){if(typeof s=="function"){s=s(t,n,r);continue}else if(typeof s=="object"&&("className"in s&&s.className&&n.add(s.className),"style"in s&&s.style))for(let o in s.style)r[o]=s.style[o];break}},R=(t,e)=>{let n=e(t);if(typeof n=="function")return R(t,n);if(process.env.NODE_ENV==="development"&&typeof n!="string"&&typeof n!="number"&&!(n instanceof String))throw new Error(`Dynamic CSS functions must return a string or number but returned ${JSON.stringify(n)}
2
2
 
3
3
  Dynamic CSS function: ${e.toString()}
4
- `);return s};var N=L(require("react"),1),F=require("next-yak/context"),_={},K=t=>Object.assign(h(t),{attrs:e=>h(t,e)}),h=(t,e)=>{let s=typeof t!="string"&&y in t,[r,n]=s?t[y]:[],o=U(e,n);return(a,...i)=>{let d=P(a,...i),g=c=>{let l=o||d.length?(0,F.useTheme)():_,p="$__attrs"in c?{theme:l,...c}:f({theme:l,...c,$__attrs:!0},o?.({theme:l,...c})),S=d(p),{theme:M,...Y}=p,A=M===l?Y:p,T=s?A:W(A);return T.className=R(T.className,S.className),T.style="style"in T?{...T.style,...S.style}:S.style,r?r(T):N.default.createElement(t,{...T})};return Object.assign(g,{[y]:[g,o]})}},O=K,W=t=>{let e={};for(let s in t)!s.startsWith("$")&&t[s]!==void 0&&(e[s]=t[s]);return e},R=(t,e)=>{if(!(!t&&!e))return t?e?t+" "+e:t:e},f=(t,e)=>e?(t.className===e.className||!e.className)&&(t.style===e.style||!e.style)?{...t,...e}:{...t,...e,className:R(t.className,e.className),style:{...t.style||{},...e.style||{}}}:t,U=(t,e)=>{let s=t&&(typeof t=="function"?t:()=>t);return s&&e?r=>{let n=e(r);return f(n,s(f(r,n)))}:s||e};var j=new Proxy(O,{get(t,e){return t(e)}});0&&(module.exports={YakThemeProvider,atoms,css,keyframes,styled,useTheme});
4
+ `);return n};var h=(...t)=>{let e=[],n=[];for(let s of t)typeof s=="string"?e.push(...s.split(" ")):typeof s=="function"&&n.push(s);let r=e.length>0?[(s,o)=>{e.forEach(i=>o.add(i))},...n]:n;return p(...r)};var N=(t,...e)=>{let n=[];for(let r of e)typeof r=="function"&&n.push(r);return n.length===0?{className:"",style:void 0}:r=>{for(let s=0;s<n.length;s++)G(r,n[s]);return{className:"",style:void 0}}};function G(t,e){let n=new Set,r={},s=e(t,n,r);for(;typeof s=="function";)s=s(t,n,r);return s}var I=(t,...e)=>"";var w=J(require("react"),1),F=require("next-yak/context"),V={},X=t=>Object.assign(b(t),{attrs:e=>b(t,e)}),Y=X,b=(t,e)=>{let n=typeof t!="string"&&u in t,[r,s,o]=n?t[u]:[],i=K(e,s);return(a,...j)=>{let d=p(a,...j),T=Q(d,o),g=l=>{let y=i||d.length?(0,F.useTheme)():V,c="$__attrs"in l?{theme:y,...l}:S({theme:y,...l,$__attrs:!0},i?.({theme:y,...l})),P=new Set("className"in c?c.className?.split(" "):[]),k={..."style"in c?c.style:{}};"$__runtimeStylesProcessed"in c||(T(c,P,k),c.$__runtimeStylesProcessed=!0),c.className=Array.from(P).join(" ")||void 0,c.style=k;let{theme:v,..._}=c,C=v===y?_:c,x=n?C:q(C);return r?r(x):w.default.createElement(t,{...x})};return Object.assign(g,{[u]:[g,i,T]})}},q=t=>{let e={};for(let n in t)!n.startsWith("$")&&t[n]!==void 0&&(e[n]=t[n]);return e},z=(t,e)=>{if(!(!t&&!e))return t?e?t+" "+e:t:e},S=(t,e)=>e?(t.className===e.className||!e.className)&&(t.style===e.style||!e.style)?{...t,...e}:{...t,...e,className:z(t.className,e.className),style:{...t.style||{},...e.style||{}}}:t,K=(t,e)=>{let n=t&&(typeof t=="function"?t:()=>t);return n&&e?r=>{let s=e(r);return S(s,n(S(r,s)))}:n||e},Q=(t,e)=>t&&e?(r,s,o)=>{e(r,s,o),t(r,s,o)}:t||e;var O=new Proxy(Y,{get(t,e){return t(e)}});0&&(module.exports={YakThemeProvider,atoms,css,keyframes,styled,useTheme});
5
5
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../runtime/index.ts","../runtime/atoms.tsx","../runtime/mocks/cssLiteral.ts","../runtime/mocks/keyframes.ts","../runtime/cssLiteral.tsx","../runtime/styled.tsx","../runtime/mocks/styled.ts"],"sourcesContent":["/**\n * This file contains the typings for the public API for next-yak and testing mocks\n *\n * IMPORTANT: In production builds, imports to this file should be replaced by the Babel plugin.\n * If you're seeing this code in a production environment, your build process may not be configured correctly.\n *\n * Purpose:\n * 1. Provide a test-friendly version of the next-yak API\n * 2. Offer type definitions for the public API\n *\n * Usage in tests:\n * - Import from \"next-yak\" as usual in your test files\n * - These mock implementations will be used instead of the actual runtime\n *\n * Warning for production:\n * - If these exports are used in a production build, styles will not be applied correctly\n * - Ensure your build process is configured to use the next-yak Babel plugin\n *\n * For maintainers:\n * - Keep this API surface in sync with the actual implementation in next-yak/internal\n * - Ensure mock implementations here are suitable for testing purposes\n */\n\n// the following export is not relative as \"next-yak/context\"\n// links to one file for react server components and\n// to another file for classic react components\nexport { useTheme, YakThemeProvider } from \"next-yak/context\";\nexport type { YakTheme } from \"./context/index.d.ts\";\n\nexport { atoms } from \"./atoms.js\";\nexport { css } from \"./mocks/cssLiteral.js\";\nexport { keyframes } from \"./mocks/keyframes.js\";\nexport { styled } from \"./mocks/styled.js\";\n","/**\n * Allows to use atomic CSS classes in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, atoms } from \"next-yak\";\n *\n * const Button = styled.button<{ $primary?: boolean }>`\n * ${atoms(\"text-teal-600\", \"text-base\", \"rounded-md\")}\n * ${props => props.$primary && atoms(\"shadow-md\")}\n * `;\n * ```\n */\nexport const atoms = (...atoms: string[]) => {\n const className = atoms.join(\" \");\n return () => ({ className });\n};\n","import type { css as cssInternal, PropsToClassNameFn } from \"../cssLiteral.js\";\n\nexport type { ComponentStyles, CSSInterpolation } from \"../cssLiteral.js\";\n\n/**\n * Allows to use CSS styles in a styled or css block\n *\n * e.g.\n *\n * ```tsx\n * const Component = styled.div`\n * color: black;\n * ${({$active}) => $active && css`color: red;`}\n * `;\n * ```\n */\nexport const css: typeof cssInternal = (\n styles: TemplateStringsArray,\n ...args: unknown[]\n) => {\n const dynamicCssFunctions: PropsToClassNameFn[] = [];\n for (const arg of args as Array<string | Function | object>) {\n // Dynamic CSS e.g.\n // css`${props => props.active && css`color: red;`}`\n // compiled -> css((props: { active: boolean }) => props.active && css(\"yak31e4\"))\n if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg as unknown as PropsToClassNameFn);\n }\n }\n if (dynamicCssFunctions.length === 0) {\n return {\n className: \"\",\n style: undefined,\n };\n }\n return ((props: unknown) => {\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n // run the dynamic expressions and ignore the return value\n // the execution is important to ensure that the user code is executed\n // the same way as in the real runtime\n executeDynamicExpressionRecursively(props, dynamicCssFunctions[i]);\n }\n return {\n className: \"\",\n style: undefined,\n };\n }) as any;\n};\n\nfunction executeDynamicExpressionRecursively(\n props: unknown,\n expression: PropsToClassNameFn,\n) {\n let result = expression(props);\n while (typeof result === \"function\") {\n result = result(props);\n }\n return result;\n}\n","import type { keyframes as keyframesInternal } from \"../keyframes.js\";\n\n/**\n * Allows to use CSS keyframe animations in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, keyframes } from \"next-yak\";\n *\n * const rotate = keyframes`\n * from {\n * transform: rotate(0deg);\n * }\n * to {\n * transform: rotate(360deg);\n * }\n * `;\n *\n * const Spinner = styled.div`\n * animation: ${rotate} 1s linear infinite;\n * `;\n * ```\n */\nexport const keyframes: typeof keyframesInternal = (styles, ...dynamic) => {\n // the keyframes function is a no-op in the mock\n // as it has no dynamic runtime behavior but only css\n return \"\";\n};\n","import type { YakTheme } from \"./index.d.ts\";\n\nexport const yakComponentSymbol = Symbol(\"yak\");\n\nexport type ComponentStyles<TProps> = (props: TProps) => {\n className: string;\n style?: {\n [key: string]: string;\n };\n};\n\nexport type CSSInterpolation<TProps> =\n | string\n | number\n | undefined\n | null\n | false\n | ComponentStyles<TProps>\n | {\n // type only identifier to allow targeting components\n // e.g. styled.svg`${Button}:hover & { fill: red; }`\n [yakComponentSymbol]: any;\n }\n | ((props: TProps) => CSSInterpolation<TProps>);\n\ntype CSSStyles<TProps = {}> = {\n style: { [key: string]: string | ((props: TProps) => string) };\n};\n\ntype CSSFunction = <TProps = {}>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<TProps & { theme: YakTheme }>[]\n) => ComponentStyles<TProps>;\n\nexport type PropsToClassNameFn = (props: unknown) =>\n | {\n className?: string;\n style?: Record<string, string>;\n }\n | PropsToClassNameFn;\n\n/**\n * css() runtime factory of css``\n *\n * /!\\ next-yak transpiles css`` and styled``\n *\n * This changes the typings of the css`` and styled`` functions.\n * During development the user of next-yak wants to work with the\n * typings BEFORE compilation.\n *\n * Therefore this is only an internal function only and it must be cast to any\n * before exported to the user.\n */\nexport function css<TProps>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<NoInfer<TProps> & { theme: YakTheme }>[]\n): ComponentStyles<TProps>;\nexport function css<TProps>(...args: Array<any>): ComponentStyles<TProps> {\n const classNames: string[] = [];\n const dynamicCssFunctions: PropsToClassNameFn[] = [];\n const style: Record<string, string> = {};\n for (const arg of args as Array<string | CSSFunction | CSSStyles<any>>) {\n // A CSS-module class name which got auto generated during build from static css\n // e.g. css`color: red;`\n // compiled -> css(\"yak31e4\")\n if (typeof arg === \"string\") {\n classNames.push(arg);\n }\n // Dynamic CSS e.g.\n // css`${props => props.active && css`color: red;`}`\n // compiled -> css((props: { active: boolean }) => props.active && css(\"yak31e4\"))\n else if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg as unknown as PropsToClassNameFn);\n }\n // Dynamic CSS with css variables e.g.\n // css`transform: translate(${props => props.x}, ${props => props.y});`\n // compiled -> css(\"yak31e4\", { style: { \"--yakVarX\": props => props.x }, \"--yakVarY\": props => props.y }})\n else if (typeof arg === \"object\" && \"style\" in arg) {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n dynamicCssFunctions.push((props: unknown) => ({\n style: {\n [key]: String(\n // The value for a css value can be a theme dependent function e.g.:\n // const borderColor = (props: { theme: { mode: \"dark\" | \"light\" } }) => props.theme === \"dark\" ? \"black\" : \"white\";\n // css`border-color: ${borderColor};`\n // Therefore the value has to be extracted recursively\n recursivePropExecution(props, value),\n ),\n },\n }));\n } else {\n style[key] = value;\n }\n }\n }\n }\n\n // Non Dynamic CSS\n if (dynamicCssFunctions.length === 0) {\n const className = classNames.join(\" \");\n return () => ({ className, style });\n }\n\n return (props: unknown) => {\n const allClassNames: string[] = [...classNames];\n const allStyles: Record<string, string> = { ...style };\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n unwrapProps(props, dynamicCssFunctions[i], allClassNames, allStyles);\n }\n return {\n className: allClassNames.join(\" \"),\n style: allStyles,\n };\n };\n}\n\n// Dynamic CSS with runtime logic\nconst unwrapProps = (\n props: unknown,\n fn: PropsToClassNameFn,\n classNames: string[],\n style: Record<string, string>,\n) => {\n let result = fn(props);\n while (result) {\n if (typeof result === \"function\") {\n result = result(props);\n continue;\n } else if (typeof result === \"object\") {\n if (\"className\" in result && result.className) {\n classNames.push(result.className);\n }\n if (\"style\" in result && result.style) {\n for (const key in result.style) {\n style[key] = result.style[key];\n }\n }\n }\n break;\n }\n};\n\nconst recursivePropExecution = (\n props: unknown,\n fn: (props: unknown) => any,\n): string | number => {\n const result = fn(props);\n if (typeof result === \"function\") {\n return recursivePropExecution(props, result);\n }\n if (process.env.NODE_ENV === \"development\") {\n if (\n typeof result !== \"string\" &&\n typeof result !== \"number\" &&\n !(result instanceof String)\n ) {\n throw new Error(\n `Dynamic CSS functions must return a string or number but returned ${JSON.stringify(\n result,\n )}\\n\\nDynamic CSS function: ${fn.toString()}\\n`,\n );\n }\n }\n return result;\n};\n","import { CSSInterpolation, css, yakComponentSymbol } from \"./cssLiteral.js\";\nimport React, {\n HTMLAttributes,\n HtmlHTMLAttributes,\n SVGAttributes,\n} from \"react\";\n\n// the following export is not relative as \"next-yak/context\"\n// links to one file for react server components and\n// to another file for classic react components\nimport { useTheme } from \"next-yak/context\";\nimport type { YakTheme } from \"./context/index.d.ts\";\n\n/** Symbols */\n\n/**\n * This Symbol is a fake theme which was used instead of the real one from the context\n * to speed up rendering\n */\nconst noTheme: YakTheme = {};\n\n/**\n * All valid html tags\n */\ntype HtmlTags = keyof React.JSX.IntrinsicElements;\n\ntype CustomWebComponentTag = `${string}-${string}`;\n\n/**\n * Return type of the provided props merged with the initial props\n * where the specified props are optional\n */\ntype AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<\n TBaseProps & { theme: YakTheme },\n TIn\n>;\n\n/**\n * The attrs function allows to add additional props in a function that receives\n * the current props as argument.\n */\ntype AttrsFunction<\n TBaseProps,\n TIn extends object,\n TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>,\n> = (p: Substitute<TBaseProps & { theme: YakTheme }, TIn>) => Partial<TOut>;\n\n/**\n * The attrs function allows to add additional props to a styled component.\n * The props can be specified as an object or as a function that receives the\n * current props as argument.\n */\ntype Attrs<\n TBaseProps,\n TIn extends object = {},\n TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>,\n> = Partial<TOut> | AttrsFunction<TBaseProps, TIn, TOut>;\n\n//\n// The `styled()` API without `styled.` syntax\n//\n// The API design is inspired by styled-components:\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/constructors/styled.tsx\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/models/StyledComponent.ts\n//\nconst StyledFactory = <\n T extends object = React.DOMAttributes<Element> &\n React.RefAttributes<Element>,\n>(\n Component: HtmlTags | React.FunctionComponent<T> | CustomWebComponentTag,\n) =>\n Object.assign(yakStyled(Component), {\n attrs: <\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n >(\n attrs: Attrs<T, TAttrsIn, TAttrsOut>,\n ) => yakStyled<T, TAttrsIn, TAttrsOut>(Component, attrs),\n });\n\n/**\n * A yak component has a special symbol attached to it that allows to\n * target the component from a child component and to correctly handle the attrs function (if any).\n * e.g. styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`\n */\ntype YakComponent<\n T,\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n> = React.FunctionComponent<T> & {\n [yakComponentSymbol]: [\n React.FunctionComponent<T>,\n AttrsFunction<T, TAttrsIn, TAttrsOut>,\n ];\n};\n\nconst yakStyled = <\n T,\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n>(\n Component:\n | React.FunctionComponent<T>\n | YakComponent<T, TAttrsIn, TAttrsOut>\n | HtmlTags\n | string,\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n) => {\n const isYakComponent =\n typeof Component !== \"string\" && yakComponentSymbol in Component;\n\n // if the component that is wrapped is a yak component, we can extract it to render the underlying component directly\n // and we can also extract the attrs function to merge it with the current attrs function so that the sequence of\n // the attrs functions is preserved\n const [parentYakComponent, parentAttrsFn] = isYakComponent\n ? Component[yakComponentSymbol]\n : [];\n\n const mergedAttrsFn = buildRuntimeAttrsProcessor(attrs, parentAttrsFn);\n\n return <TCSSProps extends object = {}>(\n styles: TemplateStringsArray,\n ...values: Array<\n CSSInterpolation<T & NoInfer<TCSSProps> & { theme: YakTheme }>\n >\n ) => {\n const getRuntimeStyles = css<object>(styles, ...(values as any));\n const yak = (props: Substitute<TCSSProps & T, TAttrsIn>) => {\n // if the css component does not require arguments\n // it can be called without arguments and we skip calling useTheme()\n //\n // `attrsFn || getRuntimeStyles.length` is NOT against the rule of hooks as\n // getRuntimeStyles and attrsFn are constants defined outside of the component\n //\n // for example\n //\n // const Button = styled.button`color: red;`\n // ^ does not need to have access to theme, so we skip calling useTheme()\n //\n // const Button = styled.button`${({ theme }) => css`color: ${theme.color};`}`\n // ^ must be have access to theme, so we call useTheme()\n const theme =\n mergedAttrsFn || getRuntimeStyles.length ? useTheme() : noTheme;\n\n // The first components which is not wrapped in a yak component will execute all attrs functions\n // starting from the innermost yak component to the outermost yak component (itself)\n const combinedProps =\n \"$__attrs\" in props\n ? {\n theme,\n ...props,\n }\n : // overwrite and merge the current props with the processed attrs\n combineProps(\n {\n theme,\n ...(props as {\n className?: string;\n style?: React.CSSProperties;\n }),\n // mark the props as processed\n $__attrs: true,\n },\n mergedAttrsFn?.({ theme, ...props } as Substitute<\n T & { theme: YakTheme },\n TAttrsIn\n >),\n );\n // execute all functions inside the style literal\n // e.g. styled.button`color: ${props => props.color};`\n const runtimeStyles = getRuntimeStyles(combinedProps as T & TCSSProps);\n\n // delete the yak theme from the props\n // this must happen after the runtimeStyles are calculated\n // prevents passing the theme prop to the DOM element of a styled component\n const { theme: themeAfterAttr, ...combinedPropsWithoutTheme } =\n combinedProps;\n const propsBeforeFiltering =\n themeAfterAttr === theme ? combinedPropsWithoutTheme : combinedProps;\n\n // remove all props that start with a $ sign for string components e.g. \"button\" or \"div\"\n // so that they are not passed to the DOM element\n const filteredProps = (\n !isYakComponent\n ? removeNonDomProperties(propsBeforeFiltering)\n : propsBeforeFiltering\n ) as T & {\n className?: string;\n style?: React.CSSProperties;\n };\n\n filteredProps.className = mergeClassNames(\n filteredProps.className,\n runtimeStyles.className,\n );\n filteredProps.style =\n \"style\" in filteredProps\n ? {\n ...filteredProps.style,\n ...runtimeStyles.style,\n }\n : runtimeStyles.style;\n\n return parentYakComponent ? (\n // if the styled(Component) syntax is used and the component is a yak component\n // we can call the yak function directly without running through react createElement\n parentYakComponent(filteredProps)\n ) : (\n // if the final component is a string component e.g. styled(\"div\") or a custom non yak fn e.g. styled(MyComponent)\n <Component {...filteredProps} />\n );\n };\n\n // Assign the yakComponentSymbol directly without forwardRef\n return Object.assign(yak, {\n [yakComponentSymbol]: [yak, mergedAttrsFn],\n }) as YakComponent<\n Substitute<TCSSProps & T, TAttrsIn>,\n object,\n AttrsMerged<Substitute<TCSSProps & T, TAttrsIn>, object>\n >;\n };\n};\n\n/**\n * Type for the proxy object returned by `styled` that allows to\n * access all html tags as properties.\n */\ntype StyledLiteral<T> = <TCSSProps>(\n styles: TemplateStringsArray,\n ...values: Array<\n CSSInterpolation<\n T &\n // don't allow inference from types in the tagged template literal\n // additional benefit is that destruction is now typed and provides hints\n NoInfer<TCSSProps> & { theme: YakTheme }\n >\n >\n) => YakComponent<TCSSProps & T>;\n\n/**\n * The `styled` method works perfectly on all of your own or any third-party component,\n * as long as they attach the passed className prop to a DOM element.\n *\n * @usage\n *\n * ```tsx\n * const StyledLink = styled(Link)`\n * color: #BF4F74;\n * font-weight: bold;\n * `;\n * ```\n */\nexport const styled =\n // this type is wrong - but it will work correctly with compiled code\n StyledFactory as typeof StyledFactory & {\n [Tag in HtmlTags]: StyledLiteral<React.JSX.IntrinsicElements[Tag]> & {\n attrs: <\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<\n React.JSX.IntrinsicElements[Tag],\n TAttrsIn\n > = AttrsMerged<React.JSX.IntrinsicElements[Tag], TAttrsIn>,\n >(\n attrs: Attrs<React.JSX.IntrinsicElements[Tag], TAttrsIn, TAttrsOut>,\n ) => StyledLiteral<\n Substitute<React.JSX.IntrinsicElements[Tag], TAttrsIn>\n >;\n };\n };\n\n/**\n * Remove all entries that start with a $ sign\n *\n * This allows to have props that are used for internal stylingen purposes\n * but are not be passed to the DOM element\n */\nconst removeNonDomProperties = <T extends Record<string, unknown>>(\n obj: T,\n): T => {\n const result = {} as T;\n for (const key in obj) {\n if (!key.startsWith(\"$\") && obj[key] !== undefined) {\n result[key] = obj[key];\n }\n }\n return result;\n};\n\n// util function to merge class names, as they are concatenated with a space\nconst mergeClassNames = (a?: string, b?: string) => {\n if (!a && !b) return undefined;\n if (!a) return b;\n if (!b) return a;\n return a + \" \" + b;\n};\n\n/**\n * merge props and processed props (including class names and styles)\n * e.g.:\\\n * `{ className: \"a\", foo: 1 }` and `{ className: \"b\", bar: 2 }` \\\n * => `{ className: \"a b\", foo: 1, bar: 2 }`\n */\nconst combineProps = <\n T extends {\n className?: string;\n style?: React.CSSProperties;\n },\n TOther extends\n | {\n className?: string;\n style?: React.CSSProperties;\n }\n | null\n | undefined,\n>(\n props: T,\n newProps: TOther,\n) =>\n newProps\n ? (props.className === newProps.className || !newProps.className) &&\n (props.style === newProps.style || !newProps.style)\n ? // shortcut if no style and class merging is necessary\n {\n ...props,\n ...newProps,\n }\n : // merge class names and styles\n {\n ...props,\n ...newProps,\n className: mergeClassNames(props.className, newProps.className),\n style: { ...(props.style || {}), ...(newProps.style || {}) },\n }\n : // if no new props are provided, no merging is necessary\n props;\n\n// util type to remove properties from an object\ntype FastOmit<T extends object, U extends string | number | symbol> = {\n [K in keyof T as K extends U ? never : K]: T[K];\n};\n\n// util type to merge two objects\n// if a property is present in both objects the property from B is used\nexport type Substitute<A extends object, B extends object> = FastOmit<\n A,\n keyof B\n> &\n B;\n\n/**\n * Merges the attrs function of the current component with the attrs function of the parent component\n * in order to preserve the sequence of the attrs functions.\n * Note: In theory, the parentAttrsFn can have different types for TAttrsIn and TAttrsOut\n * but as this is only used internally, we can ignore and simplify this case\n * @param attrs The attrs object or function of the current component (if any)\n * @param parentAttrsFn The attrs function of the parent/wrapped component (if any)\n * @returns A function that receives the props and returns the transformed props\n */\nconst buildRuntimeAttrsProcessor = <\n T,\n TAttrsIn extends object,\n TAttrsOut extends AttrsMerged<T, TAttrsIn>,\n>(\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n parentAttrsFn?: AttrsFunction<T, TAttrsIn, TAttrsOut>,\n): AttrsFunction<T, TAttrsIn, TAttrsOut> | undefined => {\n const ownAttrsFn =\n attrs && (typeof attrs === \"function\" ? attrs : () => attrs);\n\n if (ownAttrsFn && parentAttrsFn) {\n return (props) => {\n const parentProps = parentAttrsFn(props);\n\n // overwrite and merge the parent props with the props received from the attrs function\n // after they went through the parent attrs function.\n //\n // This makes sure the linearity of the attrs functions is preserved and all attrs function receive\n // the whole props object calculated from the previous attrs functions\n return combineProps(\n parentProps,\n ownAttrsFn(combineProps(props, parentProps)),\n );\n };\n }\n\n return ownAttrsFn || parentAttrsFn;\n};\n","import React from \"react\";\nimport { styled as StyledFactory } from \"../styled.js\";\n\nexport const styled = new Proxy(StyledFactory, {\n get(target, TagName: keyof React.JSX.IntrinsicElements) {\n return target(TagName);\n },\n}) as typeof StyledFactory;\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mDAAAE,EAAA,QAAAC,EAAA,cAAAC,EAAA,WAAAC,EAAA,yCAAAC,EAAAN,GA0BA,IAAAO,EAA2C,4BCZpC,IAAMC,EAAQ,IAAIA,IAAoB,CAC3C,IAAMC,EAAYD,EAAM,KAAK,GAAG,EAChC,MAAO,KAAO,CAAE,UAAAC,CAAU,EAC5B,ECDO,IAAMC,EAA0B,CACrCC,KACGC,IACA,CACH,IAAMC,EAA4C,CAAC,EACnD,QAAWC,KAAOF,EAIZ,OAAOE,GAAQ,YACjBD,EAAoB,KAAKC,CAAoC,EAGjE,OAAID,EAAoB,SAAW,EAC1B,CACL,UAAW,GACX,MAAO,MACT,EAEOE,GAAmB,CAC1B,QAASC,EAAI,EAAGA,EAAIH,EAAoB,OAAQG,IAI9CC,EAAoCF,EAAOF,EAAoBG,CAAC,CAAC,EAEnE,MAAO,CACL,UAAW,GACX,MAAO,MACT,CACF,CACF,EAEA,SAASC,EACPF,EACAG,EACA,CACA,IAAIC,EAASD,EAAWH,CAAK,EAC7B,KAAO,OAAOI,GAAW,YACvBA,EAASA,EAAOJ,CAAK,EAEvB,OAAOI,CACT,CClCO,IAAMC,EAAsC,CAACC,KAAWC,IAGtD,GCzBF,IAAMC,EAAqB,OAAO,KAAK,EAuDvC,SAASC,KAAeC,EAA2C,CACxE,IAAMC,EAAuB,CAAC,EACxBC,EAA4C,CAAC,EAC7CC,EAAgC,CAAC,EACvC,QAAWC,KAAOJ,EAIhB,GAAI,OAAOI,GAAQ,SACjBH,EAAW,KAAKG,CAAG,UAKZ,OAAOA,GAAQ,WACtBF,EAAoB,KAAKE,CAAoC,UAKtD,OAAOA,GAAQ,UAAY,UAAWA,EAC7C,QAAWC,KAAOD,EAAI,MAAO,CAC3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N,CAAa,CAC3C,CAAC,CAKH,CACF,EA+BamB,EAEX3B,EAsBIwB,EACJI,GACM,CACN,IAAMC,EAAS,CAAC,EAChB,QAAWC,KAAOF,EACZ,CAACE,EAAI,WAAW,GAAG,GAAKF,EAAIE,CAAG,IAAM,SACvCD,EAAOC,CAAG,EAAIF,EAAIE,CAAG,GAGzB,OAAOD,CACT,EAGMJ,EAAkB,CAACM,EAAYC,IAAe,CAClD,GAAI,GAACD,GAAK,CAACC,GACX,OAAKD,EACAC,EACED,EAAI,IAAMC,EADFD,EADAC,CAGjB,EAQMd,EAAe,CAanBH,EACAkB,IAEAA,GACKlB,EAAM,YAAckB,EAAS,WAAa,CAACA,EAAS,aACpDlB,EAAM,QAAUkB,EAAS,OAAS,CAACA,EAAS,OAE3C,CACE,GAAGlB,EACH,GAAGkB,CACL,EAEA,CACE,GAAGlB,EACH,GAAGkB,EACH,UAAWR,EAAgBV,EAAM,UAAWkB,EAAS,SAAS,EAC9D,MAAO,CAAE,GAAIlB,EAAM,OAAS,CAAC,EAAI,GAAIkB,EAAS,OAAS,CAAC,CAAG,CAC7D,EAEFlB,EAwBAN,EAA6B,CAKjCN,EACAI,IACsD,CACtD,IAAM2B,EACJ/B,IAAU,OAAOA,GAAU,WAAaA,EAAQ,IAAMA,GAExD,OAAI+B,GAAc3B,EACRQ,GAAU,CAChB,IAAMoB,EAAc5B,EAAcQ,CAAK,EAOvC,OAAOG,EACLiB,EACAD,EAAWhB,EAAaH,EAAOoB,CAAW,CAAC,CAC7C,CACF,EAGKD,GAAc3B,CACvB,EChYO,IAAM6B,EAAS,IAAI,MAAMA,EAAe,CAC7C,IAAIC,EAAQC,EAA4C,CACtD,OAAOD,EAAOC,CAAO,CACvB,CACF,CAAC","names":["index_exports","__export","atoms","css","keyframes","styled","__toCommonJS","import_context","atoms","className","css","styles","args","dynamicCssFunctions","arg","props","i","executeDynamicExpressionRecursively","expression","result","keyframes","styles","dynamic","yakComponentSymbol","css","args","classNames","dynamicCssFunctions","style","arg","key","value","props","recursivePropExecution","className","allClassNames","allStyles","unwrapProps","fn","result","import_react","import_context","noTheme","StyledFactory","Component","yakStyled","attrs","isYakComponent","yakComponentSymbol","parentYakComponent","parentAttrsFn","mergedAttrsFn","buildRuntimeAttrsProcessor","styles","values","getRuntimeStyles","css","yak","props","theme","combinedProps","combineProps","runtimeStyles","themeAfterAttr","combinedPropsWithoutTheme","propsBeforeFiltering","filteredProps","removeNonDomProperties","mergeClassNames","React","styled","obj","result","key","a","b","newProps","ownAttrsFn","parentProps","styled","target","TagName"]}
1
+ {"version":3,"sources":["../runtime/index.ts","../runtime/cssLiteral.tsx","../runtime/atoms.tsx","../runtime/mocks/cssLiteral.ts","../runtime/mocks/keyframes.ts","../runtime/styled.tsx","../runtime/mocks/styled.ts"],"sourcesContent":["/**\n * This file contains the typings for the public API for next-yak and testing mocks\n *\n * IMPORTANT: In production builds, imports to this file should be replaced by the Babel plugin.\n * If you're seeing this code in a production environment, your build process may not be configured correctly.\n *\n * Purpose:\n * 1. Provide a test-friendly version of the next-yak API\n * 2. Offer type definitions for the public API\n *\n * Usage in tests:\n * - Import from \"next-yak\" as usual in your test files\n * - These mock implementations will be used instead of the actual runtime\n *\n * Warning for production:\n * - If these exports are used in a production build, styles will not be applied correctly\n * - Ensure your build process is configured to use the next-yak Babel plugin\n *\n * For maintainers:\n * - Keep this API surface in sync with the actual implementation in next-yak/internal\n * - Ensure mock implementations here are suitable for testing purposes\n */\n\n// the following export is not relative as \"next-yak/context\"\n// links to one file for react server components and\n// to another file for classic react components\nexport { useTheme, YakThemeProvider } from \"next-yak/context\";\nexport type { YakTheme } from \"./context/index.d.ts\";\n\nexport type { GenericYakComponentOf } from \"./publicStyledApi.ts\";\n\nexport { atoms } from \"./atoms.js\";\nexport { css } from \"./mocks/cssLiteral.js\";\nexport { keyframes } from \"./mocks/keyframes.js\";\nexport { styled } from \"./mocks/styled.js\";\n","import type { YakTheme } from \"./index.d.ts\";\nimport { RuntimeStyleProcessor } from \"./publicStyledApi.js\";\n\nexport const yakComponentSymbol = Symbol(\"yak\");\n\nexport type ComponentStyles<TProps> = (props: TProps) => {\n className: string;\n style?: {\n [key: string]: string;\n };\n};\n\nexport type CSSInterpolation<TProps> =\n | string\n | number\n | undefined\n | null\n | false\n | ComponentStyles<TProps>\n | {\n // type only identifier to allow targeting components\n // e.g. styled.svg`${Button}:hover & { fill: red; }`\n [yakComponentSymbol]: any;\n }\n | ((props: TProps) => CSSInterpolation<TProps>);\n\ntype CSSStyles<TProps = {}> = {\n style: { [key: string]: string | ((props: TProps) => string) };\n};\n\ntype CSSFunction = <TProps = {}>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<TProps & { theme: YakTheme }>[]\n) => ComponentStyles<TProps>;\n\nexport type NestedRuntimeStyleProcessor = (\n props: unknown,\n classNames: Set<string>,\n style: React.CSSProperties,\n) =>\n | {\n className?: string;\n style?: React.CSSProperties;\n }\n | void\n | NestedRuntimeStyleProcessor;\n\n/**\n * css() runtime factory of css``\n *\n * /!\\ next-yak transpiles css`` and styled``\n *\n * This changes the typings of the css`` and styled`` functions.\n * During development the user of next-yak wants to work with the\n * typings BEFORE compilation.\n *\n * Therefore this is only an internal function only and it must be cast to any\n * before exported to the user.\n *\n * The internal functioning of css`` is to return a single callback function that runs all functions\n * (or creates new ones if needed) that are passed as arguments. These functions receive the props, classNames, and style object as arguments\n * and operate directly on the classNames and style objects.\n */\nexport function css<TProps>(\n styles: TemplateStringsArray,\n ...values: CSSInterpolation<NoInfer<TProps> & { theme: YakTheme }>[]\n): ComponentStyles<TProps>;\nexport function css<TProps>(\n ...args: Array<any>\n): RuntimeStyleProcessor<TProps> {\n // Normally this could be an array of strings passed, but as we transpile the usage of css`` ourselves, we control the arguments\n // and ensure that only the first argument is a string (class name of the non-dynamic styles)\n let className: string | undefined;\n const dynamicCssFunctions: NestedRuntimeStyleProcessor[] = [];\n const style: Record<string, string> = {};\n for (const arg of args as Array<string | CSSFunction | CSSStyles<any>>) {\n // A CSS-module class name which got auto generated during build from static css\n // e.g. css`color: red;`\n // compiled -> css(\"yak31e4\")\n if (typeof arg === \"string\") {\n className = arg;\n }\n // Dynamic CSS e.g.\n // css`${props => props.active && css`color: red;`}`\n // compiled -> css((props: { active: boolean }) => props.active && css(\"yak31e4\"))\n else if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg as unknown as NestedRuntimeStyleProcessor);\n }\n // Dynamic CSS with css variables e.g.\n // css`transform: translate(${props => props.x}, ${props => props.y});`\n // compiled -> css(\"yak31e4\", { style: { \"--yakVarX\": props => props.x }, \"--yakVarY\": props => props.y }})\n else if (typeof arg === \"object\" && \"style\" in arg) {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n dynamicCssFunctions.push((props: unknown) => ({\n style: {\n [key]: String(\n // The value for a css value can be a theme dependent function e.g.:\n // const borderColor = (props: { theme: { mode: \"dark\" | \"light\" } }) => props.theme === \"dark\" ? \"black\" : \"white\";\n // css`border-color: ${borderColor};`\n // Therefore the value has to be extracted recursively\n recursivePropExecution(props, value),\n ),\n },\n }));\n } else {\n style[key] = value;\n }\n }\n }\n }\n\n // Non Dynamic CSS\n // This is just an optimization for the common case where there are no dynamic css functions\n if (dynamicCssFunctions.length === 0) {\n return (_, classNames) => {\n if (className) {\n classNames.add(className);\n }\n return () => {};\n };\n }\n\n return (props, classNames, allStyles) => {\n if (className) {\n classNames.add(className);\n }\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n unwrapProps(props, dynamicCssFunctions[i], classNames, allStyles);\n }\n };\n}\n\n// Dynamic CSS with runtime logic\nconst unwrapProps = (\n props: unknown,\n fn: NestedRuntimeStyleProcessor,\n classNames: Set<string>,\n style: React.CSSProperties,\n) => {\n let result = fn(props, classNames, style);\n while (result) {\n if (typeof result === \"function\") {\n result = result(props, classNames, style);\n continue;\n } else if (typeof result === \"object\") {\n if (\"className\" in result && result.className) {\n classNames.add(result.className);\n }\n if (\"style\" in result && result.style) {\n for (const key in result.style) {\n // This is hard for typescript to infer\n style[key as keyof React.CSSProperties] = result.style[\n key as keyof React.CSSProperties\n ] as any;\n }\n }\n }\n break;\n }\n};\n\nconst recursivePropExecution = (\n props: unknown,\n fn: (props: unknown) => any,\n): string | number => {\n const result = fn(props);\n if (typeof result === \"function\") {\n return recursivePropExecution(props, result);\n }\n if (process.env.NODE_ENV === \"development\") {\n if (\n typeof result !== \"string\" &&\n typeof result !== \"number\" &&\n !(result instanceof String)\n ) {\n throw new Error(\n `Dynamic CSS functions must return a string or number but returned ${JSON.stringify(\n result,\n )}\\n\\nDynamic CSS function: ${fn.toString()}\\n`,\n );\n }\n }\n return result;\n};\n","import { ComponentStyles, css } from \"./cssLiteral.js\";\nimport { RuntimeStyleProcessor as RuntimeStyleProcessor } from \"./publicStyledApi.js\";\n\n/**\n * Allows to use atomic CSS classes in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, atoms } from \"next-yak\";\n *\n * const Button = styled.button<{ $primary?: boolean }>`\n * ${atoms(\"text-teal-600\", \"text-base\", \"rounded-md\")}\n * ${props => props.$primary && atoms(\"shadow-md\")}\n * `;\n * ```\n */\nexport const atoms = <T,>(\n ...atoms: (string | RuntimeStyleProcessor<T> | false)[]\n): ComponentStyles<T> => {\n const staticClasses: string[] = [];\n const dynamicFunctions: RuntimeStyleProcessor<T>[] = [];\n\n for (const atom of atoms) {\n if (typeof atom === \"string\") {\n staticClasses.push(...atom.split(\" \"));\n } else if (typeof atom === \"function\") {\n dynamicFunctions.push(atom);\n }\n }\n\n const runtimeFunctions: RuntimeStyleProcessor<T>[] =\n staticClasses.length > 0\n ? [\n (_, classNames) => {\n staticClasses.forEach((cls) => classNames.add(cls));\n },\n ...dynamicFunctions,\n ]\n : dynamicFunctions;\n\n // @ts-expect-error the internal implementation of css is not typed\n return css(...runtimeFunctions);\n};\n","import type {\n css as cssInternal,\n NestedRuntimeStyleProcessor,\n} from \"../cssLiteral.js\";\n\nexport type { ComponentStyles, CSSInterpolation } from \"../cssLiteral.js\";\n\n/**\n * Allows to use CSS styles in a styled or css block\n *\n * e.g.\n *\n * ```tsx\n * const Component = styled.div`\n * color: black;\n * ${({$active}) => $active && css`color: red;`}\n * `;\n * ```\n */\nexport const css: typeof cssInternal = (\n styles: TemplateStringsArray,\n ...args: unknown[]\n) => {\n const dynamicCssFunctions: NestedRuntimeStyleProcessor[] = [];\n for (const arg of args as Array<string | Function | object>) {\n // Dynamic CSS e.g.\n // css`${props => props.active && css`color: red;`}`\n // compiled -> css((props: { active: boolean }) => props.active && css(\"yak31e4\"))\n if (typeof arg === \"function\") {\n dynamicCssFunctions.push(arg as unknown as NestedRuntimeStyleProcessor);\n }\n }\n if (dynamicCssFunctions.length === 0) {\n return {\n className: \"\",\n style: undefined,\n };\n }\n return ((props: unknown) => {\n for (let i = 0; i < dynamicCssFunctions.length; i++) {\n // run the dynamic expressions and ignore the return value\n // the execution is important to ensure that the user code is executed\n // the same way as in the real runtime\n executeDynamicExpressionRecursively(props, dynamicCssFunctions[i]);\n }\n return {\n className: \"\",\n style: undefined,\n };\n }) as any;\n};\n\nfunction executeDynamicExpressionRecursively(\n props: unknown,\n expression: NestedRuntimeStyleProcessor,\n) {\n const classNames = new Set<string>();\n const style = {};\n let result = expression(props, classNames, style);\n while (typeof result === \"function\") {\n result = result(props, classNames, style);\n }\n return result;\n}\n","import type { keyframes as keyframesInternal } from \"../keyframes.js\";\n\n/**\n * Allows to use CSS keyframe animations in a styled or css block\n *\n * @usage\n *\n * ```tsx\n * import { styled, keyframes } from \"next-yak\";\n *\n * const rotate = keyframes`\n * from {\n * transform: rotate(0deg);\n * }\n * to {\n * transform: rotate(360deg);\n * }\n * `;\n *\n * const Spinner = styled.div`\n * animation: ${rotate} 1s linear infinite;\n * `;\n * ```\n */\nexport const keyframes: typeof keyframesInternal = (styles, ...dynamic) => {\n // the keyframes function is a no-op in the mock\n // as it has no dynamic runtime behavior but only css\n return \"\";\n};\n","import { css, CSSInterpolation, yakComponentSymbol } from \"./cssLiteral.js\";\nimport React from \"react\";\nimport type {\n Attrs,\n AttrsMerged,\n Styled,\n YakComponent,\n AttrsFunction,\n StyledFn,\n HtmlTags,\n Substitute,\n StyledLiteral,\n RuntimeStyleProcessor,\n} from \"./publicStyledApi.js\";\n\n// the following export is not relative as \"next-yak/context\"\n// links to one file for react server components and\n// to another file for classic react components\nimport { useTheme } from \"next-yak/context\";\nimport type { YakTheme } from \"./context/index.d.ts\";\n\n/**\n * This Symbol is a fake theme which was used instead of the real one from the context\n * to speed up rendering\n */\nconst noTheme: YakTheme = {};\n\n//\n// The `styled()` API without `styled.` syntax\n//\n// The API design is inspired by styled-components:\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/constructors/styled.tsx\n// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/models/StyledComponent.ts\n//\nconst styledFactory: StyledFn = (Component) =>\n Object.assign(yakStyled(Component), {\n attrs: (attrs: Attrs<any>) => yakStyled(Component, attrs),\n });\n\n/**\n * The `styled` method works perfectly on all of your own or any third-party component,\n * as long as they attach the passed className prop to a DOM element.\n *\n * @usage\n *\n * ```tsx\n * const StyledLink = styled(Link)`\n * color: #BF4F74;\n * font-weight: bold;\n * `;\n * ```\n */\nexport const styled = styledFactory as Styled;\n\nconst yakStyled: StyledInternal = (Component, attrs) => {\n const isYakComponent =\n typeof Component !== \"string\" && yakComponentSymbol in Component;\n\n // if the component that is wrapped is a yak component, we can extract it to render the underlying component directly\n // and we can also extract the attrs function and the dynamic style function to merge it with the current attrs function (or dynamic style function)\n // so that the sequence of the attrs functions is preserved\n const [parentYakComponent, parentAttrsFn, parentRuntimeStylesFn] =\n isYakComponent\n ? (Component[yakComponentSymbol] as [\n YakComponent<unknown>,\n ExtractAttrsFunction<typeof attrs>,\n RuntimeStyleProcessor<unknown>,\n ])\n : [];\n\n const mergedAttrsFn = buildRuntimeAttrsProcessor(attrs, parentAttrsFn);\n\n return (styles, ...values) => {\n // combine all interpolated logic into a single function\n // e.g. styled.button`color: ${props => props.color}; margin: ${props => props.margin};`\n const runtimeStylesFn = css(\n styles,\n ...(values as CSSInterpolation<unknown>[]),\n ) as RuntimeStyleProcessor<unknown>;\n const runtimeStyleProcessor = buildRuntimeStylesProcessor(\n runtimeStylesFn,\n parentRuntimeStylesFn,\n );\n const yak: React.FunctionComponent = (props) => {\n // if the css component does not require arguments\n // it can be called without arguments and we skip calling useTheme()\n //\n // `attrsFn || getRuntimeStyles.length` is NOT against the rule of hooks as\n // getRuntimeStyles and attrsFn are constants defined outside of the component\n //\n // for example\n //\n // const Button = styled.button`color: red;`\n // ^ does not need to have access to theme, so we skip calling useTheme()\n //\n // const Button = styled.button`${({ theme }) => css`color: ${theme.color};`}`\n // ^ must be have access to theme, so we call useTheme()\n const theme =\n mergedAttrsFn || runtimeStylesFn.length ? useTheme() : noTheme;\n\n // The first components which is not wrapped in a yak component will execute all attrs functions\n // starting from the innermost yak component to the outermost yak component (itself)\n const combinedProps =\n \"$__attrs\" in props\n ? ({\n theme,\n ...props,\n } as {\n theme: YakTheme;\n className?: string;\n style?: React.CSSProperties;\n })\n : // overwrite and merge the current props with the processed attrs\n combineProps(\n {\n theme,\n ...(props as {\n className?: string;\n style?: React.CSSProperties;\n }),\n // mark the props as processed\n $__attrs: true,\n },\n mergedAttrsFn?.({ theme, ...(props as any) }),\n );\n\n const classNames = new Set<string>(\n \"className\" in combinedProps ? combinedProps.className?.split(\" \") : [],\n );\n const styles = {\n ...(\"style\" in combinedProps ? combinedProps.style : {}),\n };\n\n // execute all functions inside the style literal if not already executed\n // e.g. styled.button`color: ${props => props.color};`\n if (!(\"$__runtimeStylesProcessed\" in combinedProps)) {\n runtimeStyleProcessor(combinedProps, classNames, styles);\n // @ts-expect-error this is not typed correctly\n combinedProps.$__runtimeStylesProcessed = true;\n }\n\n combinedProps.className = Array.from(classNames).join(\" \") || undefined;\n combinedProps.style = styles;\n\n // delete the yak theme from the props\n // this must happen after the runtimeStyles are calculated\n // prevents passing the theme prop to the DOM element of a styled component\n const { theme: themeAfterAttr, ...combinedPropsWithoutTheme } =\n combinedProps;\n const propsBeforeFiltering =\n themeAfterAttr === theme ? combinedPropsWithoutTheme : combinedProps;\n\n // remove all props that start with a $ sign for string components e.g. \"button\" or \"div\"\n // so that they are not passed to the DOM element\n const filteredProps = !isYakComponent\n ? removeNonDomProperties(propsBeforeFiltering)\n : propsBeforeFiltering;\n\n return parentYakComponent ? (\n // if the styled(Component) syntax is used and the component is a yak component\n // we can call the yak function directly without running through react createElement\n parentYakComponent(filteredProps)\n ) : (\n // if the final component is a string component e.g. styled(\"div\") or a custom non yak fn e.g. styled(MyComponent)\n <Component\n {...(filteredProps as React.ComponentProps<\n Exclude<typeof Component, string>\n >)}\n />\n );\n };\n\n // Assign the yakComponentSymbol directly without forwardRef\n return Object.assign(yak, {\n [yakComponentSymbol]: [yak, mergedAttrsFn, runtimeStyleProcessor] as [\n unknown,\n unknown,\n unknown,\n ],\n });\n };\n};\n\n/**\n * Remove all entries that start with a $ sign\n *\n * This allows to have props that are used for internal stylingen purposes\n * but are not be passed to the DOM element\n */\nconst removeNonDomProperties = <T extends Record<string, unknown>>(\n obj: T,\n): T => {\n const result = {} as T;\n for (const key in obj) {\n if (!key.startsWith(\"$\") && obj[key] !== undefined) {\n result[key] = obj[key];\n }\n }\n return result;\n};\n\n// util function to merge class names, as they are concatenated with a space\nconst mergeClassNames = (a?: string, b?: string) => {\n if (!a && !b) return undefined;\n if (!a) return b;\n if (!b) return a;\n return a + \" \" + b;\n};\n\n/**\n * merge props and processed props (including class names and styles)\n * e.g.:\\\n * `{ className: \"a\", foo: 1 }` and `{ className: \"b\", bar: 2 }` \\\n * => `{ className: \"a b\", foo: 1, bar: 2 }`\n */\nconst combineProps = <\n T extends {\n className?: string;\n style?: React.CSSProperties;\n },\n TOther extends\n | {\n className?: string;\n style?: React.CSSProperties;\n }\n | null\n | undefined,\n>(\n props: T,\n newProps: TOther,\n) =>\n newProps\n ? (props.className === newProps.className || !newProps.className) &&\n (props.style === newProps.style || !newProps.style)\n ? // shortcut if no style and class merging is necessary\n {\n ...props,\n ...newProps,\n }\n : // merge class names and styles\n {\n ...props,\n ...newProps,\n className: mergeClassNames(props.className, newProps.className),\n style: { ...(props.style || {}), ...(newProps.style || {}) },\n }\n : // if no new props are provided, no merging is necessary\n props;\n\n/**\n * Merges the attrs function of the current component with the attrs function of the parent component\n * in order to preserve the sequence of the attrs functions.\n * Note: In theory, the parentAttrsFn can have different types for TAttrsIn and TAttrsOut\n * but as this is only used internally, we can ignore and simplify this case\n * @param attrs The attrs object or function of the current component (if any)\n * @param parentAttrsFn The attrs function of the parent/wrapped component (if any)\n * @returns A function that receives the props and returns the transformed props\n */\nconst buildRuntimeAttrsProcessor = <\n T,\n TAttrsIn extends object,\n TAttrsOut extends AttrsMerged<T, TAttrsIn>,\n>(\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n parentAttrsFn?: AttrsFunction<T, TAttrsIn, TAttrsOut>,\n): AttrsFunction<T, TAttrsIn, TAttrsOut> | undefined => {\n const ownAttrsFn =\n attrs && (typeof attrs === \"function\" ? attrs : () => attrs);\n\n if (ownAttrsFn && parentAttrsFn) {\n return (props) => {\n const parentProps = parentAttrsFn(props);\n\n // overwrite and merge the parent props with the props received from the attrs function\n // after they went through the parent attrs function.\n //\n // This makes sure the linearity of the attrs functions is preserved and all attrs function receive\n // the whole props object calculated from the previous attrs functions\n return combineProps(\n parentProps,\n ownAttrsFn(combineProps(props, parentProps)),\n );\n };\n }\n\n return ownAttrsFn || parentAttrsFn;\n};\n\n/**\n * Merges the runtime style function of the current component with the runtime style function of the parent component\n * in order to preserve the sequence of the attrs functions.\n * @param runtimeStylesFn The current runtime styles function\n * @param parentRuntimeStylesFn The parent runtime styles function\n * @returns The merged runtime styles function\n */\nconst buildRuntimeStylesProcessor = <T,>(\n runtimeStylesFn: RuntimeStyleProcessor<T>,\n parentRuntimeStylesFn?: RuntimeStyleProcessor<T>,\n) => {\n if (runtimeStylesFn && parentRuntimeStylesFn) {\n const combined: RuntimeStyleProcessor<T> = (props, classNames, style) => {\n parentRuntimeStylesFn(props, classNames, style);\n runtimeStylesFn(props, classNames, style);\n };\n return combined;\n }\n return runtimeStylesFn || parentRuntimeStylesFn;\n};\n\n/**\n * Internal function where attrs are passed to be processed\n */\nexport type StyledInternal = <\n T extends object,\n TAttrsIn extends object = {},\n TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,\n>(\n Component: React.FunctionComponent<T> | YakComponent<T> | HtmlTags | string,\n attrs?: Attrs<T, TAttrsIn, TAttrsOut>,\n) => StyledLiteral<Substitute<T, TAttrsIn>>;\n\n/**\n * Utility type to extract the AttrsFunction from the Attrs type\n */\nexport type ExtractAttrsFunction<T> = T extends (p: any) => any ? T : never;\n","import React from \"react\";\nimport { styled as StyledFactory } from \"../styled.js\";\n\nexport const styled = new Proxy(StyledFactory, {\n get(target, TagName: keyof React.JSX.IntrinsicElements) {\n return target(TagName);\n },\n}) as typeof StyledFactory;\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mDAAAE,EAAA,QAAAC,EAAA,cAAAC,EAAA,WAAAC,EAAA,yCAAAC,EAAAN,GA0BA,IAAAO,EAA2C,4BCvBpC,IAAMC,EAAqB,OAAO,KAAK,EAgEvC,SAASC,KACXC,EAC4B,CAG/B,IAAIC,EACEC,EAAqD,CAAC,EACtDC,EAAgC,CAAC,EACvC,QAAWC,KAAOJ,EAIhB,GAAI,OAAOI,GAAQ,SACjBH,EAAYG,UAKL,OAAOA,GAAQ,WACtBF,EAAoB,KAAKE,CAA6C,UAK/D,OAAOA,GAAQ,UAAY,UAAWA,EAC7C,QAAWC,KAAOD,EAAI,MAAO,CAC3B,IAAME,EAAQF,EAAI,MAAMC,CAAG,EACvB,OAAOC,GAAU,WACnBJ,EAAoB,KAAMK,IAAoB,CAC5C,MAAO,CACL,CAACF,CAAG,EAAG,OAKLG,EAAuBD,EAAOD,CAAK,CAC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CAClD,GAAI,GAACD,GAAK,CAACC,GACX,OAAKD,EACAC,EACED,EAAI,IAAMC,EADFD,EADAC,CAGjB,EAQMb,EAAe,CAanBH,EACAiB,IAEAA,GACKjB,EAAM,YAAciB,EAAS,WAAa,CAACA,EAAS,aACpDjB,EAAM,QAAUiB,EAAS,OAAS,CAACA,EAAS,OAE3C,CACE,GAAGjB,EACH,GAAGiB,CACL,EAEA,CACE,GAAGjB,EACH,GAAGiB,EACH,UAAWH,EAAgBd,EAAM,UAAWiB,EAAS,SAAS,EAC9D,MAAO,CAAE,GAAIjB,EAAM,OAAS,CAAC,EAAI,GAAIiB,EAAS,OAAS,CAAC,CAAG,CAC7D,EAEFjB,EAWAR,EAA6B,CAKjCR,EACAK,IACsD,CACtD,IAAM6B,EACJlC,IAAU,OAAOA,GAAU,WAAaA,EAAQ,IAAMA,GAExD,OAAIkC,GAAc7B,EACRW,GAAU,CAChB,IAAMmB,EAAc9B,EAAcW,CAAK,EAOvC,OAAOG,EACLgB,EACAD,EAAWf,EAAaH,EAAOmB,CAAW,CAAC,CAC7C,CACF,EAGKD,GAAc7B,CACvB,EASMS,EAA8B,CAClCH,EACAL,IAEIK,GAAmBL,EACsB,CAACU,EAAOI,EAAYgB,IAAU,CACvE9B,EAAsBU,EAAOI,EAAYgB,CAAK,EAC9CzB,EAAgBK,EAAOI,EAAYgB,CAAK,CAC1C,EAGKzB,GAAmBL,EC/SrB,IAAM+B,EAAS,IAAI,MAAMA,EAAe,CAC7C,IAAIC,EAAQC,EAA4C,CACtD,OAAOD,EAAOC,CAAO,CACvB,CACF,CAAC","names":["index_exports","__export","atoms","css","keyframes","styled","__toCommonJS","import_context","yakComponentSymbol","css","args","className","dynamicCssFunctions","style","arg","key","value","props","recursivePropExecution","_","classNames","allStyles","i","unwrapProps","fn","result","atoms","staticClasses","dynamicFunctions","atom","runtimeFunctions","_","classNames","cls","css","css","styles","args","dynamicCssFunctions","arg","props","i","executeDynamicExpressionRecursively","expression","classNames","style","result","keyframes","styles","dynamic","import_react","import_context","noTheme","styledFactory","Component","yakStyled","attrs","styled","isYakComponent","yakComponentSymbol","parentYakComponent","parentAttrsFn","parentRuntimeStylesFn","mergedAttrsFn","buildRuntimeAttrsProcessor","styles","values","runtimeStylesFn","css","runtimeStyleProcessor","buildRuntimeStylesProcessor","yak","props","theme","combinedProps","combineProps","classNames","themeAfterAttr","combinedPropsWithoutTheme","propsBeforeFiltering","filteredProps","removeNonDomProperties","React","obj","result","key","mergeClassNames","a","b","newProps","ownAttrsFn","parentProps","style","styled","target","TagName"]}
package/dist/index.d.cts CHANGED
@@ -18,24 +18,6 @@ declare const YakThemeProvider: ({ children, theme, }: {
18
18
  theme?: YakTheme;
19
19
  }) => React.JSX.Element;
20
20
 
21
- /**
22
- * Allows to use atomic CSS classes in a styled or css block
23
- *
24
- * @usage
25
- *
26
- * ```tsx
27
- * import { styled, atoms } from "next-yak";
28
- *
29
- * const Button = styled.button<{ $primary?: boolean }>`
30
- * ${atoms("text-teal-600", "text-base", "rounded-md")}
31
- * ${props => props.$primary && atoms("shadow-md")}
32
- * `;
33
- * ```
34
- */
35
- declare const atoms: (...atoms: string[]) => () => {
36
- className: string;
37
- };
38
-
39
21
  declare const yakComponentSymbol: unique symbol;
40
22
  type ComponentStyles<TProps> = (props: TProps) => {
41
23
  className: string;
@@ -57,11 +39,129 @@ type CSSInterpolation<TProps> = string | number | undefined | null | false | Com
57
39
  *
58
40
  * Therefore this is only an internal function only and it must be cast to any
59
41
  * before exported to the user.
42
+ *
43
+ * The internal functioning of css`` is to return a single callback function that runs all functions
44
+ * (or creates new ones if needed) that are passed as arguments. These functions receive the props, classNames, and style object as arguments
45
+ * and operate directly on the classNames and style objects.
60
46
  */
61
47
  declare function css$1<TProps>(styles: TemplateStringsArray, ...values: CSSInterpolation<NoInfer<TProps> & {
62
48
  theme: YakTheme;
63
49
  }>[]): ComponentStyles<TProps>;
64
50
 
51
+ /**
52
+ * Main styled interface that combines HTML tag mappings with the styled function.
53
+ * This is the primary entry point for creating styled components.
54
+ */
55
+ interface Styled extends MappedHtmlTags, StyledFn {
56
+ }
57
+ /**
58
+ * Function interface for creating styled components from any component or HTML tag.
59
+ * Supports React components, HTML tags, and custom web components.
60
+ */
61
+ interface StyledFn {
62
+ <TProps extends object = React.DOMAttributes<Element> & React.RefAttributes<Element>>(Component: HtmlTags | React.FunctionComponent<TProps> | CustomWebComponentTag): LiteralWithAttrs<TProps>;
63
+ }
64
+ /**
65
+ * A yak component with a special symbol that allows component targeting
66
+ * and proper attrs function handling.
67
+ * @example styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`
68
+ */
69
+ interface YakComponent<T> extends React.FunctionComponent<T> {
70
+ [yakComponentSymbol]: [unknown, unknown, unknown];
71
+ }
72
+ /**
73
+ * Styled component with attrs method for adding default props.
74
+ * Extends StyledLiteral with the ability to specify default attributes.
75
+ */
76
+ interface LiteralWithAttrs<T extends object> extends StyledLiteral<T> {
77
+ attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>>(attrs: Attrs<T, TAttrsIn, TAttrsOut>) => StyledLiteral<Substitute<T, TAttrsIn>>;
78
+ }
79
+ /**
80
+ * Template literal function for defining CSS styles with interpolation support.
81
+ * Accepts CSS template strings and interpolated values with proper typing.
82
+ */
83
+ interface StyledLiteral<T> {
84
+ <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
85
+ theme: YakTheme;
86
+ }>>): YakComponent<TCSSProps & T>;
87
+ }
88
+ /**
89
+ * Function variant of attrs that receives current props and returns additional props.
90
+ * Allows for dynamic prop generation based on component state.
91
+ */
92
+ interface AttrsFunction<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> {
93
+ (p: Substitute<TBaseProps & {
94
+ theme: YakTheme;
95
+ }, TIn>): Partial<TOut>;
96
+ }
97
+ /**
98
+ * Merges provided props with initial props, making specified props optional.
99
+ * Includes theme support for styled components.
100
+ */
101
+ type AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<TBaseProps & {
102
+ theme?: YakTheme;
103
+ }, TIn>;
104
+ /**
105
+ * Maps all HTML tag names to their corresponding styled component types with attributes support.
106
+ * Provides typed access to all standard HTML elements through the styled interface.
107
+ */
108
+ type MappedHtmlTags = {
109
+ [Tag in HtmlTags]: LiteralWithAttrs<React.JSX.IntrinsicElements[Tag]>;
110
+ };
111
+ /**
112
+ * The attrs function allows adding additional props to a styled component.
113
+ * Props can be specified as an object or as a function that receives current props.
114
+ */
115
+ type Attrs<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = Partial<TOut> | AttrsFunction<TBaseProps, TIn, TOut>;
116
+ /**
117
+ * Utility type to merge two object types, with properties from B taking precedence.
118
+ * If a property exists in both A and B, the property from B is used.
119
+ */
120
+ type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
121
+ /**
122
+ * Union type of all valid HTML element tag names.
123
+ * Derived from React's JSX intrinsic elements.
124
+ */
125
+ type HtmlTags = keyof React.JSX.IntrinsicElements;
126
+ /**
127
+ * Custom web component tag pattern that must contain at least one hyphen.
128
+ * Follows the web component naming convention.
129
+ */
130
+ type CustomWebComponentTag = `${string}-${string}`;
131
+ /**
132
+ * Utility type to efficiently remove properties from an object type.
133
+ * More performant than the built-in Omit type for large object types.
134
+ */
135
+ type FastOmit<T extends object, U extends string | number | symbol> = {
136
+ [K in keyof T as K extends U ? never : K]: T[K];
137
+ };
138
+ /**
139
+ * Type of all functions that can be passed to manipulate styles
140
+ */
141
+ type RuntimeStyleProcessor<T> = (props: T, classNames: Set<string>, style: React.CSSProperties) => void;
142
+ /**
143
+ * Utility type to keep the generic API of a component while still being able to use it in a selector
144
+ */
145
+ type GenericYakComponentOf<T, P = {}> = T & YakComponent<P> & {
146
+ <G = {}>(props: P & G): React.ReactElement | null;
147
+ };
148
+
149
+ /**
150
+ * Allows to use atomic CSS classes in a styled or css block
151
+ *
152
+ * @usage
153
+ *
154
+ * ```tsx
155
+ * import { styled, atoms } from "next-yak";
156
+ *
157
+ * const Button = styled.button<{ $primary?: boolean }>`
158
+ * ${atoms("text-teal-600", "text-base", "rounded-md")}
159
+ * ${props => props.$primary && atoms("shadow-md")}
160
+ * `;
161
+ * ```
162
+ */
163
+ declare const atoms: <T>(...atoms: (string | RuntimeStyleProcessor<T> | false)[]) => ComponentStyles<T>;
164
+
65
165
  /**
66
166
  * Allows to use CSS styles in a styled or css block
67
167
  *
@@ -124,56 +224,6 @@ declare const keyframes$1: <T extends (string | number | bigint)[] = never>(styl
124
224
  */
125
225
  declare const keyframes: typeof keyframes$1;
126
226
 
127
- /**
128
- * All valid html tags
129
- */
130
- type HtmlTags = keyof React.JSX.IntrinsicElements;
131
- type CustomWebComponentTag = `${string}-${string}`;
132
- /**
133
- * Return type of the provided props merged with the initial props
134
- * where the specified props are optional
135
- */
136
- type AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<TBaseProps & {
137
- theme: YakTheme;
138
- }, TIn>;
139
- /**
140
- * The attrs function allows to add additional props in a function that receives
141
- * the current props as argument.
142
- */
143
- type AttrsFunction<TBaseProps, TIn extends object, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = (p: Substitute<TBaseProps & {
144
- theme: YakTheme;
145
- }, TIn>) => Partial<TOut>;
146
- /**
147
- * The attrs function allows to add additional props to a styled component.
148
- * The props can be specified as an object or as a function that receives the
149
- * current props as argument.
150
- */
151
- type Attrs<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = Partial<TOut> | AttrsFunction<TBaseProps, TIn, TOut>;
152
- declare const StyledFactory: <T extends object = React.DOMAttributes<Element> & React.RefAttributes<Element>>(Component: HtmlTags | React.FunctionComponent<T> | CustomWebComponentTag) => (<TCSSProps extends object = {}>(styles: TemplateStringsArray, ...values: CSSInterpolation<T & NoInfer<TCSSProps> & {
153
- theme: YakTheme;
154
- }>[]) => YakComponent<FastOmit<TCSSProps & T, never>, object, AttrsMerged<FastOmit<TCSSProps & T, never>, object>>) & {
155
- attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>>(attrs: Attrs<T, TAttrsIn, TAttrsOut>) => <TCSSProps extends object = {}>(styles: TemplateStringsArray, ...values: CSSInterpolation<T & NoInfer<TCSSProps> & {
156
- theme: YakTheme;
157
- }>[]) => YakComponent<Substitute<TCSSProps & T, TAttrsIn>, object, AttrsMerged<Substitute<TCSSProps & T, TAttrsIn>, object>>;
158
- };
159
- /**
160
- * A yak component has a special symbol attached to it that allows to
161
- * target the component from a child component and to correctly handle the attrs function (if any).
162
- * e.g. styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`
163
- */
164
- type YakComponent<T, TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>> = React.FunctionComponent<T> & {
165
- [yakComponentSymbol]: [
166
- React.FunctionComponent<T>,
167
- AttrsFunction<T, TAttrsIn, TAttrsOut>
168
- ];
169
- };
170
- /**
171
- * Type for the proxy object returned by `styled` that allows to
172
- * access all html tags as properties.
173
- */
174
- type StyledLiteral<T> = <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
175
- theme: YakTheme;
176
- }>>) => YakComponent<TCSSProps & T>;
177
227
  /**
178
228
  * The `styled` method works perfectly on all of your own or any third-party component,
179
229
  * as long as they attach the passed className prop to a DOM element.
@@ -187,14 +237,8 @@ type StyledLiteral<T> = <TCSSProps>(styles: TemplateStringsArray, ...values: Arr
187
237
  * `;
188
238
  * ```
189
239
  */
190
- declare const styled$1: typeof StyledFactory & { [Tag in HtmlTags]: StyledLiteral<React.JSX.IntrinsicElements[Tag]> & {
191
- attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<React.JSX.IntrinsicElements[Tag], TAttrsIn> = AttrsMerged<React.JSX.IntrinsicElements[Tag], TAttrsIn>>(attrs: Attrs<React.JSX.IntrinsicElements[Tag], TAttrsIn, TAttrsOut>) => StyledLiteral<Substitute<React.JSX.IntrinsicElements[Tag], TAttrsIn>>;
192
- }; };
193
- type FastOmit<T extends object, U extends string | number | symbol> = {
194
- [K in keyof T as K extends U ? never : K]: T[K];
195
- };
196
- type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
240
+ declare const styled$1: Styled;
197
241
 
198
242
  declare const styled: typeof styled$1;
199
243
 
200
- export { type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };
244
+ export { type GenericYakComponentOf, type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };
package/dist/index.d.ts CHANGED
@@ -18,24 +18,6 @@ declare const YakThemeProvider: ({ children, theme, }: {
18
18
  theme?: YakTheme;
19
19
  }) => React.JSX.Element;
20
20
 
21
- /**
22
- * Allows to use atomic CSS classes in a styled or css block
23
- *
24
- * @usage
25
- *
26
- * ```tsx
27
- * import { styled, atoms } from "next-yak";
28
- *
29
- * const Button = styled.button<{ $primary?: boolean }>`
30
- * ${atoms("text-teal-600", "text-base", "rounded-md")}
31
- * ${props => props.$primary && atoms("shadow-md")}
32
- * `;
33
- * ```
34
- */
35
- declare const atoms: (...atoms: string[]) => () => {
36
- className: string;
37
- };
38
-
39
21
  declare const yakComponentSymbol: unique symbol;
40
22
  type ComponentStyles<TProps> = (props: TProps) => {
41
23
  className: string;
@@ -57,11 +39,129 @@ type CSSInterpolation<TProps> = string | number | undefined | null | false | Com
57
39
  *
58
40
  * Therefore this is only an internal function only and it must be cast to any
59
41
  * before exported to the user.
42
+ *
43
+ * The internal functioning of css`` is to return a single callback function that runs all functions
44
+ * (or creates new ones if needed) that are passed as arguments. These functions receive the props, classNames, and style object as arguments
45
+ * and operate directly on the classNames and style objects.
60
46
  */
61
47
  declare function css$1<TProps>(styles: TemplateStringsArray, ...values: CSSInterpolation<NoInfer<TProps> & {
62
48
  theme: YakTheme;
63
49
  }>[]): ComponentStyles<TProps>;
64
50
 
51
+ /**
52
+ * Main styled interface that combines HTML tag mappings with the styled function.
53
+ * This is the primary entry point for creating styled components.
54
+ */
55
+ interface Styled extends MappedHtmlTags, StyledFn {
56
+ }
57
+ /**
58
+ * Function interface for creating styled components from any component or HTML tag.
59
+ * Supports React components, HTML tags, and custom web components.
60
+ */
61
+ interface StyledFn {
62
+ <TProps extends object = React.DOMAttributes<Element> & React.RefAttributes<Element>>(Component: HtmlTags | React.FunctionComponent<TProps> | CustomWebComponentTag): LiteralWithAttrs<TProps>;
63
+ }
64
+ /**
65
+ * A yak component with a special symbol that allows component targeting
66
+ * and proper attrs function handling.
67
+ * @example styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`
68
+ */
69
+ interface YakComponent<T> extends React.FunctionComponent<T> {
70
+ [yakComponentSymbol]: [unknown, unknown, unknown];
71
+ }
72
+ /**
73
+ * Styled component with attrs method for adding default props.
74
+ * Extends StyledLiteral with the ability to specify default attributes.
75
+ */
76
+ interface LiteralWithAttrs<T extends object> extends StyledLiteral<T> {
77
+ attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>>(attrs: Attrs<T, TAttrsIn, TAttrsOut>) => StyledLiteral<Substitute<T, TAttrsIn>>;
78
+ }
79
+ /**
80
+ * Template literal function for defining CSS styles with interpolation support.
81
+ * Accepts CSS template strings and interpolated values with proper typing.
82
+ */
83
+ interface StyledLiteral<T> {
84
+ <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
85
+ theme: YakTheme;
86
+ }>>): YakComponent<TCSSProps & T>;
87
+ }
88
+ /**
89
+ * Function variant of attrs that receives current props and returns additional props.
90
+ * Allows for dynamic prop generation based on component state.
91
+ */
92
+ interface AttrsFunction<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> {
93
+ (p: Substitute<TBaseProps & {
94
+ theme: YakTheme;
95
+ }, TIn>): Partial<TOut>;
96
+ }
97
+ /**
98
+ * Merges provided props with initial props, making specified props optional.
99
+ * Includes theme support for styled components.
100
+ */
101
+ type AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<TBaseProps & {
102
+ theme?: YakTheme;
103
+ }, TIn>;
104
+ /**
105
+ * Maps all HTML tag names to their corresponding styled component types with attributes support.
106
+ * Provides typed access to all standard HTML elements through the styled interface.
107
+ */
108
+ type MappedHtmlTags = {
109
+ [Tag in HtmlTags]: LiteralWithAttrs<React.JSX.IntrinsicElements[Tag]>;
110
+ };
111
+ /**
112
+ * The attrs function allows adding additional props to a styled component.
113
+ * Props can be specified as an object or as a function that receives current props.
114
+ */
115
+ type Attrs<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = Partial<TOut> | AttrsFunction<TBaseProps, TIn, TOut>;
116
+ /**
117
+ * Utility type to merge two object types, with properties from B taking precedence.
118
+ * If a property exists in both A and B, the property from B is used.
119
+ */
120
+ type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
121
+ /**
122
+ * Union type of all valid HTML element tag names.
123
+ * Derived from React's JSX intrinsic elements.
124
+ */
125
+ type HtmlTags = keyof React.JSX.IntrinsicElements;
126
+ /**
127
+ * Custom web component tag pattern that must contain at least one hyphen.
128
+ * Follows the web component naming convention.
129
+ */
130
+ type CustomWebComponentTag = `${string}-${string}`;
131
+ /**
132
+ * Utility type to efficiently remove properties from an object type.
133
+ * More performant than the built-in Omit type for large object types.
134
+ */
135
+ type FastOmit<T extends object, U extends string | number | symbol> = {
136
+ [K in keyof T as K extends U ? never : K]: T[K];
137
+ };
138
+ /**
139
+ * Type of all functions that can be passed to manipulate styles
140
+ */
141
+ type RuntimeStyleProcessor<T> = (props: T, classNames: Set<string>, style: React.CSSProperties) => void;
142
+ /**
143
+ * Utility type to keep the generic API of a component while still being able to use it in a selector
144
+ */
145
+ type GenericYakComponentOf<T, P = {}> = T & YakComponent<P> & {
146
+ <G = {}>(props: P & G): React.ReactElement | null;
147
+ };
148
+
149
+ /**
150
+ * Allows to use atomic CSS classes in a styled or css block
151
+ *
152
+ * @usage
153
+ *
154
+ * ```tsx
155
+ * import { styled, atoms } from "next-yak";
156
+ *
157
+ * const Button = styled.button<{ $primary?: boolean }>`
158
+ * ${atoms("text-teal-600", "text-base", "rounded-md")}
159
+ * ${props => props.$primary && atoms("shadow-md")}
160
+ * `;
161
+ * ```
162
+ */
163
+ declare const atoms: <T>(...atoms: (string | RuntimeStyleProcessor<T> | false)[]) => ComponentStyles<T>;
164
+
65
165
  /**
66
166
  * Allows to use CSS styles in a styled or css block
67
167
  *
@@ -124,56 +224,6 @@ declare const keyframes$1: <T extends (string | number | bigint)[] = never>(styl
124
224
  */
125
225
  declare const keyframes: typeof keyframes$1;
126
226
 
127
- /**
128
- * All valid html tags
129
- */
130
- type HtmlTags = keyof React.JSX.IntrinsicElements;
131
- type CustomWebComponentTag = `${string}-${string}`;
132
- /**
133
- * Return type of the provided props merged with the initial props
134
- * where the specified props are optional
135
- */
136
- type AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<TBaseProps & {
137
- theme: YakTheme;
138
- }, TIn>;
139
- /**
140
- * The attrs function allows to add additional props in a function that receives
141
- * the current props as argument.
142
- */
143
- type AttrsFunction<TBaseProps, TIn extends object, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = (p: Substitute<TBaseProps & {
144
- theme: YakTheme;
145
- }, TIn>) => Partial<TOut>;
146
- /**
147
- * The attrs function allows to add additional props to a styled component.
148
- * The props can be specified as an object or as a function that receives the
149
- * current props as argument.
150
- */
151
- type Attrs<TBaseProps, TIn extends object = {}, TOut extends AttrsMerged<TBaseProps, TIn> = AttrsMerged<TBaseProps, TIn>> = Partial<TOut> | AttrsFunction<TBaseProps, TIn, TOut>;
152
- declare const StyledFactory: <T extends object = React.DOMAttributes<Element> & React.RefAttributes<Element>>(Component: HtmlTags | React.FunctionComponent<T> | CustomWebComponentTag) => (<TCSSProps extends object = {}>(styles: TemplateStringsArray, ...values: CSSInterpolation<T & NoInfer<TCSSProps> & {
153
- theme: YakTheme;
154
- }>[]) => YakComponent<FastOmit<TCSSProps & T, never>, object, AttrsMerged<FastOmit<TCSSProps & T, never>, object>>) & {
155
- attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>>(attrs: Attrs<T, TAttrsIn, TAttrsOut>) => <TCSSProps extends object = {}>(styles: TemplateStringsArray, ...values: CSSInterpolation<T & NoInfer<TCSSProps> & {
156
- theme: YakTheme;
157
- }>[]) => YakComponent<Substitute<TCSSProps & T, TAttrsIn>, object, AttrsMerged<Substitute<TCSSProps & T, TAttrsIn>, object>>;
158
- };
159
- /**
160
- * A yak component has a special symbol attached to it that allows to
161
- * target the component from a child component and to correctly handle the attrs function (if any).
162
- * e.g. styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`
163
- */
164
- type YakComponent<T, TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>> = React.FunctionComponent<T> & {
165
- [yakComponentSymbol]: [
166
- React.FunctionComponent<T>,
167
- AttrsFunction<T, TAttrsIn, TAttrsOut>
168
- ];
169
- };
170
- /**
171
- * Type for the proxy object returned by `styled` that allows to
172
- * access all html tags as properties.
173
- */
174
- type StyledLiteral<T> = <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
175
- theme: YakTheme;
176
- }>>) => YakComponent<TCSSProps & T>;
177
227
  /**
178
228
  * The `styled` method works perfectly on all of your own or any third-party component,
179
229
  * as long as they attach the passed className prop to a DOM element.
@@ -187,14 +237,8 @@ type StyledLiteral<T> = <TCSSProps>(styles: TemplateStringsArray, ...values: Arr
187
237
  * `;
188
238
  * ```
189
239
  */
190
- declare const styled$1: typeof StyledFactory & { [Tag in HtmlTags]: StyledLiteral<React.JSX.IntrinsicElements[Tag]> & {
191
- attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<React.JSX.IntrinsicElements[Tag], TAttrsIn> = AttrsMerged<React.JSX.IntrinsicElements[Tag], TAttrsIn>>(attrs: Attrs<React.JSX.IntrinsicElements[Tag], TAttrsIn, TAttrsOut>) => StyledLiteral<Substitute<React.JSX.IntrinsicElements[Tag], TAttrsIn>>;
192
- }; };
193
- type FastOmit<T extends object, U extends string | number | symbol> = {
194
- [K in keyof T as K extends U ? never : K]: T[K];
195
- };
196
- type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
240
+ declare const styled$1: Styled;
197
241
 
198
242
  declare const styled: typeof styled$1;
199
243
 
200
- export { type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };
244
+ export { type GenericYakComponentOf, type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };