@pandacss/generator 0.0.0-dev-20230212130534 → 0.0.0-dev-20230212134223

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
@@ -604,7 +604,7 @@ function generatePattern(ctx) {
604
604
  import type { Properties } from '../types/csstype'
605
605
  import type { Tokens } from '../types/token'
606
606
 
607
- export type ${(0, import_shared.capitalize)(name)}Properties = {
607
+ export type ${upperName}Properties = {
608
608
  ${Object.keys(properties ?? {}).map((key) => {
609
609
  const value = properties[key];
610
610
  return (0, import_ts_pattern.match)(value).with({ type: "property" }, (value2) => {
@@ -656,11 +656,13 @@ function generateRecipes(ctx) {
656
656
  } = ctx;
657
657
  if (recipes.isEmpty())
658
658
  return;
659
- const js = [
660
- import_outdent8.outdent`
659
+ const createRecipeFn = {
660
+ name: "create-recipe",
661
+ dts: "",
662
+ js: import_outdent8.outdent`
661
663
  ${ctx.file.import("createCss, withoutSpace, compact", "../helpers")}
662
664
 
663
- const createRecipe = (name, defaultVariants) => {
665
+ export const createRecipe = (name, defaultVariants) => {
664
666
  return (variants) => {
665
667
  const transform = (prop, value) => {
666
668
  if (value === '__ignore__') {
@@ -689,41 +691,43 @@ function generateRecipes(ctx) {
689
691
  }
690
692
  }
691
693
  `
692
- ];
693
- const dts = [
694
- import_outdent8.outdent`
695
- import type { ConditionalValue } from '../types'
696
- `
697
- ];
698
- recipes.details.forEach(({ config, upperName, variantKeyMap }) => {
699
- const { name, description, defaultVariants } = config;
700
- js.push(import_outdent8.outdent`
701
- export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
702
- ${name}.variants = ${JSON.stringify(variantKeyMap)}
703
- `);
704
- dts.push(import_outdent8.outdent`
705
- type ${upperName}Variant = {
706
- ${Object.keys(variantKeyMap).map((key) => `${key}: ${(0, import_shared2.unionType)(variantKeyMap[key])}`).join("\n")}
707
- }
708
-
709
- type ${upperName}VariantMap = {
710
- [key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
711
- }
712
-
713
- export type ${upperName}Variants = {
714
- [key in keyof ${upperName}Variant]?: ConditionalValue<${upperName}VariantMap[key]>
715
- }
716
-
717
- ${description ? `/** ${description} */` : ""}
718
- export declare function ${name}(variants?: ${upperName}Variants): string & {
719
- variants: ${upperName}VariantMap
720
- }
721
- `);
722
- });
723
- return {
724
- js: import_outdent8.outdent.string(js.join("\n\n")),
725
- dts: import_outdent8.outdent.string(dts.join("\n\n"))
726
694
  };
695
+ return [
696
+ createRecipeFn,
697
+ ...ctx.recipes.details.map((recipe) => {
698
+ const { config, upperName, variantKeyMap, dashName } = recipe;
699
+ const { name, description, defaultVariants } = config;
700
+ return {
701
+ name: dashName,
702
+ js: import_outdent8.outdent`
703
+ ${ctx.file.import("createRecipe", "./create-recipe")}
704
+
705
+ export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
706
+ ${name}.variants = ${JSON.stringify(variantKeyMap)}
707
+ `,
708
+ dts: import_outdent8.outdent`
709
+ import type { ConditionalValue } from '../types'
710
+
711
+ type ${upperName}Variant = {
712
+ ${Object.keys(variantKeyMap).map((key) => `${key}: ${(0, import_shared2.unionType)(variantKeyMap[key])}`).join("\n")}
713
+ }
714
+
715
+ type ${upperName}VariantMap = {
716
+ [key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
717
+ }
718
+
719
+ export type ${upperName}Variants = {
720
+ [key in keyof ${upperName}Variant]?: ConditionalValue<${upperName}Variant[key]>
721
+ }
722
+
723
+ ${description ? `/** ${description} */` : ""}
724
+ export declare function ${name}(variants?: ${upperName}Variants): string & {
725
+ variants: ${upperName}VariantMap
726
+ }
727
+ `
728
+ };
729
+ })
730
+ ];
727
731
  }
728
732
 
729
733
  // src/artifacts/js/token.ts
@@ -2053,14 +2057,21 @@ function setupCx(ctx) {
2053
2057
  };
2054
2058
  }
2055
2059
  function setupRecipes(ctx) {
2056
- const code = generateRecipes(ctx);
2057
- if (!code)
2060
+ const files = generateRecipes(ctx);
2061
+ if (!files)
2058
2062
  return;
2063
+ const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
2064
+ const index = {
2065
+ js: import_outdent29.default.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
2066
+ dts: import_outdent29.default.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
2067
+ };
2059
2068
  return {
2060
2069
  dir: ctx.paths.recipe,
2061
2070
  files: [
2062
- { file: ctx.file.ext("index"), code: code.js },
2063
- { file: "index.d.ts", code: code.dts }
2071
+ ...files.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
2072
+ ...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
2073
+ { file: ctx.file.ext("index"), code: index.js },
2074
+ { file: "index.d.ts", code: index.dts }
2064
2075
  ]
2065
2076
  };
2066
2077
  }
package/dist/index.mjs CHANGED
@@ -555,7 +555,7 @@ function generateisValidProp(ctx) {
555
555
  }
556
556
 
557
557
  // src/artifacts/js/pattern.ts
558
- import { capitalize, unionType } from "@pandacss/shared";
558
+ import { unionType } from "@pandacss/shared";
559
559
  import { stringify as stringify2 } from "javascript-stringify";
560
560
  import { outdent as outdent7 } from "outdent";
561
561
  import { match } from "ts-pattern";
@@ -573,7 +573,7 @@ function generatePattern(ctx) {
573
573
  import type { Properties } from '../types/csstype'
574
574
  import type { Tokens } from '../types/token'
575
575
 
576
- export type ${capitalize(name)}Properties = {
576
+ export type ${upperName}Properties = {
577
577
  ${Object.keys(properties ?? {}).map((key) => {
578
578
  const value = properties[key];
579
579
  return match(value).with({ type: "property" }, (value2) => {
@@ -625,11 +625,13 @@ function generateRecipes(ctx) {
625
625
  } = ctx;
626
626
  if (recipes.isEmpty())
627
627
  return;
628
- const js = [
629
- outdent8`
628
+ const createRecipeFn = {
629
+ name: "create-recipe",
630
+ dts: "",
631
+ js: outdent8`
630
632
  ${ctx.file.import("createCss, withoutSpace, compact", "../helpers")}
631
633
 
632
- const createRecipe = (name, defaultVariants) => {
634
+ export const createRecipe = (name, defaultVariants) => {
633
635
  return (variants) => {
634
636
  const transform = (prop, value) => {
635
637
  if (value === '__ignore__') {
@@ -658,41 +660,43 @@ function generateRecipes(ctx) {
658
660
  }
659
661
  }
660
662
  `
661
- ];
662
- const dts = [
663
- outdent8`
664
- import type { ConditionalValue } from '../types'
665
- `
666
- ];
667
- recipes.details.forEach(({ config, upperName, variantKeyMap }) => {
668
- const { name, description, defaultVariants } = config;
669
- js.push(outdent8`
670
- export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
671
- ${name}.variants = ${JSON.stringify(variantKeyMap)}
672
- `);
673
- dts.push(outdent8`
674
- type ${upperName}Variant = {
675
- ${Object.keys(variantKeyMap).map((key) => `${key}: ${unionType2(variantKeyMap[key])}`).join("\n")}
676
- }
677
-
678
- type ${upperName}VariantMap = {
679
- [key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
680
- }
681
-
682
- export type ${upperName}Variants = {
683
- [key in keyof ${upperName}Variant]?: ConditionalValue<${upperName}VariantMap[key]>
684
- }
685
-
686
- ${description ? `/** ${description} */` : ""}
687
- export declare function ${name}(variants?: ${upperName}Variants): string & {
688
- variants: ${upperName}VariantMap
689
- }
690
- `);
691
- });
692
- return {
693
- js: outdent8.string(js.join("\n\n")),
694
- dts: outdent8.string(dts.join("\n\n"))
695
663
  };
664
+ return [
665
+ createRecipeFn,
666
+ ...ctx.recipes.details.map((recipe) => {
667
+ const { config, upperName, variantKeyMap, dashName } = recipe;
668
+ const { name, description, defaultVariants } = config;
669
+ return {
670
+ name: dashName,
671
+ js: outdent8`
672
+ ${ctx.file.import("createRecipe", "./create-recipe")}
673
+
674
+ export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
675
+ ${name}.variants = ${JSON.stringify(variantKeyMap)}
676
+ `,
677
+ dts: outdent8`
678
+ import type { ConditionalValue } from '../types'
679
+
680
+ type ${upperName}Variant = {
681
+ ${Object.keys(variantKeyMap).map((key) => `${key}: ${unionType2(variantKeyMap[key])}`).join("\n")}
682
+ }
683
+
684
+ type ${upperName}VariantMap = {
685
+ [key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
686
+ }
687
+
688
+ export type ${upperName}Variants = {
689
+ [key in keyof ${upperName}Variant]?: ConditionalValue<${upperName}Variant[key]>
690
+ }
691
+
692
+ ${description ? `/** ${description} */` : ""}
693
+ export declare function ${name}(variants?: ${upperName}Variants): string & {
694
+ variants: ${upperName}VariantMap
695
+ }
696
+ `
697
+ };
698
+ })
699
+ ];
696
700
  }
697
701
 
698
702
  // src/artifacts/js/token.ts
@@ -1846,7 +1850,7 @@ function generateStyleProps(ctx) {
1846
1850
  }
1847
1851
 
1848
1852
  // src/artifacts/types/token-types.ts
1849
- import { capitalize as capitalize2, unionType as unionType3 } from "@pandacss/shared";
1853
+ import { capitalize, unionType as unionType3 } from "@pandacss/shared";
1850
1854
  import { outdent as outdent28 } from "outdent";
1851
1855
  import pluralize from "pluralize";
1852
1856
  function generateTokenTypes(ctx) {
@@ -1858,7 +1862,7 @@ function generateTokenTypes(ctx) {
1858
1862
  result.add("[token: string]: string");
1859
1863
  } else {
1860
1864
  for (const [key, value] of tokens.categoryMap.entries()) {
1861
- const typeName = capitalize2(pluralize.singular(key));
1865
+ const typeName = capitalize(pluralize.singular(key));
1862
1866
  set.add(`export type ${typeName} = ${unionType3(value.keys())}`);
1863
1867
  set.add(`export type ColorPalette = ${unionType3(Object.keys(tokens.colorPalettes))}`);
1864
1868
  result.add(` ${key}: ${typeName}`);
@@ -2022,14 +2026,21 @@ function setupCx(ctx) {
2022
2026
  };
2023
2027
  }
2024
2028
  function setupRecipes(ctx) {
2025
- const code = generateRecipes(ctx);
2026
- if (!code)
2029
+ const files = generateRecipes(ctx);
2030
+ if (!files)
2027
2031
  return;
2032
+ const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
2033
+ const index = {
2034
+ js: outdent29.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
2035
+ dts: outdent29.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
2036
+ };
2028
2037
  return {
2029
2038
  dir: ctx.paths.recipe,
2030
2039
  files: [
2031
- { file: ctx.file.ext("index"), code: code.js },
2032
- { file: "index.d.ts", code: code.dts }
2040
+ ...files.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
2041
+ ...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
2042
+ { file: ctx.file.ext("index"), code: index.js },
2043
+ { file: "index.d.ts", code: index.dts }
2033
2044
  ]
2034
2045
  };
2035
2046
  }
@@ -2287,14 +2298,14 @@ var getBaseEngine = (conf) => pipe2(
2287
2298
  );
2288
2299
 
2289
2300
  // src/engines/jsx.ts
2290
- import { capitalize as capitalize3 } from "@pandacss/shared";
2301
+ import { capitalize as capitalize2 } from "@pandacss/shared";
2291
2302
  var getJsxEngine = (config) => {
2292
2303
  const { jsxFactory, jsxFramework } = config;
2293
2304
  return {
2294
2305
  factoryName: jsxFactory,
2295
- upperName: capitalize3(jsxFactory),
2296
- typeName: `HTML${capitalize3(jsxFactory)}Props`,
2297
- componentName: `${capitalize3(jsxFactory)}Component`,
2306
+ upperName: capitalize2(jsxFactory),
2307
+ typeName: `HTML${capitalize2(jsxFactory)}Props`,
2308
+ componentName: `${capitalize2(jsxFactory)}Component`,
2298
2309
  framework: jsxFramework
2299
2310
  };
2300
2311
  };
@@ -2317,7 +2328,7 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
2317
2328
  };
2318
2329
 
2319
2330
  // src/engines/pattern.ts
2320
- import { capitalize as capitalize4, dashCase, mapObject as mapObject2, uncapitalize } from "@pandacss/shared";
2331
+ import { capitalize as capitalize3, dashCase, mapObject as mapObject2, uncapitalize } from "@pandacss/shared";
2321
2332
  import { Obj as Obj2, pipe as pipe3 } from "lil-fp";
2322
2333
  var helpers2 = { map: mapObject2 };
2323
2334
  var getPatternEngine = (config) => {
@@ -2332,7 +2343,7 @@ var getPatternEngine = (config) => {
2332
2343
  };
2333
2344
  }),
2334
2345
  Obj2.bind("getNames", ({ getConfig }) => (name) => {
2335
- const upperName = capitalize4(name);
2346
+ const upperName = capitalize3(name);
2336
2347
  return {
2337
2348
  name,
2338
2349
  upperName,
@@ -2352,7 +2363,7 @@ var getPatternEngine = (config) => {
2352
2363
  Obj2.bind("nodes", ({ patterns }) => {
2353
2364
  return Object.entries(patterns).map(([name, pattern]) => ({
2354
2365
  type: "pattern",
2355
- name: pattern.jsx ?? capitalize4(name),
2366
+ name: pattern.jsx ?? capitalize3(name),
2356
2367
  props: Object.keys(pattern.properties),
2357
2368
  baseName: name
2358
2369
  }));
@@ -2367,7 +2378,7 @@ var getPatternEngine = (config) => {
2367
2378
  };
2368
2379
 
2369
2380
  // src/engines/recipe.ts
2370
- import { capitalize as capitalize5, dashCase as dashCase2, splitProps, uncapitalize as uncapitalize2 } from "@pandacss/shared";
2381
+ import { capitalize as capitalize4, dashCase as dashCase2, splitProps, uncapitalize as uncapitalize2 } from "@pandacss/shared";
2371
2382
  import { Obj as Obj3, pipe as pipe4 } from "lil-fp";
2372
2383
  var getRecipeEngine = (config) => {
2373
2384
  return pipe4(
@@ -2377,15 +2388,15 @@ var getRecipeEngine = (config) => {
2377
2388
  }),
2378
2389
  Obj3.bind("getNames", ({ getConfig }) => {
2379
2390
  return (name) => ({
2380
- upperName: capitalize5(name),
2391
+ upperName: capitalize4(name),
2381
2392
  dashName: dashCase2(name),
2382
- jsxName: getConfig(name)?.jsx ?? capitalize5(name)
2393
+ jsxName: getConfig(name)?.jsx ?? capitalize4(name)
2383
2394
  });
2384
2395
  }),
2385
2396
  Obj3.bind("nodes", ({ recipes }) => {
2386
2397
  return Object.entries(recipes).map(([name, recipe]) => ({
2387
2398
  type: "recipe",
2388
- name: recipe.jsx ?? capitalize5(name),
2399
+ name: recipe.jsx ?? capitalize4(name),
2389
2400
  props: Object.keys(recipe.variants ?? {}),
2390
2401
  baseName: name
2391
2402
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20230212130534",
3
+ "version": "0.0.0-dev-20230212134223",
4
4
  "description": "The css generator for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -20,16 +20,16 @@
20
20
  "pluralize": "8.0.0",
21
21
  "postcss": "8.4.21",
22
22
  "ts-pattern": "4.1.4",
23
- "@pandacss/core": "0.0.0-dev-20230212130534",
24
- "@pandacss/logger": "0.0.0-dev-20230212130534",
25
- "@pandacss/is-valid-prop": "0.0.0-dev-20230212130534",
26
- "@pandacss/shared": "0.0.0-dev-20230212130534",
27
- "@pandacss/types": "0.0.0-dev-20230212130534",
28
- "@pandacss/token-dictionary": "0.0.0-dev-20230212130534"
23
+ "@pandacss/core": "0.0.0-dev-20230212134223",
24
+ "@pandacss/logger": "0.0.0-dev-20230212134223",
25
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230212134223",
26
+ "@pandacss/shared": "0.0.0-dev-20230212134223",
27
+ "@pandacss/types": "0.0.0-dev-20230212134223",
28
+ "@pandacss/token-dictionary": "0.0.0-dev-20230212134223"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/pluralize": "0.0.29",
32
- "@pandacss/fixture": "0.0.0-dev-20230212130534"
32
+ "@pandacss/fixture": "0.0.0-dev-20230212134223"
33
33
  },
34
34
  "scripts": {
35
35
  "prebuild": "tsx scripts/prebuild.ts",