@pandacss/node 0.0.0-dev-20221125165251 → 0.0.0-dev-20221126121755

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 (3) hide show
  1. package/dist/index.js +55 -41
  2. package/dist/index.mjs +57 -43
  3. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -160,7 +160,7 @@ function generateConditions(ctx) {
160
160
  var import_outdent2 = require("outdent");
161
161
  var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
162
162
  function generateCssFn(ctx) {
163
- const { utility, hash } = ctx;
163
+ const { utility, hash, conditions } = ctx;
164
164
  const { separator } = utility;
165
165
  return {
166
166
  dts: import_outdent2.outdent`
@@ -172,7 +172,10 @@ function generateCssFn(ctx) {
172
172
  import { sortConditions, finalizeConditions } from "./conditions"
173
173
 
174
174
  const classNameMap = ${stringify(utility.entries())}
175
+
175
176
  const shorthands = ${stringify(utility.shorthands)}
177
+
178
+ const breakpointKeys = ${JSON.stringify(conditions.breakpoints.keys)}
176
179
 
177
180
  const hasShorthand = ${utility.hasShorthand ? "true" : "false"}
178
181
 
@@ -186,11 +189,17 @@ function generateCssFn(ctx) {
186
189
  }
187
190
 
188
191
  const context = {
189
- transform,
190
- conditions: { shift: sortConditions, finalize: finalizeConditions },
191
192
  hash: ${hash ? "true" : "false"},
192
- hasShorthand,
193
- resolveShorthand,
193
+ conditions: {
194
+ shift: sortConditions,
195
+ finalize: finalizeConditions,
196
+ breakpoints: { keys: breakpointKeys }
197
+ },
198
+ utility: {
199
+ transform,
200
+ hasShorthand,
201
+ resolveShorthand,
202
+ }
194
203
  }
195
204
 
196
205
  export const css = createCss(context)
@@ -987,7 +996,13 @@ function generateRecipes(ctx) {
987
996
  return { className: \`\${name}--\${prop}${separator}\${value}\` }
988
997
  }
989
998
 
990
- const context = ${hash ? "{ transform, hash: true }" : "{ transform }"}
999
+ const context = {
1000
+ hash: ${hash ? "true" : "false"},
1001
+ utility: {
1002
+ transform,
1003
+ }
1004
+ }
1005
+
991
1006
  const css = createCss(context)
992
1007
 
993
1008
  return css({ [name]: '__ignore__' , ...styles })
@@ -1126,9 +1141,9 @@ var import_core2 = require("@pandacss/core");
1126
1141
  var import_outdent18 = require("outdent");
1127
1142
  var import_ts_pattern5 = require("ts-pattern");
1128
1143
  function generateKeyframes(keyframes) {
1129
- if (keyframes) {
1130
- return (0, import_core2.toKeyframeCss)(keyframes);
1131
- }
1144
+ if (!keyframes)
1145
+ return;
1146
+ return (0, import_core2.toKeyframeCss)(keyframes);
1132
1147
  }
1133
1148
  var getConditionMessage = (value) => import_outdent18.outdent`
1134
1149
  It seems you provided an invalid condition for semantic tokens.
@@ -1150,37 +1165,44 @@ function generateTokenCss(ctx, varRoot) {
1150
1165
  const { css: css3 } = (0, import_core2.toCss)({ [root]: varsObj });
1151
1166
  results.push(css3);
1152
1167
  } else {
1153
- const cond = conditions.normalize(key);
1154
- const css3 = (0, import_ts_pattern5.match)(cond).with({ type: "parent-nesting" }, (cond2) => {
1155
- const selector = cond2.value.replace(/\s&/g, "");
1156
- const { css: css4 } = (0, import_core2.toCss)(varsObj);
1157
- return `${selector} {
1158
- ${css4};
1168
+ const keys = key.split(":");
1169
+ const { css: css3 } = (0, import_core2.toCss)(varsObj);
1170
+ const sorted = conditions.sort(keys);
1171
+ const allAtRules = sorted.every(({ type }) => type === "at-rule");
1172
+ const result = sorted.reduce(
1173
+ (acc, cond, index, conds) => {
1174
+ let selector;
1175
+ return (0, import_ts_pattern5.match)(cond).with({ type: "parent-nesting" }, (cond2) => {
1176
+ selector = cond2.value.replace(/\s&/g, "");
1177
+ const merge = conds[index - 1]?.type === "parent-nesting";
1178
+ return merge ? `${selector}${acc}` : `${selector} {
1179
+ ${acc}
1159
1180
  }`;
1160
- }).with({ type: "at-rule" }, (cond2) => {
1161
- const selector = cond2.rawValue ?? cond2.raw;
1162
- const { css: css4 } = (0, import_core2.toCss)(varsObj);
1163
- return `${selector} {
1164
- ${root} {
1165
- ${css4};
1166
- }
1181
+ }).with({ type: "at-rule" }, (cond2) => {
1182
+ selector = cond2?.rawValue ?? cond2?.raw;
1183
+ return `${selector} {
1184
+ ${acc}
1167
1185
  }`;
1168
- }).with(import_ts_pattern5.P.nullish, () => {
1169
- }).otherwise((cond2) => {
1170
- if (cond2) {
1171
- throw new Error(getConditionMessage(cond2.raw));
1172
- }
1173
- });
1174
- if (css3) {
1175
- results.push(css3);
1186
+ }).otherwise((cond2) => {
1187
+ if (!cond2)
1188
+ return acc;
1189
+ throw new Error(getConditionMessage(cond2.raw));
1190
+ });
1191
+ },
1192
+ allAtRules ? `${root} {
1193
+ ${css3}
1194
+ }` : css3
1195
+ );
1196
+ if (result) {
1197
+ results.push(result);
1176
1198
  }
1177
1199
  }
1178
1200
  }
