@pandacss/generator 0.0.0-dev-20230516185132 → 0.0.0-dev-20230516191725

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
@@ -461,7 +461,7 @@ var import_outdent4 = require("outdent");
461
461
  function generateCvaFn(ctx) {
462
462
  return {
463
463
  js: import_outdent4.outdent`
464
- ${ctx.file.import("compact", "../helpers")}
464
+ ${ctx.file.import("compact, splitProps", "../helpers")}
465
465
  ${ctx.file.import("css, mergeCss", "./css")}
466
466
 
467
467
  export function cva(config) {
@@ -482,12 +482,22 @@ function generateCvaFn(ctx) {
482
482
  function cvaFn(props) {
483
483
  return css(resolve(props))
484
484
  }
485
+
486
+ const variantKeys = Object.keys(variants)
487
+
488
+ function splitVariantProps(props) {
489
+ return splitProps(props, variantKeys)
490
+ }
491
+
492
+ const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
485
493
 
486
494
  return Object.assign(cvaFn, {
487
495
  __cva__: true,
488
- variants: Object.keys(variants),
496
+ variants: variantMap,
497
+ variantKeys,
489
498
  resolve,
490
499
  config,
500
+ splitVariantProps,
491
501
  })
492
502
  }
493
503
 
@@ -511,9 +521,7 @@ function generateCvaFn(ctx) {
511
521
 
512
522
  export function assertCompoundVariant(name, compoundVariants, variants, prop) {
513
523
  if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
514
- throw new Error(
515
- \`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`,
516
- )
524
+ throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
517
525
  }
518
526
  }
519
527
 
@@ -833,7 +841,7 @@ function generatePreactJsxFactory(ctx) {
833
841
  const { as: Element = Dynamic, ...restProps } = props
834
842
 
835
843
  const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
836
- return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
844
+ return splitProps(restProps, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
837
845
  }, [restProps])
838
846
 
