next-yak 9.4.1 → 9.4.2

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.
Files changed (99) hide show
  1. package/README.md +57 -288
  2. package/dist/context/baseContext.cjs +6 -29
  3. package/dist/context/baseContext.cjs.map +1 -1
  4. package/dist/context/baseContext.d.cts +4 -2
  5. package/dist/context/baseContext.d.ts +4 -2
  6. package/dist/context/baseContext.js +5 -5
  7. package/dist/context/baseContext.js.map +1 -1
  8. package/dist/context/index.cjs +33 -41
  9. package/dist/context/index.cjs.map +1 -1
  10. package/dist/context/index.d.cts +12 -8
  11. package/dist/context/index.d.ts +12 -8
  12. package/dist/context/index.js +10 -13
  13. package/dist/context/index.js.map +1 -1
  14. package/dist/context/index.server.cjs +35 -41
  15. package/dist/context/index.server.cjs.map +1 -1
  16. package/dist/context/index.server.d.cts +13 -0
  17. package/dist/context/index.server.d.ts +13 -0
  18. package/dist/context/index.server.js +12 -14
  19. package/dist/context/index.server.js.map +1 -1
  20. package/dist/index.cjs +1 -4
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +52 -46
  23. package/dist/index.d.ts +52 -46
  24. package/dist/index.js +1 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.cjs +464 -697
  27. package/dist/internal.cjs.map +1 -1
  28. package/dist/internal.d.cts +368 -0
  29. package/dist/internal.d.ts +368 -0
  30. package/dist/internal.js +297 -532
  31. package/dist/internal.js.map +1 -1
  32. package/dist/isolated-source-eval/index.d.ts +22 -20
  33. package/dist/isolated-source-eval/index.js +284 -304
  34. package/dist/isolated-source-eval/index.js.map +1 -1
  35. package/dist/isolated-source-eval/worker.js +53 -57
  36. package/dist/isolated-source-eval/worker.js.map +1 -1
  37. package/dist/jsx-dev-runtime.cjs +1 -1
  38. package/dist/jsx-dev-runtime.cjs.map +1 -1
  39. package/dist/jsx-dev-runtime.d.cts +9 -0
  40. package/dist/jsx-dev-runtime.d.ts +9 -0
  41. package/dist/jsx-dev-runtime.js +1 -1
  42. package/dist/jsx-dev-runtime.js.map +1 -1
  43. package/dist/jsx-runtime.cjs +1 -1
  44. package/dist/jsx-runtime.cjs.map +1 -1
  45. package/dist/jsx-runtime.d.cts +25 -24
  46. package/dist/jsx-runtime.d.ts +25 -24
  47. package/dist/jsx-runtime.js +1 -1
  48. package/dist/jsx-runtime.js.map +1 -1
  49. package/dist/loaders/turbo-loader.cjs +695 -982
  50. package/dist/loaders/turbo-loader.cjs.map +1 -1
  51. package/dist/loaders/turbo-loader.d.cts +7 -6
  52. package/dist/loaders/vite-plugin.d.ts +15 -13
  53. package/dist/loaders/vite-plugin.js +736 -1056
  54. package/dist/loaders/vite-plugin.js.map +1 -1
  55. package/dist/loaders/webpack-loader.cjs +629 -905
  56. package/dist/loaders/webpack-loader.cjs.map +1 -1
  57. package/dist/loaders/webpack-loader.d.cts +5 -4
  58. package/dist/static/chunk-WfQuXRBF.js +1 -0
  59. package/dist/static/index.cjs +1 -1
  60. package/dist/static/index.cjs.map +1 -1
  61. package/dist/static/index.d.cts +6 -7
  62. package/dist/static/index.d.ts +6 -7
  63. package/dist/static/index.js +1 -1
  64. package/dist/static/index.js.map +1 -1
  65. package/dist/withYak/index.cjs +135 -162
  66. package/dist/withYak/index.cjs.map +1 -1
  67. package/dist/withYak/index.d.cts +42 -40
  68. package/dist/withYak/index.d.ts +42 -40
  69. package/dist/withYak/index.js +114 -134
  70. package/dist/withYak/index.js.map +1 -1
  71. package/loaders/lib/__tests__/debugLogger.test.ts +11 -43
  72. package/loaders/lib/debugLogger.ts +6 -12
  73. package/loaders/lib/extractCss.ts +2 -6
  74. package/loaders/lib/resolveCrossFileSelectors.ts +54 -45
  75. package/loaders/turbo-evaluator.ts +7 -14
  76. package/loaders/turbo-loader.ts +5 -22
  77. package/loaders/vite-plugin.ts +19 -51
  78. package/loaders/webpack-loader.ts +1 -3
  79. package/package.json +129 -67
  80. package/runtime/__tests__/attrs.test.tsx +9 -16
  81. package/runtime/__tests__/cssLiteral.test.tsx +21 -45
  82. package/runtime/__tests__/cssProp.test.tsx +8 -17
  83. package/runtime/__tests__/cssPropTest.tsx +10 -13
  84. package/runtime/__tests__/styled.test.tsx +4 -13
  85. package/runtime/__tests__/tsconfig.json +1 -0
  86. package/runtime/__tests__/typeTest.tsx +7 -15
  87. package/runtime/atoms.tsx +1 -1
  88. package/runtime/context/README.md +11 -16
  89. package/runtime/context/index.server.tsx +2 -9
  90. package/runtime/cssLiteral.tsx +4 -13
  91. package/runtime/index.ts +1 -1
  92. package/runtime/internals/mergeCssProp.ts +1 -3
  93. package/runtime/jsx-runtime.ts +1 -2
  94. package/runtime/keyframes.tsx +1 -1
  95. package/runtime/mocks/cssLiteral.ts +3 -11
  96. package/runtime/mocks/keyframes.ts +1 -1
  97. package/runtime/publicStyledApi.ts +3 -13
  98. package/runtime/styled.tsx +16 -28
  99. package/withYak/index.ts +7 -16