1179
1201
  const css2 = results.join("\n\n") + "\n\n";
1180
- return `@layer tokens {
1202
+ return (0, import_core2.prettifyCss)(`@layer tokens {
1181
1203
  ${css2}
1182
1204
  }
1183
- `;
1205
+ `);
1184
1206
  }
1185
1207
 
1186
1208
  // src/generators/token-dts.ts
@@ -1638,18 +1660,10 @@ function createContext(conf, io = fileSystem) {
1638
1660
  );
1639
1661
  const context = () => ({
1640
1662
  root: import_postcss.default.root(),
1641
- breakpoints,
1642
1663
  conditions,
1643
1664
  hash,
1644
1665
  helpers,
1645
- utility,
1646
- hasShorthand: utility.hasShorthand,
1647
- resolveShorthand(prop) {
1648
- return utility.resolveShorthand(prop);
1649
- },
1650
- transform(prop, value) {
1651
- return utility.resolve(prop, value);
1652
- }
1666
+ utility
1653
1667
  });
1654
1668
  const patternExclude = ["layoutGrid"];
1655
1669
  function getPattern(name) {
package/dist/index.mjs CHANGED
@@ -115,7 +115,7 @@ function generateConditions(ctx) {
115
115
  import { outdent as outdent2 } from "outdent";
116
116
  var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
117
117
  function generateCssFn(ctx) {
118
- const { utility, hash } = ctx;
118
+ const { utility, hash, conditions } = ctx;
119
119
  const { separator } = utility;
120
120
  return {
121
121
  dts: outdent2`
@@ -127,7 +127,10 @@ function generateCssFn(ctx) {
127
127
  import { sortConditions, finalizeConditions } from "./conditions"
128
128
 
129
129
  const classNameMap = ${stringify(utility.entries())}
130
+
130
131
  const shorthands = ${stringify(utility.shorthands)}
132
+
133
+ const breakpointKeys = ${JSON.stringify(conditions.breakpoints.keys)}
131
134
 
132
135
  const hasShorthand = ${utility.hasShorthand ? "true" : "false"}
133
136
 
@@ -141,11 +144,17 @@ function generateCssFn(ctx) {
141
144
  }
142
145
 
143
146
  const context = {
144
- transform,
145
- conditions: { shift: sortConditions, finalize: finalizeConditions },
146
147
  hash: ${hash ? "true" : "false"},
147
- hasShorthand,
148
- resolveShorthand,
148
+ conditions: {
149
+ shift: sortConditions,
150
+ finalize: finalizeConditions,
151
+ breakpoints: { keys: breakpointKeys }
152
+ },
153
+ utility: {
154
+ transform,
155
+ hasShorthand,
156
+ resolveShorthand,
157
+ }
149
158
  }
150
159
 
151
160
  export const css = createCss(context)
@@ -942,7 +951,13 @@ function generateRecipes(ctx) {
942
951
  return { className: \`\${name}--\${prop}${separator}\${value}\` }
943
952
  }
944
953
 
945
- const context = ${hash ? "{ transform, hash: true }" : "{ transform }"}
954
+ const context = {
955
+ hash: ${hash ? "true" : "false"},
956
+ utility: {
957
+ transform,
958
+ }
959
+ }
960
+
946
961
  const css = createCss(context)
947
962
 
948
963
  return css({ [name]: '__ignore__' , ...styles })
@@ -1077,13 +1092,13 @@ function generateReset() {
1077
1092
  }
1078
1093
 
1079
1094
  // src/generators/token-css.ts
1080
- import { toCss, toKeyframeCss } from "@pandacss/core";
1095
+ import { prettifyCss, toCss, toKeyframeCss } from "@pandacss/core";
1081
1096
  import { outdent as outdent18 } from "outdent";
1082
- import { match as match5, P } from "ts-pattern";
1097
+ import { match as match5 } from "ts-pattern";
1083
1098
  function generateKeyframes(keyframes) {
1084
- if (keyframes) {
1085
- return toKeyframeCss(keyframes);
1086
- }
1099
+ if (!keyframes)
1100
+ return;
1101
+ return toKeyframeCss(keyframes);
1087
1102
  }
1088
1103
  var getConditionMessage = (value) => outdent18`
1089
1104
  It seems you provided an invalid condition for semantic tokens.
@@ -1105,37 +1120,44 @@ function generateTokenCss(ctx, varRoot) {
1105
1120
  const { css: css3 } = toCss({ [root]: varsObj });
1106
1121
  results.push(css3);
1107
1122
  } else {
1108
- const cond = conditions.normalize(key);
1109
- const css3 = match5(cond).with({ type: "parent-nesting" }, (cond2) => {
1110
- const selector = cond2.value.replace(/\s&/g, "");
1111
- const { css: css4 } = toCss(varsObj);
1112
- return `${selector} {
1113
- ${css4};
1123
+ const keys = key.split(":");
1124
+ const { css: css3 } = toCss(varsObj);
1125
+ const sorted = conditions.sort(keys);
1126
+ const allAtRules = sorted.every(({ type }) => type === "at-rule");
1127
+ const result = sorted.reduce(
1128
+ (acc, cond, index, conds) => {
1129
+ let selector;
1130
+ return match5(cond).with({ type: "parent-nesting" }, (cond2) => {
1131
+ selector = cond2.value.replace(/\s&/g, "");
1132
+ const merge = conds[index - 1]?.type === "parent-nesting";
1133
+ return merge ? `${selector}${acc}` : `${selector} {
1134
+ ${acc}
1114
1135
  }`;
1115
- }).with({ type: "at-rule" }, (cond2) => {
1116
- const selector = cond2.rawValue ?? cond2.raw;
1117
- const { css: css4 } = toCss(varsObj);
1118
- return `${selector} {
1119
- ${root} {
1120
- ${css4};
1121
- }
1136
+ }).with({ type: "at-rule" }, (cond2) => {
1137
+ selector = cond2?.rawValue ?? cond2?.raw;
1138
+ return `${selector} {
1139
+ ${acc}
1122
1140
  }`;
1123
- }).with(P.nullish, () => {
1124
- }).otherwise((cond2) => {
1125
- if (cond2) {
1126
- throw new Error(getConditionMessage(cond2.raw));
1127
- }
1128
- });
1129
- if (css3) {
1130
- results.push(css3);
1141
+ }).otherwise((cond2) => {
1142
+ if (!cond2)
1143
+ return acc;
1144
+ throw new Error(getConditionMessage(cond2.raw));
1145
+ });
1146
+ },
1147
+ allAtRules ? `${root} {
1148
+ ${css3}
1149
+ }` : css3
1150
+ );
1151
+ if (result) {
1152
+ results.push(result);
1131
1153
  }
1132
1154
  }
1133
1155
  }
1134
1156
  const css2 = results.join("\n\n") + "\n\n";
1135
- return `@layer tokens {
1157
+ return prettifyCss(`@layer tokens {
1136
1158
  ${css2}
1137
1159
  }
1138
- `;
1160
+ `);
1139
1161
  }
