@pandacss/generator 0.40.1 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -70
- package/dist/index.mjs +24 -71
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -634,6 +634,11 @@ var import_outdent11 = require("outdent");
|
|
|
634
634
|
var import_ts_pattern4 = require("ts-pattern");
|
|
635
635
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
636
636
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
637
|
+
var hasOwn = (obj, key) => {
|
|
638
|
+
if (!obj)
|
|
639
|
+
return false;
|
|
640
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
641
|
+
};
|
|
637
642
|
function generateCreateRecipe(ctx) {
|
|
638
643
|
const { conditions, recipes, prefix, hash, utility } = ctx;
|
|
639
644
|
if (recipes.isEmpty())
|
|
@@ -736,6 +741,17 @@ function generateRecipes(ctx, filters) {
|
|
|
736
741
|
return details.map((recipe) => {
|
|
737
742
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
738
743
|
const { description, defaultVariants, compoundVariants, deprecated } = config;
|
|
744
|
+
const getDefaultValueJsDoc = (key) => {
|
|
745
|
+
if (!hasOwn(defaultVariants, key))
|
|
746
|
+
return;
|
|
747
|
+
let defaultValue = defaultVariants[key];
|
|
748
|
+
if ((0, import_shared2.isBoolean)(defaultValue)) {
|
|
749
|
+
defaultValue = defaultValue ? `true` : `false`;
|
|
750
|
+
} else {
|
|
751
|
+
defaultValue = JSON.stringify(defaultValue);
|
|
752
|
+
}
|
|
753
|
+
return ctx.file.jsDocComment("", { default: defaultValue });
|
|
754
|
+
};
|
|
739
755
|
const jsCode = (0, import_ts_pattern4.match)(config).when(
|
|
740
756
|
import_core.Recipes.isSlotRecipeConfig,
|
|
741
757
|
(config2) => import_outdent11.outdent`
|
|
@@ -807,9 +823,8 @@ function generateRecipes(ctx, filters) {
|
|
|
807
823
|
interface ${upperName}Variant {
|
|
808
824
|
${Object.keys(variantKeyMap).map((key) => {
|
|
809
825
|
const values = variantKeyMap[key];
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
return `${key}: ${(0, import_shared2.unionType)(values)}`;
|
|
826
|
+
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${(0, import_shared2.unionType)(values)}`;
|
|
827
|
+
return [getDefaultValueJsDoc(key), valueStr].filter(Boolean).join("\n");
|
|
813
828
|
}).join("\n")}
|
|
814
829
|
}
|
|
815
830
|
|
|
@@ -2776,56 +2791,6 @@ function generateJsxPatterns(ctx, filters) {
|
|
|
2776
2791
|
return patternMap[ctx.jsx.framework](ctx, filters);
|
|
2777
2792
|
}
|
|
2778
2793
|
|
|
2779
|
-
// src/artifacts/pkg-json.ts
|
|
2780
|
-
function generatePackageJson(ctx) {
|
|
2781
|
-
const {
|
|
2782
|
-
config: { outdir }
|
|
2783
|
-
} = ctx;
|
|
2784
|
-
const pkg = {
|
|
2785
|
-
name: outdir,
|
|
2786
|
-
description: "This package is auto-generated by Panda CSS",
|
|
2787
|
-
version: `0.0.0-${performance.now()}`,
|
|
2788
|
-
type: "module",
|
|
2789
|
-
exports: {
|
|
2790
|
-
"./css": {
|
|
2791
|
-
types: ctx.file.extDts("./css/index"),
|
|
2792
|
-
require: ctx.file.ext(`./css/index`),
|
|
2793
|
-
import: ctx.file.ext(`./css/index`)
|
|
2794
|
-
},
|
|
2795
|
-
"./jsx": {
|
|
2796
|
-
types: ctx.file.extDts("./jsx/index"),
|
|
2797
|
-
require: ctx.file.ext(`./jsx/index`),
|
|
2798
|
-
import: ctx.file.ext(`./jsx/index`)
|
|
2799
|
-
},
|
|
2800
|
-
"./patterns": {
|
|
2801
|
-
types: ctx.file.extDts("./patterns/index"),
|
|
2802
|
-
require: ctx.file.ext(`./patterns/index`),
|
|
2803
|
-
import: ctx.file.ext(`./patterns/index`)
|
|
2804
|
-
},
|
|
2805
|
-
"./recipes": {
|
|
2806
|
-
types: ctx.file.extDts("./recipes/index"),
|
|
2807
|
-
require: ctx.file.ext(`./recipes/index`),
|
|
2808
|
-
import: ctx.file.ext(`./recipes/index`)
|
|
2809
|
-
},
|
|
2810
|
-
"./themes": {
|
|
2811
|
-
types: ctx.file.extDts("./themes/index"),
|
|
2812
|
-
require: ctx.file.ext(`./themes/index`),
|
|
2813
|
-
import: ctx.file.ext(`./themes/index`)
|
|
2814
|
-
},
|
|
2815
|
-
"./tokens": {
|
|
2816
|
-
types: ctx.file.extDts("./tokens/index"),
|
|
2817
|
-
require: ctx.file.ext(`./tokens/index`),
|
|
2818
|
-
import: ctx.file.ext(`./tokens/index`)
|
|
2819
|
-
},
|
|
2820
|
-
"./types": {
|
|
2821
|
-
types: ctx.file.extDts("./types/index")
|
|
2822
|
-
},
|
|
2823
|
-
"./styles.css": "./styles.css"
|
|
2824
|
-
}
|
|
2825
|
-
};
|
|
2826
|
-
return JSON.stringify(pkg, null, 2);
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
2794
|
// src/artifacts/types/generated.ts
|
|
2830
2795
|
var import_ts_pattern10 = require("ts-pattern");
|
|
2831
2796
|
|
|
@@ -4415,14 +4380,6 @@ function setupCssIndex(ctx) {
|
|
|
4415
4380
|
]
|
|
4416
4381
|
};
|
|
4417
4382
|
}
|
|
4418
|
-
function setupPackageJson(ctx) {
|
|
4419
|
-
if (!ctx.config.emitPackage)
|
|
4420
|
-
return;
|
|
4421
|
-
return {
|
|
4422
|
-
id: "package.json",
|
|
4423
|
-
files: [{ file: "package.json", code: generatePackageJson(ctx) }]
|
|
4424
|
-
};
|
|
4425
|
-
}
|
|
4426
4383
|
function setupThemes(ctx) {
|
|
4427
4384
|
const { themes } = ctx.config;
|
|
4428
4385
|
if (!themes)
|
|
@@ -4504,7 +4461,6 @@ var entries = [
|
|
|
4504
4461
|
["jsx-patterns", setupJsxPatterns],
|
|
4505
4462
|
["jsx-patterns-index", setupJsxPatternsIndex],
|
|
4506
4463
|
["css-index", setupCssIndex],
|
|
4507
|
-
["package.json", setupPackageJson],
|
|
4508
4464
|
["themes", setupThemes]
|
|
4509
4465
|
];
|
|
4510
4466
|
var getMatchingArtifacts = (ctx, filters) => {
|
|
@@ -4568,10 +4524,10 @@ var generateParserCss = (ctx, decoder) => {
|
|
|
4568
4524
|
if (!decoder)
|
|
4569
4525
|
return "";
|
|
4570
4526
|
const sheet = ctx.createSheet();
|
|
4571
|
-
const { minify
|
|
4527
|
+
const { minify } = ctx.config;
|
|
4572
4528
|
sheet.processDecoder(decoder);
|
|
4573
4529
|
try {
|
|
4574
|
-
const css = sheet.toCss({ minify
|
|
4530
|
+
const css = sheet.toCss({ minify });
|
|
4575
4531
|
return css;
|
|
4576
4532
|
} catch (err) {
|
|
4577
4533
|
import_logger2.logger.error("serializer:css", "Failed to serialize CSS: " + err);
|
|
@@ -4741,8 +4697,8 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
4741
4697
|
const { config, staticCss } = ctx;
|
|
4742
4698
|
const engine = staticCss.process(ctx.config.staticCss ?? {}, sheet);
|
|
4743
4699
|
if (!sheet) {
|
|
4744
|
-
const {
|
|
4745
|
-
let css = engine.sheet.toCss({
|
|
4700
|
+
const { minify } = config;
|
|
4701
|
+
let css = engine.sheet.toCss({ minify });
|
|
4746
4702
|
if (ctx.hooks["cssgen:done"]) {
|
|
4747
4703
|
css = ctx.hooks["cssgen:done"]({ artifact: "static", content: css }) ?? css;
|
|
4748
4704
|
}
|
|
@@ -4785,10 +4741,7 @@ var Generator = class extends import_core5.Context {
|
|
|
4785
4741
|
};
|
|
4786
4742
|
getCss = (stylesheet) => {
|
|
4787
4743
|
const sheet = stylesheet ?? this.createSheet();
|
|
4788
|
-
let css = sheet.toCss({
|
|
4789
|
-
optimize: true,
|
|
4790
|
-
minify: this.config.minify
|
|
4791
|
-
});
|
|
4744
|
+
let css = sheet.toCss({ minify: this.config.minify });
|
|
4792
4745
|
if (this.hooks["cssgen:done"]) {
|
|
4793
4746
|
css = this.hooks["cssgen:done"]({ artifact: "styles.css", content: css }) ?? css;
|
|
4794
4747
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -593,11 +593,16 @@ defaultValues`)}
|
|
|
593
593
|
|
|
594
594
|
// src/artifacts/js/recipe.ts
|
|
595
595
|
import { Recipes } from "@pandacss/core";
|
|
596
|
-
import { unionType as unionType2 } from "@pandacss/shared";
|
|
596
|
+
import { isBoolean, unionType as unionType2 } from "@pandacss/shared";
|
|
597
597
|
import { outdent as outdent11 } from "outdent";
|
|
598
598
|
import { match as match4 } from "ts-pattern";
|
|
599
599
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
600
600
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
601
|
+
var hasOwn = (obj, key) => {
|
|
602
|
+
if (!obj)
|
|
603
|
+
return false;
|
|
604
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
605
|
+
};
|
|
601
606
|
function generateCreateRecipe(ctx) {
|
|
602
607
|
const { conditions, recipes, prefix, hash, utility } = ctx;
|
|
603
608
|
if (recipes.isEmpty())
|
|
@@ -700,6 +705,17 @@ function generateRecipes(ctx, filters) {
|
|
|
700
705
|
return details.map((recipe) => {
|
|
701
706
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
702
707
|
const { description, defaultVariants, compoundVariants, deprecated } = config;
|
|
708
|
+
const getDefaultValueJsDoc = (key) => {
|
|
709
|
+
if (!hasOwn(defaultVariants, key))
|
|
710
|
+
return;
|
|
711
|
+
let defaultValue = defaultVariants[key];
|
|
712
|
+
if (isBoolean(defaultValue)) {
|
|
713
|
+
defaultValue = defaultValue ? `true` : `false`;
|
|
714
|
+
} else {
|
|
715
|
+
defaultValue = JSON.stringify(defaultValue);
|
|
716
|
+
}
|
|
717
|
+
return ctx.file.jsDocComment("", { default: defaultValue });
|
|
718
|
+
};
|
|
703
719
|
const jsCode = match4(config).when(
|
|
704
720
|
Recipes.isSlotRecipeConfig,
|
|
705
721
|
(config2) => outdent11`
|
|
@@ -771,9 +787,8 @@ function generateRecipes(ctx, filters) {
|
|
|
771
787
|
interface ${upperName}Variant {
|
|
772
788
|
${Object.keys(variantKeyMap).map((key) => {
|
|
773
789
|
const values = variantKeyMap[key];
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
return `${key}: ${unionType2(values)}`;
|
|
790
|
+
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${unionType2(values)}`;
|
|
791
|
+
return [getDefaultValueJsDoc(key), valueStr].filter(Boolean).join("\n");
|
|
777
792
|
}).join("\n")}
|
|
778
793
|
}
|
|
779
794
|
|
|
@@ -2740,56 +2755,6 @@ function generateJsxPatterns(ctx, filters) {
|
|
|
2740
2755
|
return patternMap[ctx.jsx.framework](ctx, filters);
|
|
2741
2756
|
}
|
|
2742
2757
|
|
|
2743
|
-
// src/artifacts/pkg-json.ts
|
|
2744
|
-
function generatePackageJson(ctx) {
|
|
2745
|
-
const {
|
|
2746
|
-
config: { outdir }
|
|
2747
|
-
} = ctx;
|
|
2748
|
-
const pkg = {
|
|
2749
|
-
name: outdir,
|
|
2750
|
-
description: "This package is auto-generated by Panda CSS",
|
|
2751
|
-
version: `0.0.0-${performance.now()}`,
|
|
2752
|
-
type: "module",
|
|
2753
|
-
exports: {
|
|
2754
|
-
"./css": {
|
|
2755
|
-
types: ctx.file.extDts("./css/index"),
|
|
2756
|
-
require: ctx.file.ext(`./css/index`),
|
|
2757
|
-
import: ctx.file.ext(`./css/index`)
|
|
2758
|
-
},
|
|
2759
|
-
"./jsx": {
|
|
2760
|
-
types: ctx.file.extDts("./jsx/index"),
|
|
2761
|
-
require: ctx.file.ext(`./jsx/index`),
|
|
2762
|
-
import: ctx.file.ext(`./jsx/index`)
|
|
2763
|
-
},
|
|
2764
|
-
"./patterns": {
|
|
2765
|
-
types: ctx.file.extDts("./patterns/index"),
|
|
2766
|
-
require: ctx.file.ext(`./patterns/index`),
|
|
2767
|
-
import: ctx.file.ext(`./patterns/index`)
|
|
2768
|
-
},
|
|
2769
|
-
"./recipes": {
|
|
2770
|
-
types: ctx.file.extDts("./recipes/index"),
|
|
2771
|
-
require: ctx.file.ext(`./recipes/index`),
|
|
2772
|
-
import: ctx.file.ext(`./recipes/index`)
|
|
2773
|
-
},
|
|
2774
|
-
"./themes": {
|
|
2775
|
-
types: ctx.file.extDts("./themes/index"),
|
|
2776
|
-
require: ctx.file.ext(`./themes/index`),
|
|
2777
|
-
import: ctx.file.ext(`./themes/index`)
|
|
2778
|
-
},
|
|
2779
|
-
"./tokens": {
|
|
2780
|
-
types: ctx.file.extDts("./tokens/index"),
|
|
2781
|
-
require: ctx.file.ext(`./tokens/index`),
|
|
2782
|
-
import: ctx.file.ext(`./tokens/index`)
|
|
2783
|
-
},
|
|
2784
|
-
"./types": {
|
|
2785
|
-
types: ctx.file.extDts("./types/index")
|
|
2786
|
-
},
|
|
2787
|
-
"./styles.css": "./styles.css"
|
|
2788
|
-
}
|
|
2789
|
-
};
|
|
2790
|
-
return JSON.stringify(pkg, null, 2);
|
|
2791
|
-
}
|
|
2792
|
-
|
|
2793
2758
|
// src/artifacts/types/generated.ts
|
|
2794
2759
|
import { match as match10 } from "ts-pattern";
|
|
2795
2760
|
|
|
@@ -4379,14 +4344,6 @@ function setupCssIndex(ctx) {
|
|
|
4379
4344
|
]
|
|
4380
4345
|
};
|
|
4381
4346
|
}
|
|
4382
|
-
function setupPackageJson(ctx) {
|
|
4383
|
-
if (!ctx.config.emitPackage)
|
|
4384
|
-
return;
|
|
4385
|
-
return {
|
|
4386
|
-
id: "package.json",
|
|
4387
|
-
files: [{ file: "package.json", code: generatePackageJson(ctx) }]
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
4347
|
function setupThemes(ctx) {
|
|
4391
4348
|
const { themes } = ctx.config;
|
|
4392
4349
|
if (!themes)
|
|
@@ -4468,7 +4425,6 @@ var entries = [
|
|
|
4468
4425
|
["jsx-patterns", setupJsxPatterns],
|
|
4469
4426
|
["jsx-patterns-index", setupJsxPatternsIndex],
|
|
4470
4427
|
["css-index", setupCssIndex],
|
|
4471
|
-
["package.json", setupPackageJson],
|
|
4472
4428
|
["themes", setupThemes]
|
|
4473
4429
|
];
|
|
4474
4430
|
var getMatchingArtifacts = (ctx, filters) => {
|
|
@@ -4532,10 +4488,10 @@ var generateParserCss = (ctx, decoder) => {
|
|
|
4532
4488
|
if (!decoder)
|
|
4533
4489
|
return "";
|
|
4534
4490
|
const sheet = ctx.createSheet();
|
|
4535
|
-
const { minify
|
|
4491
|
+
const { minify } = ctx.config;
|
|
4536
4492
|
sheet.processDecoder(decoder);
|
|
4537
4493
|
try {
|
|
4538
|
-
const css = sheet.toCss({ minify
|
|
4494
|
+
const css = sheet.toCss({ minify });
|
|
4539
4495
|
return css;
|
|
4540
4496
|
} catch (err) {
|
|
4541
4497
|
logger2.error("serializer:css", "Failed to serialize CSS: " + err);
|
|
@@ -4705,8 +4661,8 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
4705
4661
|
const { config, staticCss } = ctx;
|
|
4706
4662
|
const engine = staticCss.process(ctx.config.staticCss ?? {}, sheet);
|
|
4707
4663
|
if (!sheet) {
|
|
4708
|
-
const {
|
|
4709
|
-
let css = engine.sheet.toCss({
|
|
4664
|
+
const { minify } = config;
|
|
4665
|
+
let css = engine.sheet.toCss({ minify });
|
|
4710
4666
|
if (ctx.hooks["cssgen:done"]) {
|
|
4711
4667
|
css = ctx.hooks["cssgen:done"]({ artifact: "static", content: css }) ?? css;
|
|
4712
4668
|
}
|
|
@@ -4749,10 +4705,7 @@ var Generator = class extends Context2 {
|
|
|
4749
4705
|
};
|
|
4750
4706
|
getCss = (stylesheet) => {
|
|
4751
4707
|
const sheet = stylesheet ?? this.createSheet();
|
|
4752
|
-
let css = sheet.toCss({
|
|
4753
|
-
optimize: true,
|
|
4754
|
-
minify: this.config.minify
|
|
4755
|
-
});
|
|
4708
|
+
let css = sheet.toCss({ minify: this.config.minify });
|
|
4756
4709
|
if (this.hooks["cssgen:done"]) {
|
|
4757
4710
|
css = this.hooks["cssgen:done"]({ artifact: "styles.css", content: css }) ?? css;
|
|
4758
4711
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
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.38",
|
|
39
39
|
"ts-pattern": "5.0.8",
|
|
40
|
-
"@pandacss/core": "0.
|
|
41
|
-
"@pandacss/is-valid-prop": "^0.
|
|
42
|
-
"@pandacss/logger": "0.
|
|
43
|
-
"@pandacss/shared": "0.
|
|
44
|
-
"@pandacss/token-dictionary": "0.
|
|
45
|
-
"@pandacss/types": "0.
|
|
40
|
+
"@pandacss/core": "0.42.0",
|
|
41
|
+
"@pandacss/is-valid-prop": "^0.42.0",
|
|
42
|
+
"@pandacss/logger": "0.42.0",
|
|
43
|
+
"@pandacss/shared": "0.42.0",
|
|
44
|
+
"@pandacss/token-dictionary": "0.42.0",
|
|
45
|
+
"@pandacss/types": "0.42.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/pluralize": "0.0.33"
|