@@ -1,18 +1,15 @@
1
1
  "use client";
2
2
 
3
- // runtime/context/index.tsx
4
3
  import React, { createContext, use } from "react";
5
- var YakContext = createContext({});
6
- var useTheme = () => {
7
- const context = use(YakContext);
8
- return context instanceof Promise ? use(context) : context;
9
- };
10
- var YakThemeProvider = ({
11
- children,
12
- theme = {}
13
- }) => /* @__PURE__ */ React.createElement(YakContext.Provider, { value: theme }, children);
14
- export {
15
- YakThemeProvider,
16
- useTheme
4
+
5
+ //#region runtime/context/index.tsx
6
+ const YakContext = createContext({});
7
+ const useTheme = () => {
8
+ const context = use(YakContext);
9
+ return context instanceof Promise ? use(context) : context;
17
10
  };
11
+ const YakThemeProvider = ({ children, theme = {} }) => /* @__PURE__ */ React.createElement(YakContext.Provider, { value: theme }, children);
12
+
13
+ //#endregion
14
+ export { YakThemeProvider, useTheme };
18
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../runtime/context/index.tsx"],"sourcesContent":["\"use client\";\n//\n// This file is the client component (browser & ssr) version of index.server.tsx\n//\nimport React, { ReactNode, createContext, use } from \"react\";\n\nexport interface YakTheme {}\n\n/**\n * The yak theme context\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nconst YakContext = createContext<YakTheme>({});\n\n/**\n * Returns the current yak theme context\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const useTheme = (): YakTheme => {\n const context = use(YakContext);\n return context instanceof Promise ? use(context) : context;\n};\n\n/**\n * Yak theme context provider\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const YakThemeProvider = ({\n children,\n theme = {},\n}: {\n children: ReactNode;\n theme?: YakTheme;\n}) => <YakContext.Provider value={theme}>{children}</YakContext.Provider>;\n"],"mappings":";;;AAIA,OAAO,SAAoB,eAAe,WAAW;AAQrD,IAAM,aAAa,cAAwB,CAAC,CAAC;AAOtC,IAAM,WAAW,MAAgB;AACtC,QAAM,UAAU,IAAI,UAAU;AAC9B,SAAO,mBAAmB,UAAU,IAAI,OAAO,IAAI;AACrD;AAOO,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,QAAQ,CAAC;AACX,MAGM,oCAAC,WAAW,UAAX,EAAoB,OAAO,SAAQ,QAAS;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../runtime/context/index.tsx"],"sourcesContent":["\"use client\";\n//\n// This file is the client component (browser & ssr) version of index.server.tsx\n//\nimport React, { ReactNode, createContext, use } from \"react\";\n\nexport interface YakTheme {}\n\n/**\n * The yak theme context\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nconst YakContext = createContext<YakTheme>({});\n\n/**\n * Returns the current yak theme context\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const useTheme = (): YakTheme => {\n const context = use(YakContext);\n return context instanceof Promise ? use(context) : context;\n};\n\n/**\n * Yak theme context provider\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const YakThemeProvider = ({\n children,\n theme = {},\n}: {\n children: ReactNode;\n theme?: YakTheme;\n}) => <YakContext.Provider value={theme}>{children}</YakContext.Provider>;\n"],"mappings":";;;;;AAYA,MAAM,aAAa,cAAwB,EAAE,CAAC;AAO9C,MAAa,iBAA2B;CACtC,MAAM,UAAU,IAAI,WAAW;AAC/B,QAAO,mBAAmB,UAAU,IAAI,QAAQ,GAAG;;AAQrD,MAAa,oBAAoB,EAC/B,UACA,QAAQ,EAAE,OAIN,oCAAC,WAAW,UAAZ,EAAqB,OAAO,OAAuC,EAA/B,SAA+B"}
@@ -1,53 +1,47 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
9
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ let react = require("react");
30
+ react = __toESM(react);
31
+ let runtime_context_index_js = require("./index.js");
32
+ let next_yak_context_baseContext = require("next-yak/context/baseContext");
29
33
 