839
847
  function classes() {
@@ -971,7 +979,7 @@ function generateReactJsxFactory(ctx) {
971
979
  const { as: Element = Dynamic, ...restProps } = props
972
980
 
973
981
  const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
974
- return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
982
+ return splitProps(restProps, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
975
983
  }, [restProps])
976
984
 
977
985
  function classes() {
@@ -1112,7 +1120,7 @@ function generateSolidJsxFactory(ctx) {
1112
1120
  mergedProps,
1113
1121
  ['as', 'class'],
1114
1122
  allCssProperties,
1115
- cvaFn.variants,
1123
+ cvaFn.variantKeys,
1116
1124
  normalizeHTMLProps.keys
1117
1125
  )
1118
1126
 
@@ -1259,7 +1267,7 @@ function generateVueJsxFactory(ctx) {
1259
1267
  props: { as: { type: [String, Object], default: Dynamic } },
1260
1268
  setup(props, { slots, attrs }) {
1261
1269
  const splittedProps = computed(() => {
1262
- return splitProps(attrs, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
1270
+ return splitProps(attrs, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
1263
1271
  })
1264
1272
 
1265
1273
  const classes = computed(() => {
@@ -1554,7 +1562,7 @@ var composition_d_ts_default = {
1554
1562
 
1555
1563
  // src/artifacts/generated/recipe.d.ts.json
1556
1564
  var recipe_d_ts_default = {
1557
- 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<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n variants: (keyof T)[]\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
1565
+ 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<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n variants: (keyof T)[]\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<Omit<Props, keyof RecipeVariantRecord>>]\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
1558
1566
  };
1559
1567
 
1560
1568
  // src/artifacts/generated/pattern.d.ts.json
package/dist/index.mjs CHANGED
@@ -430,7 +430,7 @@ import { outdent as outdent4 } from "outdent";
430
430
  function generateCvaFn(ctx) {
431
431
  return {
432
432
  js: outdent4`
433
- ${ctx.file.import("compact", "../helpers")}
433
+ ${ctx.file.import("compact, splitProps", "../helpers")}
434
434
  ${ctx.file.import("css, mergeCss", "./css")}
435
435
 
436
436
  export function cva(config) {
@@ -451,12 +451,22 @@ function generateCvaFn(ctx) {
451
451
  function cvaFn(props) {
452
452
  return css(resolve(props))
453
453
  }
454
+
455
+ const variantKeys = Object.keys(variants)
456
+
457
+ function splitVariantProps(props) {
458
+ return splitProps(props, variantKeys)
459
+ }
460
+
461
+ const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
454
462
 
455
463
  return Object.assign(cvaFn, {
456
464
  __cva__: true,
457
- variants: Object.keys(variants),
465
+ variants: variantMap,
466
+ variantKeys,
458
467
  resolve,
459
468
  config,
469
+ splitVariantProps,
460
470
  })
461
471
  }
462
472
 
@@ -480,9 +490,7 @@ function generateCvaFn(ctx) {
480
490
 
481
491
  export function assertCompoundVariant(name, compoundVariants, variants, prop) {
482
492
  if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
483
- throw new Error(
484
- \`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`,
485
- )
493
+ throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
486
494
  }
487
495
  }
488
496
 
@@ -802,7 +810,7 @@ function generatePreactJsxFactory(ctx) {
802
810
  const { as: Element = Dynamic, ...restProps } = props
803
811
 
804
812
  const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
805
- return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
813
+ return splitProps(restProps, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
806
814
  }, [restProps])
807
815
 
808
816
  function classes() {
@@ -940,7 +948,7 @@ function generateReactJsxFactory(ctx) {
940
948
  const { as: Element = Dynamic, ...restProps } = props
941
949
 
942
950
  const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
943
- return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
951
+ return splitProps(restProps, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
944
952
  }, [restProps])
945
953
 
946
954
  function classes() {
@@ -1081,7 +1089,7 @@ function generateSolidJsxFactory(ctx) {
1081
1089
  mergedProps,
1082
1090
  ['as', 'class'],
1083
1091
  allCssProperties,
1084
- cvaFn.variants,
1092
+ cvaFn.variantKeys,
1085
1093
  normalizeHTMLProps.keys
1086
1094
  )
1087
1095
 
@@ -1228,7 +1236,7 @@ function generateVueJsxFactory(ctx) {
1228
1236
  props: { as: { type: [String, Object], default: Dynamic } },
1229
1237
  setup(props, { slots, attrs }) {
1230
1238
  const splittedProps = computed(() => {
1231
- return splitProps(attrs, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
1239
+ return splitProps(attrs, isCssProperty, cvaFn.variantKeys, normalizeHTMLProps.keys)
1232
1240
  })
1233
1241
 
1234
1242
  const classes = computed(() => {
@@ -1523,7 +1531,7 @@ var composition_d_ts_default = {
1523
1531
 
1524
1532
  // src/artifacts/generated/recipe.d.ts.json
1525
1533
  var recipe_d_ts_default = {
1526
- 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<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n variants: (keyof T)[]\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
1534
+ 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<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n variants: (keyof T)[]\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<Omit<Props, keyof RecipeVariantRecord>>]\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
1527
1535
  };
1528
1536
 
1529
1537
  // src/artifacts/generated/pattern.d.ts.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20230516185132",
3
+ "version": "0.0.0-dev-20230516191725",
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.23",
22
22
  "ts-pattern": "4.3.0",
23
- "@pandacss/core": "0.0.0-dev-20230516185132",
24
- "@pandacss/logger": "0.0.0-dev-20230516185132",
25
- "@pandacss/is-valid-prop": "0.0.0-dev-20230516185132",
26
- "@pandacss/shared": "0.0.0-dev-20230516185132",
27
- "@pandacss/types": "0.0.0-dev-20230516185132",
28
- "@pandacss/token-dictionary": "0.0.0-dev-20230516185132"
23
+ "@pandacss/core": "0.0.0-dev-20230516191725",
24
+ "@pandacss/logger": "0.0.0-dev-20230516191725",
25
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230516191725",
26
+ "@pandacss/shared": "0.0.0-dev-20230516191725",
27
+ "@pandacss/types": "0.0.0-dev-20230516191725",
28
+ "@pandacss/token-dictionary": "0.0.0-dev-20230516191725"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/pluralize": "0.0.29",
32
- "@pandacss/fixture": "0.0.0-dev-20230516185132"
32
+ "@pandacss/fixture": "0.0.0-dev-20230516191725"
33
33
  },
34
34
  "scripts": {
35
35
  "prebuild": "tsx scripts/prebuild.ts",