@pandacss/generator 0.40.1 → 0.41.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 +18 -3
- package/dist/index.mjs +19 -4
- 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
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.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.41.0",
|
|
41
|
+
"@pandacss/is-valid-prop": "^0.41.0",
|
|
42
|
+
"@pandacss/logger": "0.41.0",
|
|
43
|
+
"@pandacss/shared": "0.41.0",
|
|
44
|
+
"@pandacss/token-dictionary": "0.41.0",
|
|
45
|
+
"@pandacss/types": "0.41.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/pluralize": "0.0.33"
|