30
- // runtime/context/index.server.tsx
31
- var index_server_exports = {};
32
- __export(index_server_exports, {
33
- YakThemeProvider: () => YakThemeProvider,
34
- useTheme: () => useTheme
35
- });
36
- module.exports = __toCommonJS(index_server_exports);
37
- var import_react = __toESM(require("react"), 1);
38
- var import_index = require("./index.js");
39
- var import_baseContext = require("next-yak/context/baseContext");
40
- var getYakContext = (0, import_react.cache)(() => (0, import_baseContext.getYakThemeContext)());
41
- var useTheme = () => {
42
- const theme = getYakContext();
43
- return theme instanceof Promise ? (0, import_react.use)(theme) : theme;
34
+ //#region runtime/context/index.server.tsx
35
+ const getYakContext = (0, react.cache)(() => (0, next_yak_context_baseContext.getYakThemeContext)());
36
+ const useTheme = () => {
37
+ const theme = getYakContext();
38
+ return theme instanceof Promise ? (0, react.use)(theme) : theme;
44
39
  };
45
- var YakThemeProvider = ({ children }) => {
46
- return /* @__PURE__ */ import_react.default.createElement(import_index.YakThemeProvider, { theme: getYakContext() }, children);
40
+ const YakThemeProvider = ({ children }) => {
41
+ return /* @__PURE__ */ react.default.createElement(runtime_context_index_js.YakThemeProvider, { theme: getYakContext() }, children);
47
42
  };
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- YakThemeProvider,
51
- useTheme
52
- });
43
+
44
+ //#endregion
45
+ exports.YakThemeProvider = YakThemeProvider;
46
+ exports.useTheme = useTheme;
53
47
  //# sourceMappingURL=index.server.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport {\n YakTheme,\n YakThemeProvider as YakThemeClientProvider,\n} from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"next-yak/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return (\n <YakThemeClientProvider theme={getYakContext()}>\n {children}\n </YakThemeClientProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAA6C;AAC7C,mBAGO;AAKP,yBAAmC;AAGnC,IAAM,oBAAgB,oBAAM,UAAM,uCAAmB,CAAC;AAC/C,IAAM,WAAW,MAA4B;AAClD,QAAM,QAAkD,cAAc;AACtE,SAAO,iBAAiB,cAAU,kBAAI,KAAK,IAAI;AACjD;AACO,IAAM,mBAAmB,CAAC,EAAE,SAAS,MAA+B;AACzE,SACE,6BAAAA,QAAA,cAAC,aAAAC,kBAAA,EAAuB,OAAO,cAAc,KAC1C,QACH;AAEJ;","names":["React","YakThemeClientProvider"]}
