@pandacss/generator 0.40.0 → 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 +44 -25
- package/dist/index.mjs +45 -26
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -477,7 +477,7 @@ function generateIsValidProp(ctx) {
|
|
|
477
477
|
let content = is_valid_prop_mjs_default.content;
|
|
478
478
|
content = content.replace(
|
|
479
479
|
'var userGeneratedStr = "";',
|
|
480
|
-
`var userGeneratedStr = "${(0, import_ts_pattern.match)(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
480
|
+
`var userGeneratedStr = "${(0, import_ts_pattern.match)(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties).join(",")).with("minimal", () => "css").with("none", () => "css").exhaustive()}"`
|
|
481
481
|
);
|
|
482
482
|
content = content.replace(memoFnDeclarationRegex, "var cssPropertySelectorRegex");
|
|
483
483
|
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
@@ -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
|
|
|
@@ -1053,9 +1068,9 @@ function generatePreactJsxPattern(ctx, filters) {
|
|
|
1053
1068
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1054
1069
|
|
|
1055
1070
|
const styleProps = ${styleFnName}(patternProps)
|
|
1056
|
-
const
|
|
1071
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1057
1072
|
|
|
1058
|
-
return h(
|
|
1073
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1059
1074
|
`
|
|
1060
1075
|
).with(
|
|
1061
1076
|
"minimal",
|
|
@@ -1380,9 +1395,9 @@ function generateQwikJsxPattern(ctx, filters) {
|
|
|
1380
1395
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1381
1396
|
|
|
1382
1397
|
const styleProps = ${styleFnName}(patternProps)
|
|
1383
|
-
const
|
|
1398
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1384
1399
|
|
|
1385
|
-
return h(
|
|
1400
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1386
1401
|
`
|
|
1387
1402
|
).with(
|
|
1388
1403
|
"minimal",
|
|
@@ -1714,9 +1729,9 @@ function generateReactJsxPattern(ctx, filters) {
|
|
|
1714
1729
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1715
1730
|
|
|
1716
1731
|
const styleProps = ${styleFnName}(patternProps)
|
|
1717
|
-
const
|
|
1732
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1718
1733
|
|
|
1719
|
-
return createElement(
|
|
1734
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1720
1735
|
`
|
|
1721
1736
|
).with(
|
|
1722
1737
|
"minimal",
|
|
@@ -2090,10 +2105,14 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2090
2105
|
() => import_outdent30.outdent`
|
|
2091
2106
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2092
2107
|
|
|
2093
|
-
const
|
|
2094
|
-
|
|
2108
|
+
const cssProps = createMemo(() => {
|
|
2109
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2110
|
+
return { css: styleProps }
|
|
2111
|
+
})
|
|
2095
2112
|
|
|
2096
|
-
|
|
2113
|
+
const mergedProps = mergeProps(restProps, cssProps)
|
|
2114
|
+
|
|
2115
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2097
2116
|
`
|
|
2098
2117
|
).with(
|
|
2099
2118
|
"minimal",
|
|
@@ -2104,6 +2123,7 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2104
2123
|
const styleProps = ${styleFnName}(patternProps)
|
|
2105
2124
|
return { css: mergeCss(styleProps, props.css) }
|
|
2106
2125
|
})
|
|
2126
|
+
|
|
2107
2127
|
const mergedProps = mergeProps(restProps, cssProps)
|
|
2108
2128
|
|
|
2109
2129
|
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
@@ -2546,13 +2566,14 @@ function generateVueJsxPattern(ctx, filters) {
|
|
|
2546
2566
|
${(0, import_ts_pattern9.match)(jsxStyleProps2).with(
|
|
2547
2567
|
"none",
|
|
2548
2568
|
() => import_outdent36.outdent`
|
|
2549
|
-
const
|
|
2569
|
+
const cssProps = computed(() => {
|
|
2550
2570
|
const styleProps = ${styleFnName}(props)
|
|
2551
|
-
return
|
|
2571
|
+
return { css: styleProps }
|
|
2552
2572
|
})
|
|
2553
2573
|
|
|
2554
2574
|
return () => {
|
|
2555
|
-
|
|
2575
|
+
const mergedProps = { ...attrs, ...cssProps.value }
|
|
2576
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2556
2577
|
}
|
|
2557
2578
|
`
|
|
2558
2579
|
).with(
|
|
@@ -3555,22 +3576,20 @@ var system_types_d_ts_default = {
|
|
|
3555
3576
|
|
|
3556
3577
|
// src/artifacts/types/generated.ts
|
|
3557
3578
|
function getGeneratedTypes(ctx) {
|
|
3558
|
-
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3559
3579
|
return {
|
|
3560
3580
|
cssType: csstype_d_ts_default.content,
|
|
3561
3581
|
static: static_css_d_ts_default.content,
|
|
3562
|
-
recipe:
|
|
3563
|
-
pattern:
|
|
3564
|
-
parts:
|
|
3565
|
-
composition:
|
|
3566
|
-
selectors:
|
|
3582
|
+
recipe: ctx.file.rewriteTypeImport(recipe_d_ts_default.content),
|
|
3583
|
+
pattern: ctx.file.rewriteTypeImport(pattern_d_ts_default.content.replace("../tokens", "../tokens/index")),
|
|
3584
|
+
parts: ctx.file.rewriteTypeImport(parts_d_ts_default.content),
|
|
3585
|
+
composition: ctx.file.rewriteTypeImport(composition_d_ts_default.content),
|
|
3586
|
+
selectors: ctx.file.rewriteTypeImport(selectors_d_ts_default.content)
|
|
3567
3587
|
};
|
|
3568
3588
|
}
|
|
3569
|
-
var jsxStyleProps = "export type JsxStyleProps =
|
|
3589
|
+
var jsxStyleProps = "export type JsxStyleProps = SystemStyleObject & WithCss";
|
|
3570
3590
|
function getGeneratedSystemTypes(ctx) {
|
|
3571
|
-
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3572
3591
|
return {
|
|
3573
|
-
system:
|
|
3592
|
+
system: ctx.file.rewriteTypeImport(
|
|
3574
3593
|
(0, import_ts_pattern10.match)(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
3575
3594
|
"minimal",
|
|
3576
3595
|
() => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
|
package/dist/index.mjs
CHANGED
|
@@ -441,7 +441,7 @@ function generateIsValidProp(ctx) {
|
|
|
441
441
|
let content = is_valid_prop_mjs_default.content;
|
|
442
442
|
content = content.replace(
|
|
443
443
|
'var userGeneratedStr = "";',
|
|
444
|
-
`var userGeneratedStr = "${match(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
444
|
+
`var userGeneratedStr = "${match(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties).join(",")).with("minimal", () => "css").with("none", () => "css").exhaustive()}"`
|
|
445
445
|
);
|
|
446
446
|
content = content.replace(memoFnDeclarationRegex, "var cssPropertySelectorRegex");
|
|
447
447
|
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
@@ -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
|
|
|
@@ -1017,9 +1032,9 @@ function generatePreactJsxPattern(ctx, filters) {
|
|
|
1017
1032
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1018
1033
|
|
|
1019
1034
|
const styleProps = ${styleFnName}(patternProps)
|
|
1020
|
-
const
|
|
1035
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1021
1036
|
|
|
1022
|
-
return h(
|
|
1037
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1023
1038
|
`
|
|
1024
1039
|
).with(
|
|
1025
1040
|
"minimal",
|
|
@@ -1344,9 +1359,9 @@ function generateQwikJsxPattern(ctx, filters) {
|
|
|
1344
1359
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1345
1360
|
|
|
1346
1361
|
const styleProps = ${styleFnName}(patternProps)
|
|
1347
|
-
const
|
|
1362
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1348
1363
|
|
|
1349
|
-
return h(
|
|
1364
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1350
1365
|
`
|
|
1351
1366
|
).with(
|
|
1352
1367
|
"minimal",
|
|
@@ -1678,9 +1693,9 @@ function generateReactJsxPattern(ctx, filters) {
|
|
|
1678
1693
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1679
1694
|
|
|
1680
1695
|
const styleProps = ${styleFnName}(patternProps)
|
|
1681
|
-
const
|
|
1696
|
+
const mergedProps = { ref, ...restProps, css: styleProps }
|
|
1682
1697
|
|
|
1683
|
-
return createElement(
|
|
1698
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1684
1699
|
`
|
|
1685
1700
|
).with(
|
|
1686
1701
|
"minimal",
|
|
@@ -2054,10 +2069,14 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2054
2069
|
() => outdent30`
|
|
2055
2070
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2056
2071
|
|
|
2057
|
-
const
|
|
2058
|
-
|
|
2072
|
+
const cssProps = createMemo(() => {
|
|
2073
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2074
|
+
return { css: styleProps }
|
|
2075
|
+
})
|
|
2059
2076
|
|
|
2060
|
-
|
|
2077
|
+
const mergedProps = mergeProps(restProps, cssProps)
|
|
2078
|
+
|
|
2079
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2061
2080
|
`
|
|
2062
2081
|
).with(
|
|
2063
2082
|
"minimal",
|
|
@@ -2068,6 +2087,7 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2068
2087
|
const styleProps = ${styleFnName}(patternProps)
|
|
2069
2088
|
return { css: mergeCss(styleProps, props.css) }
|
|
2070
2089
|
})
|
|
2090
|
+
|
|
2071
2091
|
const mergedProps = mergeProps(restProps, cssProps)
|
|
2072
2092
|
|
|
2073
2093
|
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
@@ -2510,13 +2530,14 @@ function generateVueJsxPattern(ctx, filters) {
|
|
|
2510
2530
|
${match9(jsxStyleProps2).with(
|
|
2511
2531
|
"none",
|
|
2512
2532
|
() => outdent36`
|
|
2513
|
-
const
|
|
2533
|
+
const cssProps = computed(() => {
|
|
2514
2534
|
const styleProps = ${styleFnName}(props)
|
|
2515
|
-
return
|
|
2535
|
+
return { css: styleProps }
|
|
2516
2536
|
})
|
|
2517
2537
|
|
|
2518
2538
|
return () => {
|
|
2519
|
-
|
|
2539
|
+
const mergedProps = { ...attrs, ...cssProps.value }
|
|
2540
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2520
2541
|
}
|
|
2521
2542
|
`
|
|
2522
2543
|
).with(
|
|
@@ -3519,22 +3540,20 @@ var system_types_d_ts_default = {
|
|
|
3519
3540
|
|
|
3520
3541
|
// src/artifacts/types/generated.ts
|
|
3521
3542
|
function getGeneratedTypes(ctx) {
|
|
3522
|
-
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3523
3543
|
return {
|
|
3524
3544
|
cssType: csstype_d_ts_default.content,
|
|
3525
3545
|
static: static_css_d_ts_default.content,
|
|
3526
|
-
recipe:
|
|
3527
|
-
pattern:
|
|
3528
|
-
parts:
|
|
3529
|
-
composition:
|
|
3530
|
-
selectors:
|
|
3546
|
+
recipe: ctx.file.rewriteTypeImport(recipe_d_ts_default.content),
|
|
3547
|
+
pattern: ctx.file.rewriteTypeImport(pattern_d_ts_default.content.replace("../tokens", "../tokens/index")),
|
|
3548
|
+
parts: ctx.file.rewriteTypeImport(parts_d_ts_default.content),
|
|
3549
|
+
composition: ctx.file.rewriteTypeImport(composition_d_ts_default.content),
|
|
3550
|
+
selectors: ctx.file.rewriteTypeImport(selectors_d_ts_default.content)
|
|
3531
3551
|
};
|
|
3532
3552
|
}
|
|
3533
|
-
var jsxStyleProps = "export type JsxStyleProps =
|
|
3553
|
+
var jsxStyleProps = "export type JsxStyleProps = SystemStyleObject & WithCss";
|
|
3534
3554
|
function getGeneratedSystemTypes(ctx) {
|
|
3535
|
-
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3536
3555
|
return {
|
|
3537
|
-
system:
|
|
3556
|
+
system: ctx.file.rewriteTypeImport(
|
|
3538
3557
|
match10(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
3539
3558
|
"minimal",
|
|
3540
3559
|
() => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
|
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"
|