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

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 +33 -26
  2. package/dist/index.mjs +35 -28
  3. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -1126,9 +1126,9 @@ var import_core2 = require("@pandacss/core");
1126
1126
  var import_outdent18 = require("outdent");
1127
1127
  var import_ts_pattern5 = require("ts-pattern");
1128
1128
  function generateKeyframes(keyframes) {
1129
- if (keyframes) {
1130
- return (0, import_core2.toKeyframeCss)(keyframes);
1131
- }
1129
+ if (!keyframes)
1130
+ return;
1131
+ return (0, import_core2.toKeyframeCss)(keyframes);
1132
1132
  }
1133
1133
  var getConditionMessage = (value) => import_outdent18.outdent`
1134
1134
  It seems you provided an invalid condition for semantic tokens.
@@ -1150,37 +1150,44 @@ function generateTokenCss(ctx, varRoot) {
1150
1150
  const { css: css3 } = (0, import_core2.toCss)({ [root]: varsObj });
1151
1151
  results.push(css3);
1152
1152
  } 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};
1153
+ const keys = key.split(":");
1154
+ const { css: css3 } = (0, import_core2.toCss)(varsObj);
1155
+ const sorted = conditions.sort(keys);
1156
+ const allAtRules = sorted.every(({ type }) => type === "at-rule");
1157
+ const result = sorted.reduce(
1158
+ (acc, cond, index, conds) => {
1159
+ let selector;
1160
+ return (0, import_ts_pattern5.match)(cond).with({ type: "parent-nesting" }, (cond2) => {
1161
+ selector = cond2.value.replace(/\s&/g, "");
1162
+ const merge = conds[index - 1]?.type === "parent-nesting";
1163
+ return merge ? `${selector}${acc}` : `${selector} {
1164
+ ${acc}
1159
1165
  }`;
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
- }
1166
+ }).with({ type: "at-rule" }, (cond2) => {
1167
+ selector = cond2?.rawValue ?? cond2?.raw;
1168
+ return `${selector} {
1169
+ ${acc}
1167
1170
  }`;
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);
1171
+ }).otherwise((cond2) => {
1172
+ if (!cond2)
1173
+ return acc;
1174
+ throw new Error(getConditionMessage(cond2.raw));
1175
+ });
1176
+ },
1177
+ allAtRules ? `${root} {
1178
+ ${css3}
1179
+ }` : css3
1180
+ );
1181
+ if (result) {
1182
+ results.push(result);
1176
1183
  }
1177
1184
  }
1178
1185
  }
1179
1186
  const css2 = results.join("\n\n") + "\n\n";
1180
- return `@layer tokens {
1187
+ return (0, import_core2.prettifyCss)(`@layer tokens {
1181
1188
  ${css2}
1182
1189
  }
1183
- `;
1190
+ `);
1184
1191
  }
1185
1192
 
1186
1193
  // src/generators/token-dts.ts
package/dist/index.mjs CHANGED
@@ -1077,13 +1077,13 @@ function generateReset() {
1077
1077
  }
1078
1078
 
1079
1079
  // src/generators/token-css.ts
1080
- import { toCss, toKeyframeCss } from "@pandacss/core";
1080
+ import { prettifyCss, toCss, toKeyframeCss } from "@pandacss/core";
1081
1081
  import { outdent as outdent18 } from "outdent";
1082
- import { match as match5, P } from "ts-pattern";
1082
+ import { match as match5 } from "ts-pattern";
1083
1083
  function generateKeyframes(keyframes) {
1084
- if (keyframes) {
1085
- return toKeyframeCss(keyframes);
1086
- }
1084
+ if (!keyframes)
1085
+ return;
1086
+ return toKeyframeCss(keyframes);
1087
1087
  }
1088
1088
  var getConditionMessage = (value) => outdent18`
1089
1089
  It seems you provided an invalid condition for semantic tokens.
@@ -1105,37 +1105,44 @@ function generateTokenCss(ctx, varRoot) {
1105
1105
  const { css: css3 } = toCss({ [root]: varsObj });
1106
1106
  results.push(css3);
1107
1107
  } 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};
1108
+ const keys = key.split(":");
1109
+ const { css: css3 } = toCss(varsObj);
1110
+ const sorted = conditions.sort(keys);
1111
+ const allAtRules = sorted.every(({ type }) => type === "at-rule");
1112
+ const result = sorted.reduce(
1113
+ (acc, cond, index, conds) => {
1114
+ let selector;
1115
+ return match5(cond).with({ type: "parent-nesting" }, (cond2) => {
1116
+ selector = cond2.value.replace(/\s&/g, "");
1117
+ const merge = conds[index - 1]?.type === "parent-nesting";
1118
+ return merge ? `${selector}${acc}` : `${selector} {
1119
+ ${acc}
1114
1120
  }`;
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
- }
1121
+ }).with({ type: "at-rule" }, (cond2) => {
1122
+ selector = cond2?.rawValue ?? cond2?.raw;
1123
+ return `${selector} {
1124
+ ${acc}
1122
1125
  }`;
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);
1126
+ }).otherwise((cond2) => {
1127
+ if (!cond2)
1128
+ return acc;
1129
+ throw new Error(getConditionMessage(cond2.raw));
1130
+ });
1131
+ },
1132
+ allAtRules ? `${root} {
1133
+ ${css3}
1134
+ }` : css3
1135
+ );
1136
+ if (result) {
1137
+ results.push(result);
1131
1138
  }
1132
1139
  }
1133
1140
  }
1134
1141
  const css2 = results.join("\n\n") + "\n\n";
1135
- return `@layer tokens {
1142
+ return prettifyCss(`@layer tokens {
1136
1143
  ${css2}
1137
1144
  }
1138
- `;
1145
+ `);
1139
1146
  }
1140
1147
 
1141
1148
  // src/generators/token-dts.ts
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-20221126091729",
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-20221126091729",
34
+ "@pandacss/is-valid-prop": "0.0.0-dev-20221126091729",
35
+ "@pandacss/error": "0.0.0-dev-20221126091729",
36
+ "@pandacss/parser": "0.0.0-dev-20221126091729",
37
+ "@pandacss/shared": "0.0.0-dev-20221126091729",
38
+ "@pandacss/token-dictionary": "0.0.0-dev-20221126091729",
39
+ "@pandacss/logger": "0.0.0-dev-20221126091729",
40
+ "@pandacss/core": "0.0.0-dev-20221126091729",
41
+ "@pandacss/config": "0.0.0-dev-20221126091729"
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-20221126091729"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",