1
+ {"version":3,"file":"index.server.cjs","names":["YakThemeClientProvider"],"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport { YakTheme, YakThemeProvider as YakThemeClientProvider } from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"next-yak/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return <YakThemeClientProvider theme={getYakContext()}>{children}</YakThemeClientProvider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,6FAAgD,CAAC;AACvD,MAAa,iBAAuC;CAClD,MAAM,QAAkD,eAAe;AACvE,QAAO,iBAAiB,yBAAc,MAAM,GAAG;;AAEjD,MAAa,oBAAoB,EAAE,eAAwC;AACzE,QAAO,4CAACA,2CAAD,EAAwB,OAAO,eAAe,EAAqC,EAAlC,SAAkC"}
@@ -0,0 +1,13 @@
1
+ import React, { ReactNode } from "react";
2
+ import { YakTheme } from "./index.js";
3
+
4
+ //#region runtime/context/index.server.d.ts
5
+ declare const useTheme: () => YakTheme | undefined;
6
+ declare const YakThemeProvider: ({
7
+ children
8
+ }: {
9
+ children: ReactNode;
10
+ }) => React.JSX.Element;
11
+ //#endregion
12
+ export { YakThemeProvider, useTheme };
13
+ //# sourceMappingURL=index.server.d.cts.map
@@ -0,0 +1,13 @@
1
+ import React, { ReactNode } from "react";
2
+ import { YakTheme } from "./index.js";
3
+
4
+ //#region runtime/context/index.server.d.ts
5
+ declare const useTheme: () => YakTheme | undefined;
6
+ declare const YakThemeProvider: ({
7
+ children
8
+ }: {
9
+ children: ReactNode;
10
+ }) => React.JSX.Element;
11
+ //#endregion
12
+ export { YakThemeProvider, useTheme };
13
+ //# sourceMappingURL=index.server.d.ts.map
@@ -1,19 +1,17 @@
1
- // runtime/context/index.server.tsx
2
1
  import React, { cache, use } from "react";
3
- import {
4
- YakThemeProvider as YakThemeClientProvider
5
- } from "./index.js";
2
+ import { YakThemeProvider as YakThemeProvider$1 } from "./index.js";
6
3
  import { getYakThemeContext } from "next-yak/context/baseContext";
7
- var getYakContext = cache(() => getYakThemeContext());
8
- var useTheme = () => {
9
- const theme = getYakContext();
10
- return theme instanceof Promise ? use(theme) : theme;
4
+
5
+ //#region runtime/context/index.server.tsx
6
+ const getYakContext = cache(() => getYakThemeContext());
7
+ const useTheme = () => {
8
+ const theme = getYakContext();
9
+ return theme instanceof Promise ? use(theme) : theme;
11
10
  };
12
- var YakThemeProvider = ({ children }) => {
13
- return /* @__PURE__ */ React.createElement(YakThemeClientProvider, { theme: getYakContext() }, children);
14
- };
15
- export {
16
- YakThemeProvider,
17
- useTheme
11
+ const YakThemeProvider = ({ children }) => {
12
+ return /* @__PURE__ */ React.createElement(YakThemeProvider$1, { theme: getYakContext() }, children);
18
13
  };
14
+
15
+ //#endregion
16
+ export { YakThemeProvider, useTheme };
19
17
  //# sourceMappingURL=index.server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport {\n YakTheme,\n YakThemeProvider as YakThemeClientProvider,\n} from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"next-yak/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return (\n <YakThemeClientProvider theme={getYakContext()}>\n {children}\n </YakThemeClientProvider>\n );\n};\n"],"mappings":";AAKA,OAAO,SAAoB,OAAO,WAAW;AAC7C;AAAA,EAEE,oBAAoB;AAAA,OACf;AAKP,SAAS,0BAA0B;AAGnC,IAAM,gBAAgB,MAAM,MAAM,mBAAmB,CAAC;AAC/C,IAAM,WAAW,MAA4B;AAClD,QAAM,QAAkD,cAAc;AACtE,SAAO,iBAAiB,UAAU,IAAI,KAAK,IAAI;AACjD;AACO,IAAM,mBAAmB,CAAC,EAAE,SAAS,MAA+B;AACzE,SACE,oCAAC,0BAAuB,OAAO,cAAc,KAC1C,QACH;AAEJ;","names":[]}
1
+ {"version":3,"file":"index.server.js","names":["YakThemeClientProvider"],"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport { YakTheme, YakThemeProvider as YakThemeClientProvider } from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"next-yak/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return <YakThemeClientProvider theme={getYakContext()}>{children}</YakThemeClientProvider>;\n};\n"],"mappings":";;;;;AAcA,MAAM,gBAAgB,YAAY,oBAAoB,CAAC;AACvD,MAAa,iBAAuC;CAClD,MAAM,QAAkD,eAAe;AACvE,QAAO,iBAAiB,UAAU,IAAI,MAAM,GAAG;;AAEjD,MAAa,oBAAoB,EAAE,eAAwC;AACzE,QAAO,oCAACA,oBAAD,EAAwB,OAAO,eAAe,EAAqC,EAAlC,SAAkC"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";var E=Object.create;var u=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var s in e)u(t,s,{get:e[s],enumerable:!0})},R=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of D(e))!M.call(t,n)&&n!==s&&u(t,n,{get:()=>e[n],enumerable:!(r=$(e,n))||r.enumerable});return t};var J=(t,e,s)=>(s=t!=null?E(L(t)):{},R(e||!t||!t.__esModule?u(s,"default",{value:t,enumerable:!0}):s,t)),W=t=>R(u({},"__esModule",{value:!0}),t);var U={};H(U,{YakThemeProvider:()=>S.YakThemeProvider,atoms:()=>N,css:()=>b,keyframes:()=>I,styled:()=>O,useTheme:()=>S.useTheme});module.exports=W(U);var S=require("next-yak/context");var p=Symbol("yak");function f(...t){let e,s=[];for(let r of t)typeof r=="string"?e=r:typeof r=="function"?s.push(r):typeof r=="object"&&"style"in r&&s.push((n,o,i)=>{for(let c in r.style){let y=r.style[c];typeof y=="function"?i[c]=String(h(n,y)):i[c]=String(y)}});return s.length===0?(r,n)=>(e&&n.add(e),()=>{}):(r,n,o)=>{e&&n.add(e);for(let i=0;i<s.length;i++)B(r,s[i],n,o)}}var B=(t,e,s,r)=>{let n=e(t,s,r);for(;n;){if(typeof n=="function"){n=n(t,s,r);continue}else if(typeof n=="object"&&("className"in n&&n.className&&s.add(n.className),"style"in n&&n.style))for(let o in n.style)r[o]=n.style[o];break}},h=(t,e)=>{let s=e(t);if(typeof s=="function")return h(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)}
2
-
3
- Dynamic CSS function: ${e.toString()}
4
- `);return s};var N=(...t)=>{let e=[],s=[];for(let n of t)typeof n=="string"?e.push(...n.split(" ")):typeof n=="function"&&s.push(n);let r=e.length>0?[(n,o)=>{e.forEach(i=>o.add(i))},...s]:s;return f(...r)};var b=(t,...e)=>{if(Array.isArray(t)&&"raw"in t){let r=t[0];for(let n=0;n<e.length;n++){let o=e[n];r+=o&&typeof o=="object"&&"__yak"in o?o.__yak:String(o),r+=t[n+1]}return{__yak:r}}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++)G(r,s[n]);return{className:"",style:void 0}})};function G(t,e){let s=new Set,r={},n=e(t,s,r);for(;typeof n=="function";)n=n(t,s,r);return n}var I=(t,...e)=>"";var _=J(require("react"),1),F=require("next-yak/context"),V={},X=t=>Object.assign(w(t),{attrs:e=>w(t,e)}),Y=X,w=(t,e)=>{let s=typeof t!="string"&&p in t,[r,n,o]=s?t[p]:[],i=K(e,n);return(c,...y)=>{let T=f(c,...y),g=Q(T,o),k=l=>{let m=i||T.length?(0,F.useTheme)():V,a="$__attrs"in l?{theme:m,...l}:d({theme:m,...l,$__attrs:!0},i?.({theme:m,...l})),P=new Set("className"in a?a.className?.split(" "):[]),C={..."style"in a?a.style:{}};"$__runtimeStylesProcessed"in a||(g(a,P,C),a.$__runtimeStylesProcessed=!0),a.className=Array.from(P).join(" ")||void 0,a.style=C;let{theme:j,...v}=a,A=j===m?v:a,x=s?A:q(A);return r?r(x):_.default.createElement(t,{...x})};return Object.assign(k,{[p]:[k,i,g]})}},q=t=>{let e={};for(let s in t)!s.startsWith("$")&&t[s]!==void 0&&(e[s]=t[s]);return e},z=(t,e)=>{if(!(!t&&!e))return t?e?t+" "+e:t:e},d=(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 s=t&&(typeof t=="function"?t:()=>t);return s&&e?r=>{let n=e(r);return d(n,s(d(r,n)))}:s||e},Q=(t,e)=>t&&e?(r,n,o)=>{e(r,n,o),t(r,n,o)}:t||e;var O=new Proxy(Y,{get(t,e){return t(e)}});0&&(module.exports={YakThemeProvider,atoms,css,keyframes,styled,useTheme});
1
+ 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}});
5
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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 SWC 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, YakComponent } 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 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 dynamicCssFunctions.push((props, _, style) => {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n // @ts-expect-error CSSProperties don't allow css variables\n style[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 } else {\n // @ts-expect-error CSSProperties don't allow css variables\n style[key] = String(value);\n }\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 // When called in yak files as a template tag (without SWC transformation),\n // return { __yak: rawCss } so the cross-file resolver can\n // extract the mixin value from evaluated .yak files.\n if (Array.isArray(styles) && \"raw\" in styles) {\n let rawCss = styles[0];\n for (let i = 0; i < args.length; i++) {\n const interpolation = args[i];\n rawCss +=\n interpolation &&\n typeof interpolation === \"object\" &&\n \"__yak\" in interpolation\n ? (interpolation as { __yak: string }).__yak\n : String(interpolation);\n rawCss += styles[i + 1];\n }\n return { __yak: rawCss } as any;\n }\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 styling 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,EAC5D,QAAWC,KAAOH,EAIZ,OAAOG,GAAQ,SACjBF,EAAYE,EAKL,OAAOA,GAAQ,WACtBD,EAAoB,KAAKC,CA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,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","arg","props","_","style","key","value","recursivePropExecution","classNames","allStyles","unwrapProps","fn","result","atoms","staticClasses","dynamicFunctions","atom","runtimeFunctions","_","classNames","cls","css","css","styles","args","rawCss","i","interpolation","dynamicCssFunctions","arg","props","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"]}
1
+ {"version":3,"file":"index.cjs","names":["css","css","styled","css","StyledFactory"],"sources":["../runtime/cssLiteral.tsx","../runtime/atoms.tsx","../runtime/mocks/cssLiteral.ts","../runtime/mocks/keyframes.ts","../runtime/styled.tsx","../runtime/mocks/styled.ts"],"sourcesContent":["import type { YakTheme } from \"./index.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>(...args: Array<any>): 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 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 dynamicCssFunctions.push((props, _, style) => {\n for (const key in arg.style) {\n const value = arg.style[key];\n if (typeof value === \"function\") {\n // @ts-expect-error CSSProperties don't allow css variables\n style[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 } else {\n // @ts-expect-error CSSProperties don't allow css variables\n style[key] = String(value);\n }\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 = (props: unknown, fn: (props: unknown) => any): 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 (typeof result !== \"string\" && typeof result !== \"number\" && !(result instanceof String)) {\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 } 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 { css as cssInternal, NestedRuntimeStyleProcessor } 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 = (styles: TemplateStringsArray, ...args: unknown[]) => {\n // When called in yak files as a template tag (without SWC transformation),\n // return { __yak: rawCss } so the cross-file resolver can\n // extract the mixin value from evaluated .yak files.\n if (Array.isArray(styles) && \"raw\" in styles) {\n let rawCss = styles[0];\n for (let i = 0; i < args.length; i++) {\n const interpolation = args[i];\n rawCss +=\n interpolation && typeof interpolation === \"object\" && \"__yak\" in interpolation\n ? (interpolation as { __yak: string }).__yak\n : String(interpolation);\n rawCss += styles[i + 1];\n }\n return { __yak: rawCss } as any;\n }\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.tsx\";\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 = 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] = 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 = 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 } = 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<Exclude<typeof Component, string>>)}\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 styling purposes\n * but are not be passed to the DOM element\n */\nconst removeNonDomProperties = <T extends Record<string, unknown>>(obj: T): 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 = 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(parentProps, ownAttrsFn(combineProps(props, parentProps)));\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":"6lBAGA,MAAa,EAAqB,OAAO,MAAM,CAgE/C,SAAgBA,EAAY,GAAG,EAAiD,CAG9E,IAAI,EACE,EAAqD,EAAE,CAC7D,IAAK,IAAM,KAAO,EAIZ,OAAO,GAAQ,SACjB,EAAY,EAKL,OAAO,GAAQ,WACtB,EAAoB,KAAK,EAA8C,CAKhE,OAAO,GAAQ,UAAY,UAAW,GAC7C,EAAoB,MAAM,EAAO,EAAG,IAAU,CAC5C,IAAK,IAAM,KAAO,EAAI,MAAO,CAC3B,IAAM,EAAQ,EAAI,MAAM,GACpB,OAAO,GAAU,WAEnB,EAAM,GAAO,OAKX,EAAuB,EAAO,EAAM,CACrC,CAGD,EAAM,GAAO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M,UAAW,EAAS,UAAU,CAC/D,MAAO,CAAE,GAAG,EAAM,MAAO,GAAG,EAAS,MAAO,CAC7C,CAEH,EAWA,GAKJ,EACA,IACsD,CACtD,IAAM,EAAa,IAAU,OAAO,GAAU,WAAa,MAAc,GAezE,OAbI,GAAc,EACR,GAAU,CAChB,IAAM,EAAc,EAAc,EAAM,CAOxC,OAAO,EAAa,EAAa,EAAW,EAAa,EAAO,EAAY,CAAC,CAAC,EAI3E,GAAc,GAUjB,GACJ,EACA,IAEI,GAAmB,GACuB,EAAO,EAAY,IAAU,CACvE,EAAsB,EAAO,EAAY,EAAM,CAC/C,EAAgB,EAAO,EAAY,EAAM,EAItC,GAAmB,ECnSf,EAAS,IAAI,MAAMC,EAAe,CAC7C,IAAI,EAAQ,EAA4C,CACtD,OAAO,EAAO,EAAQ,EAEzB,CAAC"}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import React, { ReactNode } from 'react';
1
+ import React$1, { ReactNode } from "react";
2
2
 
3
- interface YakTheme {
4
- }
3
+ //#region runtime/context/index.d.ts
4
+ interface YakTheme {}
5
5
  /**
6
6
  * Returns the current yak theme context
7
7
  *
@@ -13,20 +13,24 @@ declare const useTheme: () => YakTheme;
13
13
  *
14
14
  * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md
15
15
  */
16
- declare const YakThemeProvider: ({ children, theme, }: {
17
- children: ReactNode;
18
- theme?: YakTheme;
19
- }) => React.JSX.Element;
20
-
16
+ declare const YakThemeProvider: ({
17
+ children,
18
+ theme
19
+ }: {
20
+ children: ReactNode;
21
+ theme?: YakTheme;
22
+ }) => React$1.JSX.Element;
23
+ //#endregion
24
+ //#region runtime/cssLiteral.d.ts
21
25
  declare const yakComponentSymbol: unique symbol;
22
26
  type ComponentStyles<TProps> = (props: TProps) => {
23
- className: string;
24
- style?: {
25
- [key: string]: string;
26
- };
27
+ className: string;
28
+ style?: {
29
+ [key: string]: string;
30
+ };
27
31
  };
28
32
  type CSSInterpolation<TProps> = string | number | undefined | null | false | ComponentStyles<TProps> | {
29
- [yakComponentSymbol]: any;
33
+ [yakComponentSymbol]: any;
30
34
  } | ((props: TProps) => CSSInterpolation<TProps>);
31
35
  /**
32
36
  * css() runtime factory of css``
@@ -45,69 +49,67 @@ type CSSInterpolation<TProps> = string | number | undefined | null | false | Com
45
49
  * and operate directly on the classNames and style objects.
46
50
  */
47
51
  declare function css$1<TProps>(styles: TemplateStringsArray, ...values: CSSInterpolation<NoInfer<TProps> & {
48
- theme: YakTheme;
52
+ theme: YakTheme;
49
53
  }>[]): ComponentStyles<TProps>;
50
-
54
+ //#endregion
55
+ //#region runtime/publicStyledApi.d.ts
51
56
  /**
52
57
  * Main styled interface that combines HTML tag mappings with the styled function.
53
58
  * This is the primary entry point for creating styled components.
54
59
  */
55
- interface Styled extends MappedHtmlTags, StyledFn {
56
- }
60
+ interface Styled extends MappedHtmlTags, StyledFn {}
57
61
  /**
58
62
  * Function interface for creating styled components from any component or HTML tag.
59
63
  * Supports React components, HTML tags, and custom web components.
60
64
  */
61
65
  interface StyledFn {
62
- <TProps extends object = React.DOMAttributes<Element> & React.RefAttributes<Element>>(Component: HtmlTags | React.FunctionComponent<TProps> | CustomWebComponentTag): LiteralWithAttrs<TProps>;
66
+ <TProps extends object = React$1.DOMAttributes<Element> & React$1.RefAttributes<Element>>(Component: HtmlTags | React$1.FunctionComponent<TProps> | CustomWebComponentTag): LiteralWithAttrs<TProps>;
63
67
  }
64
68
  /**
65
69
  * A yak component with a special symbol that allows component targeting
66
70
  * and proper attrs function handling.
67
71
  * @example styled.svg`${Button}:hover & { fill: red; }` or styled(Button)`color: red;`
68
72
  */
69
- interface YakComponent<T> extends React.FunctionComponent<T> {
70
- [yakComponentSymbol]: [unknown, unknown, unknown];
73
+ interface YakComponent<T> extends React$1.FunctionComponent<T> {
74
+ [yakComponentSymbol]: [unknown, unknown, unknown];
71
75
  }
72
76
  /**
73
77
  * Styled component with attrs method for adding default props.
74
78
  * Extends StyledLiteral with the ability to specify default attributes.
75
79
  */
76
80
  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>>;
81
+ attrs: <TAttrsIn extends object = {}, TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>>(attrs: Attrs<T, TAttrsIn, TAttrsOut>) => StyledLiteral<Substitute<T, TAttrsIn>>;
78
82
  }
79
83
  /**
80
84
  * Template literal function for defining CSS styles with interpolation support.
81
85
  * Accepts CSS template strings and interpolated values with proper typing.
82
86
  */
83
87
  interface StyledLiteral<T> {
84
- <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
85
- theme: YakTheme;
86
- }>>): YakComponent<TCSSProps & T>;
88
+ <TCSSProps>(styles: TemplateStringsArray, ...values: Array<CSSInterpolation<T & NoInfer<TCSSProps> & {
89
+ theme: YakTheme;
90
+ }>>): YakComponent<TCSSProps & T>;
87
91
  }
88
92
  /**
89
93
  * Function variant of attrs that receives current props and returns additional props.
90
94
  * Allows for dynamic prop generation based on component state.
91
95
  */
92
96
  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>;
97
+ (p: Substitute<TBaseProps & {
98
+ theme: YakTheme;
99
+ }, TIn>): Partial<TOut>;
96
100
  }
97
101
  /**
98
102
  * Merges provided props with initial props, making specified props optional.
99
103
  * Includes theme support for styled components.
100
104
  */
101
105
  type AttrsMerged<TBaseProps, TIn extends object = {}> = Substitute<TBaseProps & {
102
- theme?: YakTheme;
106
+ theme?: YakTheme;
103
107
  }, TIn>;
104
108
  /**
105
109
  * Maps all HTML tag names to their corresponding styled component types with attributes support.
106
110
  * Provides typed access to all standard HTML elements through the styled interface.
107
111
  */
108
- type MappedHtmlTags = {
109
- [Tag in HtmlTags]: LiteralWithAttrs<React.JSX.IntrinsicElements[Tag]>;
110
- };
112
+ type MappedHtmlTags = { [Tag in HtmlTags]: LiteralWithAttrs<React$1.JSX.IntrinsicElements[Tag]> };
111
113
  /**
112
114
  * The attrs function allows adding additional props to a styled component.
113
115
  * Props can be specified as an object or as a function that receives current props.
@@ -122,7 +124,7 @@ type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
122
124
  * Union type of all valid HTML element tag names.
123
125
  * Derived from React's JSX intrinsic elements.
124
126
  */
125
- type HtmlTags = keyof React.JSX.IntrinsicElements;
127
+ type HtmlTags = keyof React$1.JSX.IntrinsicElements;
126
128
  /**
127
129
  * Custom web component tag pattern that must contain at least one hyphen.
128
130
  * Follows the web component naming convention.
@@ -132,20 +134,19 @@ type CustomWebComponentTag = `${string}-${string}`;
132
134
  * Utility type to efficiently remove properties from an object type.
133
135
  * More performant than the built-in Omit type for large object types.
134
136
  */
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
- };
137
+ type FastOmit<T extends object, U extends string | number | symbol> = { [K in keyof T as K extends U ? never : K]: T[K] };
138
138
  /**
139
139
  * Type of all functions that can be passed to manipulate styles
140
140
  */
141
- type RuntimeStyleProcessor<T> = (props: T, classNames: Set<string>, style: React.CSSProperties) => void;
141
+ type RuntimeStyleProcessor<T> = (props: T, classNames: Set<string>, style: React$1.CSSProperties) => void;
142
142
  /**
143
143
  * Utility type to keep the generic API of a component while still being able to use it in a selector
144
144
  */
145
145
  type GenericYakComponentOf<T, P = {}> = T & YakComponent<P> & {
146
- <G = {}>(props: P & G): React.ReactElement | null;
146
+ <G = {}>(props: P & G): React$1.ReactElement | null;
147
147
  };
148
-
148
+ //#endregion
149
+ //#region runtime/atoms.d.ts
149
150
  /**
150
151
  * Allows to use atomic CSS classes in a styled or css block
151
152
  *
@@ -161,7 +162,8 @@ type GenericYakComponentOf<T, P = {}> = T & YakComponent<P> & {
161
162
  * ```
