@pandacss/generator 0.0.0-dev-20240226215512 → 0.0.0-dev-20240227001356

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ function generateConditions(ctx) {
88
88
  export interface Conditions {
89
89
  ${keys.map(
90
90
  (key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */
91
- ` : ctx.conditions.get(key) ? `/** \`${[].concat(ctx.conditions.get(key)).join(" ")}\` */
91
+ ` : ctx.conditions.get(key) ? `/** \`${[].concat(ctx.conditions.get(key) ?? "").join(" ")}\` */
92
92
  ` : ""} ${JSON.stringify(key)}: string`
93
93
  ).join("\n")}
94
94
  }
@@ -3636,8 +3636,13 @@ var import_core3 = require("@pandacss/core");
3636
3636
  var import_shared4 = require("@pandacss/shared");
3637
3637
  function generateResetCss(ctx, sheet) {
3638
3638
  const { preflight } = ctx.config;
3639
- const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
3640
- const selector = scope ? `${scope} ` : "";
3639
+ const { scope = "", level = "parent" } = (0, import_shared4.isObject)(preflight) ? preflight : {};
3640
+ let selector = "";
3641
+ if (scope && level === "parent") {
3642
+ selector = `${scope} `;
3643
+ } else if (scope && level === "element") {
3644
+ selector = `&${scope}`;
3645
+ }
3641
3646
  const scoped = {
3642
3647
  "*": { margin: "0px", padding: "0px", font: "inherit" },
3643
3648
  "*, *::before, *::after": {
@@ -3728,7 +3733,10 @@ function generateResetCss(ctx, sheet) {
3728
3733
  fontFamily: "var(--global-font-body, var(--font-fallback))"
3729
3734
  }
3730
3735
  };
3731
- if (selector) {
3736
+ if (level === "element") {
3737
+ const modified = (0, import_shared4.mapEntries)(scoped, (k, v) => [k, { [selector]: v }]);
3738
+ Object.assign(reset, modified);
3739
+ } else if (selector) {
3732
3740
  reset[selector] = scoped;
3733
3741
  } else {
3734
3742
  Object.assign(reset, scoped);
@@ -3773,9 +3781,13 @@ function generateTokenCss(ctx, sheet) {
3773
3781
  const css2 = (0, import_core4.stringify)(varsObj);
3774
3782
  const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
3775
3783
  const lastSegment = Array.isArray(condition) ? condition.at(-1) : condition;
3784
+ if (!lastSegment)
3785
+ return;
3776
3786
  const parent = (0, import_core4.extractParentSelectors)(lastSegment);
3777
3787
  return parent ? `&${parent}` : lastSegment;
3778
- });
3788
+ }).filter(Boolean);
3789
+ if (!mapped.length)
3790
+ return;
3779
3791
  const rule = getDeepestRule(root, mapped);
3780
3792
  if (!rule)
3781
3793
  continue;
package/dist/index.mjs CHANGED
@@ -52,7 +52,7 @@ function generateConditions(ctx) {
52
52
  export interface Conditions {
53
53
  ${keys.map(
54
54
  (key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */
55
- ` : ctx.conditions.get(key) ? `/** \`${[].concat(ctx.conditions.get(key)).join(" ")}\` */
55
+ ` : ctx.conditions.get(key) ? `/** \`${[].concat(ctx.conditions.get(key) ?? "").join(" ")}\` */
56
56
  ` : ""} ${JSON.stringify(key)}: string`
57
57
  ).join("\n")}
58
58
  }
@@ -3597,11 +3597,16 @@ var generateParserCss = (ctx, decoder) => {
3597
3597
 
3598
3598
  // src/artifacts/css/reset-css.ts
3599
3599
  import "@pandacss/core";
3600
- import { isObject } from "@pandacss/shared";
3600
+ import { isObject, mapEntries } from "@pandacss/shared";
3601
3601
  function generateResetCss(ctx, sheet) {
3602
3602
  const { preflight } = ctx.config;
3603
- const scope = isObject(preflight) ? preflight.scope : void 0;
3604
- const selector = scope ? `${scope} ` : "";
3603
+ const { scope = "", level = "parent" } = isObject(preflight) ? preflight : {};
3604
+ let selector = "";
3605
+ if (scope && level === "parent") {
3606
+ selector = `${scope} `;
3607
+ } else if (scope && level === "element") {
3608
+ selector = `&${scope}`;
3609
+ }
3605
3610
  const scoped = {
3606
3611
  "*": { margin: "0px", padding: "0px", font: "inherit" },
3607
3612
  "*, *::before, *::after": {
@@ -3692,7 +3697,10 @@ function generateResetCss(ctx, sheet) {
3692
3697
  fontFamily: "var(--global-font-body, var(--font-fallback))"
3693
3698
  }
3694
3699
  };
3695
- if (selector) {
3700
+ if (level === "element") {
3701
+ const modified = mapEntries(scoped, (k, v) => [k, { [selector]: v }]);
3702
+ Object.assign(reset, modified);
3703
+ } else if (selector) {
3696
3704
  reset[selector] = scoped;
3697
3705
  } else {
3698
3706
  Object.assign(reset, scoped);
@@ -3737,9 +3745,13 @@ function generateTokenCss(ctx, sheet) {
3737
3745
  const css2 = stringify4(varsObj);
3738
3746
  const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
3739
3747
  const lastSegment = Array.isArray(condition) ? condition.at(-1) : condition;
3748
+ if (!lastSegment)
3749
+ return;
3740
3750
  const parent = extractParentSelectors(lastSegment);
3741
3751
  return parent ? `&${parent}` : lastSegment;
3742
- });
3752
+ }).filter(Boolean);
3753
+ if (!mapped.length)
3754
+ return;
3743
3755
  const rule = getDeepestRule(root, mapped);
3744
3756
  if (!rule)
3745
3757
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20240226215512",
3
+ "version": "0.0.0-dev-20240227001356",
4
4
  "description": "The css generator for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -37,12 +37,12 @@
37
37
  "pluralize": "8.0.0",
38
38
  "postcss": "8.4.35",
39
39
  "ts-pattern": "5.0.8",
40
- "@pandacss/core": "0.0.0-dev-20240226215512",
41
- "@pandacss/is-valid-prop": "^0.0.0-dev-20240226215512",
42
- "@pandacss/logger": "0.0.0-dev-20240226215512",
43
- "@pandacss/shared": "0.0.0-dev-20240226215512",
44
- "@pandacss/token-dictionary": "0.0.0-dev-20240226215512",
45
- "@pandacss/types": "0.0.0-dev-20240226215512"
40
+ "@pandacss/core": "0.0.0-dev-20240227001356",
41
+ "@pandacss/is-valid-prop": "^0.0.0-dev-20240227001356",
42
+ "@pandacss/logger": "0.0.0-dev-20240227001356",
43
+ "@pandacss/shared": "0.0.0-dev-20240227001356",
44
+ "@pandacss/token-dictionary": "0.0.0-dev-20240227001356",
45
+ "@pandacss/types": "0.0.0-dev-20240227001356"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/pluralize": "0.0.33"