@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 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
- if (values.every(isBooleanValue))
811
- return `${key}: boolean`;
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1071
+ const mergedProps = { ref, ...restProps, css: styleProps }
1057
1072
 
1058
- return h(Comp, { ref, ...restProps })
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1398
+ const mergedProps = { ref, ...restProps, css: styleProps }
1384
1399
 
1385
- return h(Comp, restProps)
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1732
+ const mergedProps = { ref, ...restProps, css: styleProps }
1718
1733
 
1719
- return createElement(Comp, { ref, ...restProps })
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 styleProps = ${styleFnName}(patternProps)
2094
- const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
2108
+ const cssProps = createMemo(() => {
2109
+ const styleProps = ${styleFnName}(patternProps)
2110
+ return { css: styleProps }
2111
+ })
2095
2112
 
2096
- return createComponent(Comp, restProps)
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 Comp = computed(() => {
2569
+ const cssProps = computed(() => {
2550
2570
  const styleProps = ${styleFnName}(props)
2551
- return ${factoryName}("${jsxElement}", { base: styleProps })
2571
+ return { css: styleProps }
2552
2572
  })
2553
2573
 
2554
2574
  return () => {
2555
- return h(Comp.value, attrs, slots)
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: rewriteImports(recipe_d_ts_default.content),
3563
- pattern: rewriteImports(pattern_d_ts_default.content.replace("../tokens", "../tokens/index")),
3564
- parts: rewriteImports(parts_d_ts_default.content),
3565
- composition: rewriteImports(composition_d_ts_default.content),
3566
- selectors: rewriteImports(selectors_d_ts_default.content)
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 = StyleProps & WithCss";
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: rewriteImports(
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
- if (values.every(isBooleanValue))
775
- return `${key}: boolean`;
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1035
+ const mergedProps = { ref, ...restProps, css: styleProps }
1021
1036
 
1022
- return h(Comp, { ref, ...restProps })
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1362
+ const mergedProps = { ref, ...restProps, css: styleProps }
1348
1363
 
1349
- return h(Comp, restProps)
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 Comp = ${factoryName}("${jsxElement}", { base: styleProps })
1696
+ const mergedProps = { ref, ...restProps, css: styleProps }
1682
1697
 
1683
- return createElement(Comp, { ref, ...restProps })
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 styleProps = ${styleFnName}(patternProps)
2058
- const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
2072
+ const cssProps = createMemo(() => {
2073
+ const styleProps = ${styleFnName}(patternProps)
2074
+ return { css: styleProps }
2075
+ })
2059
2076
 
2060
- return createComponent(Comp, restProps)
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 Comp = computed(() => {
2533
+ const cssProps = computed(() => {
2514
2534
  const styleProps = ${styleFnName}(props)
2515
- return ${factoryName}("${jsxElement}", { base: styleProps })
2535
+ return { css: styleProps }
2516
2536
  })
2517
2537
 
2518
2538
  return () => {
2519
- return h(Comp.value, attrs, slots)
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: rewriteImports(recipe_d_ts_default.content),
3527
- pattern: rewriteImports(pattern_d_ts_default.content.replace("../tokens", "../tokens/index")),
3528
- parts: rewriteImports(parts_d_ts_default.content),
3529
- composition: rewriteImports(composition_d_ts_default.content),
3530
- selectors: rewriteImports(selectors_d_ts_default.content)
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 = StyleProps & WithCss";
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: rewriteImports(
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.40.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.40.0",
41
- "@pandacss/is-valid-prop": "^0.40.0",
42
- "@pandacss/logger": "0.40.0",
43
- "@pandacss/shared": "0.40.0",
44
- "@pandacss/token-dictionary": "0.40.0",
45
- "@pandacss/types": "0.40.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"