162
163
  */
163
164
  declare const atoms: <T>(...atoms: (string | RuntimeStyleProcessor<T> | false)[]) => ComponentStyles<T>;
164
-
165
+ //#endregion
166
+ //#region runtime/mocks/cssLiteral.d.ts
165
167
  /**
166
168
  * Allows to use CSS styles in a styled or css block
167
169
  *
@@ -175,7 +177,8 @@ declare const atoms: <T>(...atoms: (string | RuntimeStyleProcessor<T> | false)[]
175
177
  * ```
176
178
  */
177
179
  declare const css: typeof css$1;
178
-
180
+ //#endregion
181
+ //#region runtime/keyframes.d.ts
179
182
  /**
180
183
  * Allows to use CSS keyframe animations in a styled or css block
181
184
  *
@@ -198,8 +201,9 @@ declare const css: typeof css$1;
198
201
  * `;
199
202
  * ```
200
203
  */
201
- declare const keyframes$1: <T extends (string | number | bigint)[] = never>(styles: TemplateStringsArray, ...dynamic: T) => string;
202
-
204
+ declare const keyframes$1: <T extends (string | number | bigint)[] = never>(styles: TemplateStringsArray, ..._dynamic: T) => string;
205
+ //#endregion
206
+ //#region runtime/mocks/keyframes.d.ts
203
207
  /**
204
208
  * Allows to use CSS keyframe animations in a styled or css block
205
209
  *
@@ -223,7 +227,8 @@ declare const keyframes$1: <T extends (string | number | bigint)[] = never>(styl
223
227
  * ```
224
228
  */
225
229
  declare const keyframes: typeof keyframes$1;
226
-
230
+ //#endregion
231
+ //#region runtime/styled.d.ts
227
232
  /**
228
233
  * The `styled` method works perfectly on all of your own or any third-party component,
229
234
  * as long as they attach the passed className prop to a DOM element.
@@ -238,7 +243,8 @@ declare const keyframes: typeof keyframes$1;
238
243
  * ```
239
244
  */
240
245
  declare const styled$1: Styled;
241
-
246
+ //#endregion
247
+ //#region runtime/mocks/styled.d.ts
242
248
  declare const styled: typeof styled$1;
243
-
244
- export { type GenericYakComponentOf, type YakComponent, type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };
249
+ //#endregion
250
+ export { type GenericYakComponentOf, type YakComponent, type YakTheme, YakThemeProvider, atoms, css, keyframes, styled, useTheme };