1140
1162
 
1141
1163
  // src/generators/token-dts.ts
@@ -1599,18 +1621,10 @@ function createContext(conf, io = fileSystem) {
1599
1621
  );
1600
1622
  const context = () => ({
1601
1623
  root: postcss.root(),
1602
- breakpoints,
1603
1624
  conditions,
1604
1625
  hash,
1605
1626
  helpers,
1606
- utility,
1607
- hasShorthand: utility.hasShorthand,
1608
- resolveShorthand(prop) {
1609
- return utility.resolveShorthand(prop);
1610
- },
1611
- transform(prop, value) {
1612
- return utility.resolve(prop, value);
1613
- }
1627
+ utility
1614
1628
  });
1615
1629
  const patternExclude = ["layoutGrid"];
1616
1630
  function getPattern(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.0.0-dev-20221125165251",
3
+ "version": "0.0.0-dev-20221126121755",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,15 +30,15 @@
30
30
  "telejson": "6.0.8",
31
31
  "ts-pattern": "4.0.6",
32
32
  "ts-morph": "17.0.1",
33
- "@pandacss/types": "0.0.0-dev-20221125165251",
34
- "@pandacss/is-valid-prop": "0.0.0-dev-20221125165251",
35
- "@pandacss/error": "0.0.0-dev-20221125165251",
36
- "@pandacss/parser": "0.0.0-dev-20221125165251",
37
- "@pandacss/shared": "0.0.0-dev-20221125165251",
38
- "@pandacss/token-dictionary": "0.0.0-dev-20221125165251",
39
- "@pandacss/logger": "0.0.0-dev-20221125165251",
40
- "@pandacss/core": "0.0.0-dev-20221125165251",
41
- "@pandacss/config": "0.0.0-dev-20221125165251"
33
+ "@pandacss/types": "0.0.0-dev-20221126121755",
34
+ "@pandacss/is-valid-prop": "0.0.0-dev-20221126121755",
35
+ "@pandacss/error": "0.0.0-dev-20221126121755",
36
+ "@pandacss/parser": "0.0.0-dev-20221126121755",
37
+ "@pandacss/shared": "0.0.0-dev-20221126121755",
38
+ "@pandacss/token-dictionary": "0.0.0-dev-20221126121755",
39
+ "@pandacss/logger": "0.0.0-dev-20221126121755",
40
+ "@pandacss/core": "0.0.0-dev-20221126121755",
41
+ "@pandacss/config": "0.0.0-dev-20221126121755"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/fs-extra": "9.0.13",
@@ -46,7 +46,7 @@
46
46
  "@types/glob-parent": "^5.1.1",
47
47
  "@types/pluralize": "0.0.29",
48
48
  "@types/lodash.merge": "4.6.7",
49
- "@pandacss/fixture": "0.0.0-dev-20221125165251"
49
+ "@pandacss/fixture": "0.0.0-dev-20221126121755"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",