@pandacss/generator 0.7.0 → 0.9.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
@@ -419,7 +419,7 @@ var generateStaticCss = (ctx) => {
419
419
  return [];
420
420
  return Object.keys(values);
421
421
  },
422
- getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
422
+ getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.baseName === recipe)?.variantKeyMap ?? {}
423
423
  });
424
424
  results.css.forEach((css2) => {
425
425
  sheet.processAtomic(css2);
@@ -429,7 +429,7 @@ var generateStaticCss = (ctx) => {
429
429
  const recipeConfig = recipes.getConfig(name);
430
430
  if (!recipeConfig)
431
431
  return;
432
- sheet.processRecipe(recipeConfig, value);
432
+ sheet.processRecipe(name, recipeConfig, value);
433
433
  });
434
434
  });
435
435
  const output = sheet.toCss({ optimize });
@@ -624,16 +624,22 @@ function generateCssFn(ctx) {
624
624
  return {
625
625
  dts: import_outdent4.outdent`
626
626
  import type { SystemStyleObject } from '../types'
627
- export declare function css(styles: SystemStyleObject): string
627
+
628
+ interface CssFunction {
629
+ (styles: SystemStyleObject): string
630
+ raw: (styles: SystemStyleObject) => SystemStyleObject
631
+ }
632
+
633
+ export declare const css: CssFunction;
628
634
  `,
629
635
  js: import_outdent4.outdent`
630
636
  ${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
631
637
  ${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
632
638
 
633
639
  const classNameMap = ${stringify(utility.entries())}
634
-
640
+
635
641
  const shorthands = ${stringify(utility.shorthands)}
636
-
642
+
637
643
  const breakpointKeys = ${JSON.stringify(conditions.breakpoints.keys)}
638
644
 
639
645
  const hasShorthand = ${utility.hasShorthand ? "true" : "false"}
@@ -663,6 +669,7 @@ function generateCssFn(ctx) {
663
669
  }
664
670
 
665
671
  export const css = createCss(context)
672
+ css.raw = (styles) => styles
666
673
 
667
674
  export const { mergeCss, assignCss } = createMergeCss(context)
668
675
  `
@@ -886,7 +893,7 @@ function generatePattern(ctx) {
886
893
  if (ctx.patterns.isEmpty())
887
894
  return;
888
895
  return ctx.patterns.details.map((pattern) => {
889
- const { name, config, dashName, upperName, styleFnName, blocklistType } = pattern;
896
+ const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
890
897
  const { properties, transform, strict, description } = config;
891
898
  const transformFn = (0, import_javascript_stringify.stringify)({ transform }) ?? "";
892
899
  const helperImports = ["mapObject"];
@@ -922,12 +929,17 @@ function generatePattern(ctx) {
922
929
  }).join("\n ")}
923
930
  }
924
931
 
925
- ${strict ? import_outdent10.outdent`export declare function ${name}(options: ${upperName}Properties): string` : import_outdent10.outdent`
932
+ ${strict ? import_outdent10.outdent`export declare function ${baseName}(options: ${upperName}Properties): string` : import_outdent10.outdent`
926
933
 
927
934
  type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
928
935
 
936
+ interface ${upperName}PatternFn {
937
+ (options?: ${upperName}Options): string
938
+ raw: (options: ${upperName}Options) => ${upperName}Options
939
+ }
940
+
929
941
  ${description ? `/** ${description} */` : ""}
930
- export declare function ${name}(options?: ${upperName}Options): string
942
+ export declare const ${baseName}: ${upperName}PatternFn;
931
943
  `}
932
944
 
933
945
  `,
@@ -935,12 +947,13 @@ function generatePattern(ctx) {
935
947
  ${ctx.file.import(helperImports.join(", "), "../helpers")}
936
948
  ${ctx.file.import("css", "../css/index")}
937
949
 
938
- const ${name}Config = ${transformFn.replace(`{transform`, `{
950
+ const ${baseName}Config = ${transformFn.replace(`{transform`, `{
939
951
  transform`)}
940
952
 
941
- export const ${styleFnName} = (styles = {}) => ${name}Config.transform(styles, { map: mapObject })
953
+ export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
942
954
 
943
- export const ${name} = (styles) => css(${styleFnName}(styles))
955
+ export const ${baseName} = (styles) => css(${styleFnName}(styles))
956
+ ${baseName}.raw = (styles) => styles
944
957
  `
945
958
  };
946
959
  });
@@ -1005,29 +1018,26 @@ function generateRecipes(ctx) {
1005
1018
  return [
1006
1019
  createRecipeFn,
1007
1020
  ...ctx.recipes.details.map((recipe) => {
1008
- const { config, upperName, variantKeyMap, dashName } = recipe;
1009
- const { name, description, defaultVariants, compoundVariants } = config;
1021
+ const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
1022
+ const { description, defaultVariants, compoundVariants } = config;
1010
1023
  return {
1011
1024
  name: dashName,
1012
1025
  js: import_outdent11.outdent`
1013
1026
  ${ctx.file.import("splitProps", "../helpers")}
1014
1027
  ${ctx.file.import("createRecipe", "./create-recipe")}
1015
1028
 
1016
- const ${name}Fn = createRecipe('${name}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
1029
+ const ${baseName}Fn = createRecipe('${baseName}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
1017
1030
  compoundVariants ?? []
1018
1031
  )})
1019
1032
 
1020
- const variantKeys = ${stringify3(Object.keys(variantKeyMap))}
1021
-
1022
- function splitVariantProps(props) {
1023
- return splitProps(props, variantKeys)
1024
- }
1025
-
1026
- export const ${name} = Object.assign(${name}Fn, {
1033
+ export const ${baseName} = Object.assign(${baseName}Fn, {
1027
1034
  __recipe__: true,
1028
- variantKeys,
1035
+ raw: (props) => props,
1036
+ variantKeys: ${stringify3(Object.keys(variantKeyMap))},
1029
1037
  variantMap: ${stringify3(variantKeyMap)},
1030
- splitVariantProps,
1038
+ splitVariantProps(props) {
1039
+ return splitProps(props, ${stringify3(Object.keys(variantKeyMap))})
1040
+ },
1031
1041
  })
1032
1042
  `,
1033
1043
  dts: import_outdent11.outdent`
@@ -1054,13 +1064,14 @@ function generateRecipes(ctx) {
1054
1064
  interface ${upperName}Recipe {
1055
1065
  __type: ${upperName}VariantProps
1056
1066
  (props?: ${upperName}VariantProps): string
1067
+ raw: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
1057
1068
  variantMap: ${upperName}VariantMap
1058
1069
  variantKeys: Array<keyof ${upperName}Variant>
1059
1070
  splitVariantProps<Props extends ${upperName}VariantProps>(props: Props): [${upperName}VariantProps, Pretty<Omit<Props, keyof ${upperName}VariantProps>>]
1060
1071
  }
1061
1072
 
1062
1073
  ${description ? `/** ${description} */` : ""}
1063
- export declare const ${name}: ${upperName}Recipe
1074
+ export declare const ${baseName}: ${upperName}Recipe
1064
1075
  `
1065
1076
  };
1066
1077
  })
@@ -1741,12 +1752,16 @@ import { ${upperName} } from '../types/jsx'
1741
1752
  export declare const ${factoryName}: ${upperName}
1742
1753
  `,
1743
1754
  jsxType: import_outdent25.outdent`
1744
- import type { ComponentProps, ElementType } from 'react'
1755
+ import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
1745
1756
  import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
1746
1757
  import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
1747
1758
 
1748
1759
  type Dict = Record<string, unknown>
1749
1760
 
1761
+ type ComponentProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'ref'> & {
1762
+ ref?: Ref<ElementRef<T>>
1763
+ }
1764
+
1750
1765
  export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
1751
1766
  (props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
1752
1767
  displayName?: string
@@ -1832,10 +1847,14 @@ import { ${upperName} } from '../types/jsx'
1832
1847
  export declare const ${factoryName}: ${upperName}
1833
1848
  `,
1834
1849
  jsxType: import_outdent27.outdent`
1835
- import type { ComponentProps, ElementType } from 'react'
1850
+ import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
1836
1851
 
1837
1852
  type Dict = Record<string, unknown>
1838
1853
 
1854
+ type ComponentProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'ref'> & {
1855
+ ref?: Ref<ElementRef<T>>
1856
+ }
1857
+
1839
1858
  export type ${componentName}<T extends ElementType> = {
1840
1859
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
1841
1860
  displayName?: string
@@ -2667,38 +2686,38 @@ function generateJsxPatterns(ctx) {
2667
2686
  // src/artifacts/pkg-json.ts
2668
2687
  function generatePackageJson(ctx) {
2669
2688
  const {
2670
- config: { outdir }
2689
+ config: { outdir, outExtension: ext = "mjs" }
2671
2690
  } = ctx;
2672
2691
  const pkg = {
2673
2692
  name: outdir,
2674
- description: "This package is auto-generated by CSS Panda",
2693
+ description: "This package is auto-generated by Panda CSS",
2675
2694
  version: `0.0.0-${performance.now()}`,
2676
2695
  type: "module",
2677
2696
  exports: {
2678
2697
  "./css": {
2679
2698
  types: "./css/index.d.ts",
2680
- require: "./css/index.mjs",
2681
- import: "./css/index.mjs"
2699
+ require: `./css/index.${ext}`,
2700
+ import: `./css/index.${ext}`
2682
2701
  },
2683
2702
  "./jsx": {
2684
2703
  types: "./jsx/index.d.ts",
2685
- require: "./jsx/index.mjs",
2686
- import: "./jsx/index.mjs"
2704
+ require: `./jsx/index.${ext}`,
2705
+ import: `./jsx/index.${ext}`
2687
2706
  },
2688
2707
  "./patterns": {
2689
2708
  types: "./patterns/index.d.ts",
2690
- require: "./patterns/index.mjs",
2691
- import: "./patterns/index.mjs"
2709
+ require: `./patterns/index.${ext}`,
2710
+ import: `./patterns/index.${ext}`
2692
2711
  },
2693
2712
  "./recipes": {
2694
2713
  types: "./recipes/index.d.ts",
2695
- require: "./recipes/index.mjs",
2696
- import: "./recipes/index.mjs"
2714
+ require: `./recipes/index.${ext}`,
2715
+ import: `./recipes/index.${ext}`
2697
2716
  },
2698
2717
  "./tokens": {
2699
2718
  types: "./tokens/index.d.ts",
2700
- require: "./tokens/index.mjs",
2701
- import: "./tokens/index.mjs"
2719
+ require: `./tokens/index.${ext}`,
2720
+ import: `./tokens/index.${ext}`
2702
2721
  },
2703
2722
  "./types": {
2704
2723
  types: "./types/index.d.ts"
@@ -2726,12 +2745,12 @@ var composition_d_ts_default = {
2726
2745
 
2727
2746
  // src/artifacts/generated/recipe.d.ts.json
2728
2747
  var recipe_d_ts_default = {
2729
- content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type RecipeDefinition<T extends RecipeVariantRecord> = {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | RecipeVariantRecord\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\n /**\n * The name of the recipe.\n */\n name: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n"
2748
+ content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type RecipeDefinition<T extends RecipeVariantRecord> = {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | RecipeVariantRecord\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n"
2730
2749
  };
2731
2750
 
2732
2751
  // src/artifacts/generated/pattern.d.ts.json
2733
2752
  var pattern_d_ts_default = {
2734
- content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2753
+ content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
2735
2754
  };
2736
2755
 
2737
2756
  // src/artifacts/generated/parts.d.ts.json
@@ -3185,21 +3204,21 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
3185
3204
  sheet.processStyleProps(data);
3186
3205
  });
3187
3206
  });
3188
- result2.recipe.forEach((recipeSet, name) => {
3207
+ result2.recipe.forEach((recipeSet, recipeName) => {
3189
3208
  try {
3190
3209
  for (const recipe of recipeSet) {
3191
- const recipeConfig = recipes.getConfig(name);
3210
+ const recipeConfig = recipes.getConfig(recipeName);
3192
3211
  if (!recipeConfig)
3193
3212
  continue;
3194
- (0, import_ts_pattern6.match)(recipe).with({ type: "jsx-recipe", name: import_ts_pattern6.P.string }, ({ name: name2 }) => {
3213
+ (0, import_ts_pattern6.match)(recipe).with({ type: "jsx-recipe" }, () => {
3195
3214
  recipe.data.forEach((data) => {
3196
- const [recipeProps, styleProps] = recipes.splitProps(name2, data);
3215
+ const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3197
3216
  sheet.processStyleProps(styleProps);
3198
- sheet.processRecipe(recipeConfig, recipeProps);
3217
+ sheet.processRecipe(recipeName, recipeConfig, recipeProps);
3199
3218
  });
3200
3219
  }).otherwise(() => {
3201
3220
  recipe.data.forEach((data) => {
3202
- sheet.processRecipe(recipeConfig, data);
3221
+ sheet.processRecipe(recipeName, recipeConfig, data);
3203
3222
  });
3204
3223
  });
3205
3224
  }
@@ -3210,9 +3229,9 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
3210
3229
  result2.pattern.forEach((patternSet, name) => {
3211
3230
  try {
3212
3231
  for (const pattern of patternSet) {
3213
- (0, import_ts_pattern6.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern6.P.string }, ({ name: name2 }) => {
3232
+ (0, import_ts_pattern6.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern6.P.string }, ({ name: jsxName }) => {
3214
3233
  pattern.data.forEach((data) => {
3215
- const fnName = patterns.getFnName(name2);
3234
+ const fnName = patterns.getFnName(jsxName);
3216
3235
  const styleProps = patterns.transform(fnName, data);
3217
3236
  sheet.processStyleProps(styleProps);
3218
3237
  });
@@ -3362,52 +3381,51 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
3362
3381
 
3363
3382
  // src/engines/pattern.ts
3364
3383
  var import_shared7 = require("@pandacss/shared");
3365
- var import_lil_fp2 = require("lil-fp");
3366
3384
  var helpers2 = { map: import_shared7.mapObject };
3385
+ var createRegex = (item) => {
3386
+ const regex = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
3387
+ return new RegExp(`^${regex}$`);
3388
+ };
3367
3389
  var getPatternEngine = (config) => {
3368
- return (0, import_lil_fp2.pipe)(
3369
- { patterns: config.patterns ?? {} },
3370
- import_lil_fp2.Obj.bind("getConfig", ({ patterns }) => {
3371
- return (name) => patterns[name];
3372
- }),
3373
- import_lil_fp2.Obj.bind("transform", ({ getConfig }) => {
3374
- return (name, data) => {
3375
- return getConfig(name)?.transform?.(data, helpers2) ?? {};
3376
- };
3377
- }),
3378
- import_lil_fp2.Obj.bind("getNames", ({ getConfig }) => (name) => {
3379
- const upperName = (0, import_shared7.capitalize)(name);
3380
- return {
3381
- name,
3382
- upperName,
3383
- dashName: (0, import_shared7.dashCase)(name),
3384
- styleFnName: `get${upperName}Style`,
3385
- jsxName: getConfig(name)?.jsx ?? upperName
3386
- };
3387
- }),
3388
- import_lil_fp2.Obj.bind("details", ({ getNames, patterns }) => {
3389
- return Object.entries(patterns).map(([name, pattern]) => ({
3390
- ...getNames(name),
3391
- props: Object.keys(pattern?.properties ?? {}),
3392
- blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
3393
- config: pattern
3394
- }));
3395
- }),
3396
- import_lil_fp2.Obj.bind("nodes", ({ patterns }) => {
3397
- return Object.entries(patterns).map(([name, pattern]) => ({
3398
- type: "pattern",
3399
- name: pattern.jsx ?? (0, import_shared7.capitalize)(name),
3400
- props: Object.keys(pattern?.properties ?? {}),
3401
- baseName: name
3402
- }));
3390
+ const patterns = config.patterns ?? {};
3391
+ const getNames = (name) => {
3392
+ const upperName = (0, import_shared7.capitalize)(name);
3393
+ return {
3394
+ upperName,
3395
+ baseName: name,
3396
+ dashName: (0, import_shared7.dashCase)(name),
3397
+ styleFnName: `get${upperName}Style`,
3398
+ jsxName: patterns[name]?.jsxName ?? upperName
3399
+ };
3400
+ };
3401
+ const details = Object.entries(patterns).map(([name, pattern]) => {
3402
+ const names = getNames(name);
3403
+ const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
3404
+ return {
3405
+ ...names,
3406
+ props: Object.keys(pattern?.properties ?? {}),
3407
+ blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
3408
+ config: pattern,
3409
+ type: "pattern",
3410
+ match: createRegex(jsx),
3411
+ jsx
3412
+ };
3413
+ });
3414
+ return {
3415
+ getConfig: (name) => patterns[name],
3416
+ transform: (name, data) => {
3417
+ return patterns[name]?.transform?.(data, helpers2) ?? {};
3418
+ },
3419
+ getNames,
3420
+ details,
3421
+ getFnName: (0, import_shared7.memo)((jsxName) => {
3422
+ return details.find((node) => node.jsxName === jsxName)?.baseName ?? (0, import_shared7.uncapitalize)(jsxName);
3403
3423
  }),
3404
- import_lil_fp2.Obj.bind("getFnName", ({ nodes }) => (jsx) => {
3405
- return nodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared7.uncapitalize)(jsx);
3424
+ filter: (0, import_shared7.memo)((jsxName) => {
3425
+ return details.filter((node) => node.match.test(jsxName));
3406
3426
  }),
3407
- import_lil_fp2.Obj.bind("isEmpty", ({ patterns }) => {
3408
- return () => Object.keys(patterns).length === 0;
3409
- })
3410
- );
3427
+ isEmpty: () => Object.keys(patterns).length === 0
3428
+ };
3411
3429
  };
3412
3430
 
3413
3431
  // src/engines/index.ts
@@ -3442,10 +3460,10 @@ var defaults = (conf) => ({
3442
3460
  }
3443
3461
  });
3444
3462
  var getImportMap = (outdir) => ({
3445
- css: `${outdir}/css`,
3446
- recipe: `${outdir}/recipes`,
3447
- pattern: `${outdir}/patterns`,
3448
- jsx: `${outdir}/jsx`
3463
+ css: [outdir, "css"],
3464
+ recipe: [outdir, "recipes"],
3465
+ pattern: [outdir, "patterns"],
3466
+ jsx: [outdir, "jsx"]
3449
3467
  });
3450
3468
  var createGenerator = (conf) => {
3451
3469
  const ctx = getEngine(defaults(conf));
@@ -3453,7 +3471,7 @@ var createGenerator = (conf) => {
3453
3471
  const compilerOptions = conf.tsconfig?.compilerOptions ?? {};
3454
3472
  const baseUrl = compilerOptions.baseUrl ?? "";
3455
3473
  const cwd = conf.config.cwd;
3456
- const relativeBaseUrl = baseUrl ? baseUrl.replace(cwd, "").slice(1) + "/" : cwd;
3474
+ const relativeBaseUrl = baseUrl !== cwd ? baseUrl.replace(cwd, "").slice(1) : cwd;
3457
3475
  return {
3458
3476
  ...ctx,
3459
3477
  getArtifacts: generateArtifacts(ctx),
@@ -3465,9 +3483,12 @@ var createGenerator = (conf) => {
3465
3483
  jsx: {
3466
3484
  factory: jsx.factoryName,
3467
3485
  isStyleProp: isValidProperty,
3468
- nodes: [...patterns.nodes, ...recipes.nodes]
3486
+ nodes: [...patterns.details, ...recipes.details]
3469
3487
  },
3470
- getRecipesByJsxName: recipes.filter
3488
+ getRecipesByJsxName: recipes.filter,
3489
+ getPatternsByJsxName: patterns.filter,
3490
+ compilerOptions,
3491
+ tsOptions: conf.tsOptions
3471
3492
  }
3472
3493
  };
3473
3494
  };