@pandacss/generator 0.16.0 → 0.17.1

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.mjs CHANGED
@@ -99,7 +99,7 @@ var getMessages = (ctx) => ({
99
99
 
100
100
  // src/artifacts/index.ts
101
101
  import { isObject } from "@pandacss/shared";
102
- import outdent43 from "outdent";
102
+ import outdent44 from "outdent";
103
103
 
104
104
  // src/artifacts/css/global-css.ts
105
105
  var generateGlobalCss = (ctx) => {
@@ -268,6 +268,14 @@ function generateResetCss(ctx, scope = "") {
268
268
  background-image: none;
269
269
  }
270
270
 
271
+ ${selector}button,
272
+ ${selector}input,
273
+ ${selector}optgroup,
274
+ ${selector}select,
275
+ ${selector}textarea {
276
+ color: inherit;
277
+ }
278
+
271
279
  ${selector}button,
272
280
  ${selector}select {
273
281
  text-transform: none;
@@ -487,12 +495,25 @@ function getDeepestNode(node) {
487
495
  function cleanupSelectors(css2, varSelector) {
488
496
  const root = postcss2.parse(css2);
489
497
  root.walkRules((rule) => {
498
+ const selectors = [];
490
499
  rule.selectors.forEach((selector) => {
491
- const res = selector.split(varSelector).filter(Boolean);
492
- if (res.length === 0)
493
- return;
494
- rule.selector = res.join(varSelector);
500
+ selectors.push(selector.trim());
495
501
  });
502
+ const ruleSelector = selectors.join(", ");
503
+ if (ruleSelector === varSelector) {
504
+ return;
505
+ }
506
+ const trimmedSelector = selectors.join(",");
507
+ if (trimmedSelector === varSelector) {
508
+ return;
509
+ }
510
+ const selectorsWithoutVarRoot = selectors.map((selector) => {
511
+ const res = selector.split(varSelector).filter(Boolean);
512
+ return res.join("");
513
+ }).filter(Boolean);
514
+ if (selectorsWithoutVarRoot.length === 0)
515
+ return;
516
+ rule.selector = selectorsWithoutVarRoot.join(", ");
496
517
  });
497
518
  return root.toString();
498
519
  }
@@ -606,11 +627,7 @@ function generateStringLiteralConditions(ctx) {
606
627
  // src/artifacts/js/css-fn.ts
607
628
  import { outdent as outdent4 } from "outdent";
608
629
  function generateCssFn(ctx) {
609
- const {
610
- utility,
611
- config: { hash, prefix },
612
- conditions
613
- } = ctx;
630
+ const { utility, hash, prefix, conditions } = ctx;
614
631
  const { separator, getPropShorthands } = utility;
615
632
  return {
616
633
  dts: outdent4`
@@ -665,14 +682,14 @@ function generateCssFn(ctx) {
665
682
  `}
666
683
 
667
684
  const context = {
668
- ${hash ? "hash: true," : ""}
685
+ ${hash.className ? "hash: true," : ""}
669
686
  conditions: {
670
687
  shift: sortConditions,
671
688
  finalize: finalizeConditions,
672
689
  breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
673
690
  },
674
691
  utility: {
675
- ${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
692
+ ${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
676
693
  transform: ${utility.hasShorthand ? `(prop, value) => {
677
694
  const key = resolveShorthand(prop)
678
695
  const propKey = classNameByProp.get(key) || hypenateProperty(key)
@@ -695,18 +712,15 @@ function generateCssFn(ctx) {
695
712
  // src/artifacts/js/css-fn.string-literal.ts
696
713
  import { outdent as outdent5 } from "outdent";
697
714
  function generateStringLiteralCssFn(ctx) {
698
- const {
699
- utility,
700
- config: { hash, prefix }
701
- } = ctx;
715
+ const { utility, hash, prefix } = ctx;
702
716
  const { separator } = utility;
703
717
  return {
704
718
  dts: outdent5`
705
719
  export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
706
720
  `,
707
721
  js: outdent5`
708
- ${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
709
- ${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
722
+ ${ctx.file.import("astish, createCss, isObject, mergeProps, withoutSpace", "../helpers")}
723
+ ${ctx.file.import("finalizeConditions, sortConditions", "./conditions")}
710
724
 
711
725
  function transform(prop, value) {
712
726
  const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
@@ -714,14 +728,14 @@ function generateStringLiteralCssFn(ctx) {
714
728
  }
715
729
 
716
730
  const context = {
717
- hash: ${hash ? "true" : "false"},
731
+ hash: ${hash.className ? "true" : "false"},
718
732
  conditions: {
719
733
  shift: sortConditions,
720
734
  finalize: finalizeConditions,
721
735
  breakpoints: { keys: [] },
722
736
  },
723
737
  utility: {
724
- prefix: ${prefix ? JSON.stringify(prefix) : void 0},
738
+ prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
725
739
  transform,
726
740
  hasShorthand: false,
727
741
  resolveShorthand(prop) {
@@ -732,9 +746,9 @@ function generateStringLiteralCssFn(ctx) {
732
746
 
733
747
  const cssFn = createCss(context)
734
748
 
735
- export const css = (str) => {
736
- return cssFn(astish(str[0]))
737
- }
749
+ const fn = (style) => (isObject(style) ? style : astish(style[0]))
750
+ export const css = (...styles) => cssFn(mergeProps(...styles.filter(Boolean).map(fn)))
751
+ css.raw = (...styles) => mergeProps(...styles.filter(Boolean).map(fn))
738
752
  `
739
753
  };
740
754
  }
@@ -744,11 +758,19 @@ import { outdent as outdent6 } from "outdent";
744
758
  function generateCvaFn(ctx) {
745
759
  return {
746
760
  js: outdent6`
747
- ${ctx.file.import("compact, splitProps", "../helpers")}
761
+ ${ctx.file.import("compact, mergeProps, splitProps, uniq", "../helpers")}
748
762
  ${ctx.file.import("css, mergeCss", "./css")}
749
763
 
764
+ const defaults = (conf) => ({
765
+ base: {},
766
+ variants: {},
767
+ defaultVariants: {},
768
+ compoundVariants: [],
769
+ ...conf,
770
+ })
771
+
750
772
  export function cva(config) {
751
- const { base = {}, variants = {}, defaultVariants = {}, compoundVariants = [] } = config
773
+ const { base, variants, defaultVariants, compoundVariants } = defaults(config)
752
774
 
753
775
  function resolve(props = {}) {
754
776
  const computedVariants = { ...defaultVariants, ...compact(props) }
@@ -762,6 +784,19 @@ function generateCvaFn(ctx) {
762
784
  return mergeCss(variantCss, compoundVariantCss)
763
785
  }
764
786
 
787
+ function merge(cvaConfig) {
788
+ const override = defaults(cvaConfig)
789
+ const variantKeys = uniq(override.variantKeys, Object.keys(variants))
790
+ return cva({
791
+ base: mergeCss(base, override.base),
792
+ variants: Object.fromEntries(
793
+ variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
794
+ ),
795
+ defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
796
+ compoundVariants: [...compoundVariants, ...override.compoundVariants],
797
+ })
798
+ }
799
+
765
800
  function cvaFn(props) {
766
801
  return css(resolve(props))
767
802
  }
@@ -780,6 +815,7 @@ function generateCvaFn(ctx) {
780
815
  variantKeys,
781
816
  raw: resolve,
782
817
  config,
818
+ merge,
783
819
  splitVariantProps,
784
820
  })
785
821
  }
@@ -854,7 +890,7 @@ import { outdent as outdent8 } from "outdent";
854
890
 
855
891
  // src/artifacts/generated/helpers.mjs.json
856
892
  var helpers_mjs_default = {
857
- content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate-property.ts\nvar wordRegex = /([A-Z])/g;\nvar msRegex = /^ms-/;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();\n});\n\n// src/slot.ts\nvar getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join("__"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const slots = recipe.slots ?? [];\n const recipeParts = slots.map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {\n for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {\n recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n }\n }\n return Object.fromEntries(recipeParts);\n};\nvar getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));\n\n// src/split-props.ts\nfunction splitProps(props, ...keys) {\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const dKeys = Object.keys(descriptors);\n const split = (k) => {\n const clone = {};\n for (let i = 0; i < k.length; i++) {\n const key = k[i];\n if (descriptors[key]) {\n Object.defineProperty(clone, key, descriptors[key]);\n delete descriptors[key];\n }\n }\n return clone;\n };\n const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));\n return keys.map(fn).concat(split(dKeys));\n}\nexport {\n compact,\n createCss,\n createMergeCss,\n filterBaseConditions,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n splitProps,\n toHash,\n walkObject,\n withoutSpace\n};\n'
893
+ content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const objects = sources.filter(Boolean);\n return objects.reduce((prev, obj) => {\n Object.keys(obj).forEach((key) => {\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) {\n prev[key] = mergeProps(prevValue, value);\n } else {\n prev[key] = value;\n }\n });\n return prev;\n }, {});\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate-property.ts\nvar wordRegex = /([A-Z])/g;\nvar msRegex = /^ms-/;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();\n});\n\n// src/slot.ts\nvar getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join("__"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const slots = recipe.slots ?? [];\n const recipeParts = slots.map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {\n for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {\n recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n }\n }\n return Object.fromEntries(recipeParts);\n};\nvar getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));\n\n// src/split-props.ts\nfunction splitProps(props, ...keys) {\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const dKeys = Object.keys(descriptors);\n const split = (k) => {\n const clone = {};\n for (let i = 0; i < k.length; i++) {\n const key = k[i];\n if (descriptors[key]) {\n Object.defineProperty(clone, key, descriptors[key]);\n delete descriptors[key];\n }\n }\n return clone;\n };\n const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));\n return keys.map(fn).concat(split(dKeys));\n}\n\n// src/uniq.ts\nvar uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(/* @__PURE__ */ new Set([...acc, ...item])), []);\nexport {\n compact,\n createCss,\n createMergeCss,\n filterBaseConditions,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n splitProps,\n toHash,\n uniq,\n walkObject,\n withoutSpace\n};\n'
858
894
  };
859
895
 
860
896
  // src/artifacts/generated/astish.mjs.json
@@ -922,11 +958,52 @@ function generateIsValidProp(ctx) {
922
958
  };
923
959
  }
924
960
 
961
+ // src/artifacts/js/jsx-helper.ts
962
+ import { outdent as outdent10 } from "outdent";
963
+ import { match as match2 } from "ts-pattern";
964
+ function generatedJsxHelpers(ctx) {
965
+ return {
966
+ js: match2(ctx.isTemplateLiteralSyntax).with(
967
+ true,
968
+ () => outdent10`
969
+ export const getDisplayName = (Component) => {
970
+ if (typeof Component === 'string') return Component
971
+ return Component?.displayName || Component?.name || 'Component'
972
+ }`
973
+ ).otherwise(
974
+ () => outdent10`
975
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
976
+
977
+ export const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
978
+
979
+ export const composeShouldForwardProps = (tag, shouldForwardProp) =>
980
+ tag.__shouldForwardProps__ && shouldForwardProp
981
+ ? (propName) => tag.__shouldForwardProps__(propName) && shouldForwardProp(propName)
982
+ : shouldForwardProp
983
+
984
+ export const composeCvaFn = (cvaA, cvaB) => {
985
+ if (cvaA && !cvaB) return cvaA
986
+ if (!cvaA && cvaB) return cvaB
987
+ if ((cvaA.__cva__ && cvaB.__cva__) || (cvaA.__recipe__ && cvaB.__recipe__)) return cvaA.merge(cvaB.config)
988
+ const error = new TypeError('Cannot merge cva with recipe. Please use either cva or recipe.')
989
+ TypeError.captureStackTrace?.(error)
990
+ throw error
991
+ }
992
+
993
+ export const getDisplayName = (Component) => {
994
+ if (typeof Component === 'string') return Component
995
+ return Component?.displayName || Component?.name || 'Component'
996
+ }
997
+ `
998
+ )
999
+ };
1000
+ }
1001
+
925
1002
  // src/artifacts/js/pattern.ts
926
1003
  import { unionType } from "@pandacss/shared";
927
1004
  import { stringify } from "javascript-stringify";
928
- import { outdent as outdent10 } from "outdent";
929
- import { match as match2 } from "ts-pattern";
1005
+ import { outdent as outdent11 } from "outdent";
1006
+ import { match as match3 } from "ts-pattern";
930
1007
  function generatePattern(ctx) {
931
1008
  if (ctx.patterns.isEmpty())
932
1009
  return;
@@ -943,7 +1020,7 @@ function generatePattern(ctx) {
943
1020
  }
944
1021
  return {
945
1022
  name: dashName,
946
- dts: outdent10`
1023
+ dts: outdent11`
947
1024
  ${ctx.file.importType("SystemStyleObject, ConditionalValue", "../types/index")}
948
1025
  ${ctx.file.importType("Properties", "../types/csstype")}
949
1026
  ${ctx.file.importType("PropertyValue", "../types/prop-type")}
@@ -953,7 +1030,7 @@ function generatePattern(ctx) {
953
1030
  export interface ${upperName}Properties {
954
1031
  ${Object.keys(properties ?? {}).map((key) => {
955
1032
  const value = properties[key];
956
- return match2(value).with({ type: "property" }, (value2) => {
1033
+ return match3(value).with({ type: "property" }, (value2) => {
957
1034
  return `${key}?: PropertyValue<'${value2.value}'>`;
958
1035
  }).with({ type: "token" }, (value2) => {
959
1036
  if (value2.property) {
@@ -968,7 +1045,7 @@ function generatePattern(ctx) {
968
1045
  }).join("\n ")}
969
1046
  }
970
1047
 
971
- ${strict ? outdent10`export declare function ${baseName}(styles: ${upperName}Properties): string` : outdent10`
1048
+ ${strict ? outdent11`export declare function ${baseName}(styles: ${upperName}Properties): string` : outdent11`
972
1049
 
973
1050
  interface ${upperName}Styles extends ${upperName}Properties, DistributiveOmit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}> {}
974
1051
 
@@ -982,7 +1059,7 @@ function generatePattern(ctx) {
982
1059
  `}
983
1060
 
984
1061
  `,
985
- js: outdent10`
1062
+ js: outdent11`
986
1063
  ${ctx.file.import(helperImports.join(", "), "../helpers")}
987
1064
  ${ctx.file.import("css", "../css/index")}
988
1065
 
@@ -1001,8 +1078,8 @@ transform`)}
1001
1078
  // src/artifacts/js/recipe.ts
1002
1079
  import { isSlotRecipe } from "@pandacss/core";
1003
1080
  import { unionType as unionType2 } from "@pandacss/shared";
1004
- import { outdent as outdent11 } from "outdent";
1005
- import { match as match3 } from "ts-pattern";
1081
+ import { outdent as outdent12 } from "outdent";
1082
+ import { match as match4 } from "ts-pattern";
1006
1083
  var stringify2 = (value) => JSON.stringify(value, null, 2);
1007
1084
  var isBooleanValue = (value) => value === "true" || value === "false";
1008
1085
  function generateRecipes(ctx) {
@@ -1016,11 +1093,11 @@ function generateRecipes(ctx) {
1016
1093
  const createRecipeFn = {
1017
1094
  name: "create-recipe",
1018
1095
  dts: "",
1019
- js: outdent11`
1096
+ js: outdent12`
1020
1097
  ${ctx.file.import("css", "../css/css")}
1021
1098
  ${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
1022
1099
  ${ctx.file.import("cx", "../css/cx")}
1023
- ${ctx.file.import("compact, createCss, withoutSpace", "../helpers")}
1100
+ ${ctx.file.import("compact, createCss, splitProps, uniq, withoutSpace", "../helpers")}
1024
1101
 
1025
1102
  export const createRecipe = (name, defaultVariants, compoundVariants) => {
1026
1103
  const getRecipeStyles = (variants) => {
@@ -1067,6 +1144,30 @@ function generateRecipes(ctx) {
1067
1144
  },
1068
1145
  })
1069
1146
  }
1147
+
1148
+ export const mergeRecipes = (recipeA, recipeB) => {
1149
+ if (recipeA && !recipeB) return recipeA
1150
+ if (!recipeA && recipeB) return recipeB
1151
+
1152
+ const recipeFn = (...args) => cx(recipeA(...args), recipeB(...args))
1153
+ const variantKeys = uniq(recipeA.variantKeys, recipeB.variantKeys)
1154
+ const variantMap = variantKeys.reduce((acc, key) => {
1155
+ acc[key] = uniq(recipeA.variantMap[key], recipeB.variantMap[key])
1156
+ return acc
1157
+ }, {})
1158
+
1159
+ return Object.assign(recipeFn, {
1160
+ __recipe__: true,
1161
+ __name__: \`$\{recipeA.__name__} \${recipeB.__name__}\`,
1162
+ raw: (props) => props,
1163
+ variantKeys,
1164
+ variantMap,
1165
+ splitVariantProps(props) {
1166
+ return splitProps(props, variantKeys)
1167
+ },
1168
+ })
1169
+ }
1170
+ }
1070
1171
  `
1071
1172
  };
1072
1173
  return [
@@ -1074,9 +1175,9 @@ function generateRecipes(ctx) {
1074
1175
  ...ctx.recipes.details.map((recipe) => {
1075
1176
  const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
1076
1177
  const { description, defaultVariants, compoundVariants } = config;
1077
- const jsCode = match3(config).when(
1178
+ const jsCode = match4(config).when(
1078
1179
  isSlotRecipe,
1079
- (config2) => outdent11`
1180
+ (config2) => outdent12`
1080
1181
  ${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
1081
1182
  ${ctx.file.import("createRecipe", "./create-recipe")}
1082
1183
 
@@ -1104,9 +1205,9 @@ function generateRecipes(ctx) {
1104
1205
  })
1105
1206
  `
1106
1207
  ).otherwise(
1107
- (config2) => outdent11`
1208
+ (config2) => outdent12`
1108
1209
  ${ctx.file.import("splitProps", "../helpers")}
1109
- ${ctx.file.import("createRecipe", "./create-recipe")}
1210
+ ${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
1110
1211
 
1111
1212
  const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
1112
1213
  defaultVariants ?? {}
@@ -1122,6 +1223,9 @@ function generateRecipes(ctx) {
1122
1223
  raw: (props) => props,
1123
1224
  variantKeys: ${baseName}VariantKeys,
1124
1225
  variantMap: ${baseName}VariantMap,
1226
+ merge(recipe) {
1227
+ return mergeRecipes(this, recipe)
1228
+ },
1125
1229
  splitVariantProps(props) {
1126
1230
  return splitProps(props, ${baseName}VariantKeys)
1127
1231
  },
@@ -1131,10 +1235,9 @@ function generateRecipes(ctx) {
1131
1235
  return {
1132
1236
  name: dashName,
1133
1237
  js: jsCode,
1134
- dts: outdent11`
1238
+ dts: outdent12`
1135
1239
  ${ctx.file.importType("ConditionalValue", "../types/index")}
1136
- ${ctx.file.importType("Pretty", "../types/helpers")}
1137
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
1240
+ ${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
1138
1241
 
1139
1242
  interface ${upperName}Variant {
1140
1243
  ${Object.keys(variantKeyMap).map((key) => {
@@ -1171,10 +1274,10 @@ function generateRecipes(ctx) {
1171
1274
  }
1172
1275
 
1173
1276
  // src/artifacts/js/sva.ts
1174
- import { outdent as outdent12 } from "outdent";
1277
+ import { outdent as outdent13 } from "outdent";
1175
1278
  function generateSvaFn(ctx) {
1176
1279
  return {
1177
- js: outdent12`
1280
+ js: outdent13`
1178
1281
  ${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
1179
1282
  ${ctx.file.import("cva", "./cva")}
1180
1283
 
@@ -1211,7 +1314,7 @@ function generateSvaFn(ctx) {
1211
1314
  })
1212
1315
  }
1213
1316
  `,
1214
- dts: outdent12`
1317
+ dts: outdent13`
1215
1318
  ${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
1216
1319
 
1217
1320
  export declare const sva: SlotRecipeCreatorFn
@@ -1220,7 +1323,7 @@ function generateSvaFn(ctx) {
1220
1323
  }
1221
1324
 
1222
1325
  // src/artifacts/js/token.ts
1223
- import outdent13 from "outdent";
1326
+ import outdent14 from "outdent";
1224
1327
  function generateTokenJs(ctx) {
1225
1328
  const { tokens } = ctx;
1226
1329
  const map = /* @__PURE__ */ new Map();
@@ -1231,7 +1334,7 @@ function generateTokenJs(ctx) {
1231
1334
  });
1232
1335
  const obj = Object.fromEntries(map);
1233
1336
  return {
1234
- js: outdent13`
1337
+ js: outdent14`
1235
1338
  const tokens = ${JSON.stringify(obj, null, 2)}
1236
1339
 
1237
1340
  export function token(path, fallback) {
@@ -1244,7 +1347,7 @@ function generateTokenJs(ctx) {
1244
1347
 
1245
1348
  token.var = tokenVar
1246
1349
  `,
1247
- dts: outdent13`
1350
+ dts: outdent14`
1248
1351
  ${ctx.file.importType("Token", "./tokens")}
1249
1352
 
1250
1353
  export declare const token: {
@@ -1258,49 +1361,54 @@ function generateTokenJs(ctx) {
1258
1361
  }
1259
1362
 
1260
1363
  // src/artifacts/preact-jsx/jsx.ts
1261
- import { outdent as outdent14 } from "outdent";
1364
+ import { outdent as outdent15 } from "outdent";
1262
1365
  function generatePreactJsxFactory(ctx) {
1263
1366
  const { factoryName, componentName } = ctx.jsx;
1264
1367
  return {
1265
- js: outdent14`
1368
+ js: outdent15`
1266
1369
  import { h } from 'preact'
1267
1370
  import { forwardRef } from 'preact/compat'
1268
1371
  import { useMemo } from 'preact/hooks'
1372
+ ${ctx.file.import(
1373
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1374
+ "./factory-helper"
1375
+ )}
1376
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1269
1377
  ${ctx.file.import("css, cx, cva", "../css/index")}
1270
1378
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1271
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1272
-
1273
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1274
1379
 
1275
1380
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1276
1381
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1277
1382
 
1278
1383
  const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1279
1384
  const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1280
-
1385
+
1281
1386
  const defaultProps = Object.assign(
1282
1387
  options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1283
1388
  options.defaultProps,
1284
1389
  )
1285
1390
 
1286
1391
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1287
- const { as: Element = Dynamic, children, ...restProps } = props
1392
+ const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
1393
+
1394
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1395
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1288
1396
 
1289
1397
  const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1290
1398
 
1291
- const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1292
- return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1399
+ const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] = useMemo(() => {
1400
+ return splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
1293
1401
  }, [combinedProps])
1294
1402
 
1295
1403
  function recipeClass() {
1296
1404
  const { css: cssStyles, ...propStyles } = styleProps
1297
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1298
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1405
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
1406
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1299
1407
  }
1300
1408
 
1301
1409
  function cvaClass() {
1302
1410
  const { css: cssStyles, ...propStyles } = styleProps
1303
- const cvaStyles = cvaFn.raw(variantProps)
1411
+ const cvaStyles = __cvaFn__.raw(variantProps)
1304
1412
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1305
1413
  }
1306
1414
 
@@ -1316,8 +1424,13 @@ function generatePreactJsxFactory(ctx) {
1316
1424
  })
1317
1425
  })
1318
1426
 
1319
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1427
+ const name = getDisplayName(Dynamic)
1428
+
1320
1429
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1430
+ ${componentName}.__cva__ = cvaFn
1431
+ ${componentName}.__base__ = Dynamic
1432
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
1433
+
1321
1434
  return ${componentName}
1322
1435
  }
1323
1436
 
@@ -1343,8 +1456,8 @@ function generatePreactJsxFactory(ctx) {
1343
1456
  }
1344
1457
 
1345
1458
  // src/artifacts/preact-jsx/pattern.ts
1346
- import { outdent as outdent15 } from "outdent";
1347
- import { match as match4 } from "ts-pattern";
1459
+ import { outdent as outdent16 } from "outdent";
1460
+ import { match as match5 } from "ts-pattern";
1348
1461
  function generatePreactJsxPattern(ctx) {
1349
1462
  const { typeName, factoryName } = ctx.jsx;
1350
1463
  return ctx.patterns.details.map((pattern) => {
@@ -1352,21 +1465,21 @@ function generatePreactJsxPattern(ctx) {
1352
1465
  const { description, jsxElement = "div" } = pattern.config;
1353
1466
  return {
1354
1467
  name: dashName,
1355
- js: outdent15`
1468
+ js: outdent16`
1356
1469
  import { h } from 'preact'
1357
1470
  import { forwardRef } from 'preact/compat'
1358
1471
  ${ctx.file.import(factoryName, "./factory")}
1359
1472
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1360
1473
 
1361
1474
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1362
- ${match4(props.length).with(
1475
+ ${match5(props.length).with(
1363
1476
  0,
1364
- () => outdent15`
1477
+ () => outdent16`
1365
1478
  const styleProps = ${styleFnName}()
1366
1479
  return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
1367
1480
  `
1368
1481
  ).otherwise(
1369
- () => outdent15`
1482
+ () => outdent16`
1370
1483
  const { ${props.join(", ")}, ...restProps } = props
1371
1484
  const styleProps = ${styleFnName}({${props.join(", ")}})
1372
1485
  return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
@@ -1374,7 +1487,7 @@ function generatePreactJsxPattern(ctx) {
1374
1487
  )}
1375
1488
  })
1376
1489
  `,
1377
- dts: outdent15`
1490
+ dts: outdent16`
1378
1491
  import type { FunctionComponent } from 'preact'
1379
1492
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1380
1493
  ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
@@ -1390,72 +1503,92 @@ function generatePreactJsxPattern(ctx) {
1390
1503
  }
1391
1504
 
1392
1505
  // src/artifacts/preact-jsx/types.ts
1393
- import { outdent as outdent16 } from "outdent";
1506
+ import { outdent as outdent17 } from "outdent";
1394
1507
  function generatePreactJsxTypes(ctx) {
1395
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1508
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1396
1509
  return {
1397
- jsxFactory: outdent16`
1510
+ jsxFactory: outdent17`
1398
1511
  import type { ${upperName} } from '../types/jsx'
1399
1512
  export declare const ${factoryName}: ${upperName}
1400
1513
  `,
1401
- jsxType: outdent16`
1514
+ jsxType: outdent17`
1402
1515
  import type { ComponentProps, JSX } from 'preact'
1403
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
1404
1516
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1517
+ ${ctx.file.importType(
1518
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
1519
+ "./system-types"
1520
+ )}
1405
1521
 
1406
- type ElementType = keyof JSX.IntrinsicElements
1522
+ export type ElementType = JSX.ElementType
1407
1523
 
1408
- type Dict = Record<string, unknown>
1524
+ interface Dict {
1525
+ [k: string]: unknown
1526
+ }
1409
1527
 
1410
1528
  export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1411
1529
  (props: JsxHTMLProps<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
1412
1530
  displayName?: string
1413
1531
  }
1414
1532
 
1415
- interface RecipeFn { __type: any }
1533
+ interface RecipeFn {
1534
+ __type: any
1535
+ }
1416
1536
 
1417
- interface JsxFactoryOptions<TProps extends Dict> {
1537
+ export interface JsxFactoryOptions<TProps extends Dict> {
1418
1538
  dataAttr?: boolean
1419
1539
  defaultProps?: TProps
1420
1540
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1421
1541
  }
1422
1542
 
1423
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1543
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>
1424
1544
 
1425
- interface JsxFactory {
1545
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
1546
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1547
+ : ${componentName}<T, P>
1548
+
1549
+ export interface JsxFactory {
1426
1550
  <T extends ElementType>(component: T): ${componentName}<T, {}>
1427
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1551
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1428
1552
  T,
1429
1553
  RecipeSelection<P>
1430
1554
  >
1431
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1555
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1432
1556
  }
1433
1557
 
1434
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1558
+ export type JsxElements = {
1559
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
1560
+ }
1435
1561
 
1436
1562
  export type ${upperName} = JsxFactory & JsxElements
1437
1563
 
1438
1564
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1565
+
1566
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1439
1567
  `
1440
1568
  };
1441
1569
  }
1442
1570
 
1443
1571
  // src/artifacts/preact-jsx/jsx.string-literal.ts
1444
- import { outdent as outdent17 } from "outdent";
1572
+ import { outdent as outdent18 } from "outdent";
1445
1573
  function generatePreactJsxStringLiteralFactory(ctx) {
1446
1574
  const { factoryName, componentName } = ctx.jsx;
1447
1575
  return {
1448
- js: outdent17`
1576
+ js: outdent18`
1449
1577
  import { h } from 'preact'
1450
1578
  import { forwardRef } from 'preact/compat'
1579
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1451
1580
  ${ctx.file.import("css, cx", "../css/index")}
1452
1581
 
1453
1582
  function createStyledFn(Dynamic) {
1454
1583
  return function styledFn(template) {
1455
- const baseClassName = css(template)
1584
+ const styles = css.raw(template)
1585
+
1456
1586
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1457
- const { as: Element = Dynamic, ...elementProps } = props
1458
- const classes = () => cx(baseClassName, elementProps.className)
1587
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
1588
+
1589
+ function classes() {
1590
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
1591
+ }
1459
1592
 
1460
1593
  return h(Element, {
1461
1594
  ref,
@@ -1464,8 +1597,12 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1464
1597
  })
1465
1598
  })
1466
1599
 
1467
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1600
+ const name = getDisplayName(Dynamic)
1601
+
1468
1602
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1603
+ ${componentName}.__styles__ = styles
1604
+ ${componentName}.__base__ = Dynamic
1605
+
1469
1606
  return ${componentName}
1470
1607
  }
1471
1608
  }
@@ -1492,31 +1629,35 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1492
1629
  }
1493
1630
 
1494
1631
  // src/artifacts/preact-jsx/types.string-literal.ts
1495
- import { outdent as outdent18 } from "outdent";
1632
+ import { outdent as outdent19 } from "outdent";
1496
1633
  function generatePreactJsxStringLiteralTypes(ctx) {
1497
1634
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1498
1635
  return {
1499
- jsxFactory: outdent18`
1636
+ jsxFactory: outdent19`
1500
1637
  ${ctx.file.importType(upperName, "../types/jsx")}
1501
1638
  export declare const ${factoryName}: ${upperName}
1502
1639
  `,
1503
- jsxType: outdent18`
1640
+ jsxType: outdent19`
1504
1641
  import type { ComponentProps, JSX } from 'preact'
1505
1642
 
1506
- type ElementType = keyof JSX.IntrinsicElements
1643
+ export type ElementType = JSX.ElementType
1507
1644
 
1508
- type Dict = Record<string, unknown>
1645
+ interface Dict {
1646
+ [k: string]: unknown
1647
+ }
1509
1648
 
1510
1649
  export type ${componentName}<T extends ElementType> = {
1511
1650
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
1512
1651
  displayName?: string
1513
1652
  }
1514
1653
 
1515
- interface JsxFactory {
1654
+ export interface JsxFactory {
1516
1655
  <T extends ElementType>(component: T): ${componentName}<T>
1517
1656
  }
1518
1657
 
1519
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
1658
+ export type JsxElements = {
1659
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
1660
+ }
1520
1661
 
1521
1662
  export type ${upperName} = JsxFactory & JsxElements
1522
1663
 
@@ -1526,46 +1667,53 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1526
1667
  }
1527
1668
 
1528
1669
  // src/artifacts/qwik-jsx/jsx.ts
1529
- import { outdent as outdent19 } from "outdent";
1670
+ import { outdent as outdent20 } from "outdent";
1530
1671
  function generateQwikJsxFactory(ctx) {
1531
1672
  const { factoryName, componentName } = ctx.jsx;
1532
1673
  return {
1533
- js: outdent19`
1674
+ js: outdent20`
1534
1675
  import { h } from '@builder.io/qwik'
1676
+ ${ctx.file.import(
1677
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1678
+ "./factory-helper"
1679
+ )}
1680
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1535
1681
  ${ctx.file.import("css, cx, cva", "../css/index")}
1536
1682
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1537
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1538
1683
 
1539
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1540
-
1541
1684
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1542
1685
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1543
1686
 
1544
1687
  const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1545
1688
  const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1546
-
1689
+
1547
1690
  const defaultProps = Object.assign(
1548
1691
  options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1549
1692
  options.defaultProps,
1550
1693
  )
1551
1694
 
1552
1695
  const ${componentName} = function ${componentName}(props) {
1553
- const { as: Element = Dynamic, children, className, ...restProps } = props
1696
+ const { as: Element = Dynamic.__base__ || Dynamic, children, className, ...restProps } = props
1697
+
1698
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1699
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1554
1700
 
1555
1701
  const combinedProps = Object.assign({}, defaultProps, restProps)
1556
-
1557
- const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
1558
- splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1702
+
1703
+ const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] =
1704
+ splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
1559
1705
 
1560
1706
  const { css: cssStyles, ...propStyles } = styleProps
1561
1707
 
1562
1708
  function recipeClass() {
1563
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1564
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1709
+ const { css: cssStyles, ...propStyles } = styleProps
1710
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
1711
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1565
1712
  }
1566
1713
 
1567
1714
  function cvaClass() {
1568
- const cvaStyles = cvaFn.raw(variantProps)
1715
+ const { css: cssStyles, ...propStyles } = styleProps
1716
+ const cvaStyles = __cvaFn__.raw(variantProps)
1569
1717
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
1570
1718
  }
1571
1719
 
@@ -1580,8 +1728,13 @@ function generateQwikJsxFactory(ctx) {
1580
1728
  })
1581
1729
  }
1582
1730
 
1583
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1731
+ const name = getDisplayName(Dynamic)
1732
+
1584
1733
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1734
+ ${componentName}.__cva__ = cvaFn
1735
+ ${componentName}.__base__ = Dynamic
1736
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
1737
+
1585
1738
  return ${componentName}
1586
1739
  }
1587
1740
 
@@ -1608,8 +1761,8 @@ function generateQwikJsxFactory(ctx) {
1608
1761
  }
1609
1762
 
1610
1763
  // src/artifacts/qwik-jsx/pattern.ts
1611
- import { outdent as outdent20 } from "outdent";
1612
- import { match as match5 } from "ts-pattern";
1764
+ import { outdent as outdent21 } from "outdent";
1765
+ import { match as match6 } from "ts-pattern";
1613
1766
  function generateQwikJsxPattern(ctx) {
1614
1767
  const { typeName, factoryName } = ctx.jsx;
1615
1768
  return ctx.patterns.details.map((pattern) => {
@@ -1617,20 +1770,20 @@ function generateQwikJsxPattern(ctx) {
1617
1770
  const { description, jsxElement = "div" } = pattern.config;
1618
1771
  return {
1619
1772
  name: dashName,
1620
- js: outdent20`
1773
+ js: outdent21`
1621
1774
  import { h } from '@builder.io/qwik'
1622
1775
  ${ctx.file.import(factoryName, "./factory")}
1623
1776
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1624
1777
 
1625
1778
  export const ${jsxName} = function ${jsxName}(props) {
1626
- ${match5(props.length).with(
1779
+ ${match6(props.length).with(
1627
1780
  0,
1628
- () => outdent20`
1781
+ () => outdent21`
1629
1782
  const styleProps = ${styleFnName}()
1630
1783
  return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
1631
1784
  `
1632
1785
  ).otherwise(
1633
- () => outdent20`
1786
+ () => outdent21`
1634
1787
  const { ${props.join(", ")}, ...restProps } = props
1635
1788
  const styleProps = ${styleFnName}({${props.join(", ")}})
1636
1789
  return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
@@ -1638,7 +1791,7 @@ function generateQwikJsxPattern(ctx) {
1638
1791
  )}
1639
1792
  }
1640
1793
  `,
1641
- dts: outdent20`
1794
+ dts: outdent21`
1642
1795
  import type { Component } from '@builder.io/qwik'
1643
1796
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1644
1797
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -1654,20 +1807,23 @@ function generateQwikJsxPattern(ctx) {
1654
1807
  }
1655
1808
 
1656
1809
  // src/artifacts/qwik-jsx/types.ts
1657
- import { outdent as outdent21 } from "outdent";
1810
+ import { outdent as outdent22 } from "outdent";
1658
1811
  function generateQwikJsxTypes(ctx) {
1659
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1812
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1660
1813
  return {
1661
- jsxFactory: outdent21`
1814
+ jsxFactory: outdent22`
1662
1815
  ${ctx.file.importType(upperName, "../types/jsx")}
1663
1816
  export declare const ${factoryName}: ${upperName}
1664
1817
  `,
1665
- jsxType: outdent21`
1818
+ jsxType: outdent22`
1666
1819
  import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
1667
- import type { Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
1668
- import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
1820
+ ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1821
+ ${ctx.file.importType(
1822
+ "Assign, DistributiveOmit, DistributiveUnion, JsxStyleProps, PatchedHTMLProps, Pretty",
1823
+ "./system-types"
1824
+ )}
1669
1825
 
1670
- type ElementType = keyof QwikIntrinsicElements | Component<any>
1826
+ export type ElementType = keyof QwikIntrinsicElements | Component<any>
1671
1827
 
1672
1828
  export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
1673
1829
  ? QwikIntrinsicElements[T]
@@ -1675,13 +1831,17 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
1675
1831
  ? P
1676
1832
  : never
1677
1833
 
1678
- type Dict = Record<string, unknown>
1834
+ interface Dict {
1835
+ [k: string]: unknown
1836
+ }
1679
1837
 
1680
1838
  export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T>, Assign<PatchedHTMLProps, Assign<JsxStyleProps, P>>>> {}
1681
1839
 
1682
- interface RecipeFn { __type: any }
1840
+ interface RecipeFn {
1841
+ __type: any
1842
+ }
1683
1843
 
1684
- interface JsxFactoryOptions<TProps extends Dict> {
1844
+ export interface JsxFactoryOptions<TProps extends Dict> {
1685
1845
  dataAttr?: boolean
1686
1846
  defaultProps?: TProps
1687
1847
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -1689,48 +1849,65 @@ interface JsxFactoryOptions<TProps extends Dict> {
1689
1849
 
1690
1850
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1691
1851
 
1692
- interface JsxFactory {
1852
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
1853
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1854
+ : ${componentName}<T, P>
1855
+
1856
+ export interface JsxFactory {
1693
1857
  <T extends ElementType>(component: T): ${componentName}<T, {}>
1694
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1858
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1695
1859
  T,
1696
1860
  RecipeSelection<P>
1697
1861
  >
1698
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1862
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1699
1863
  }
1700
1864
 
1701
- type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
1865
+ export type JsxElements = {
1866
+ [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}>
1867
+ }
1702
1868
 
1703
1869
  export type ${upperName} = JsxFactory & JsxElements
1704
1870
 
1705
1871
  export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
1872
+
1873
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1706
1874
  `
1707
1875
  };
1708
1876
  }
1709
1877
 
1710
1878
  // src/artifacts/qwik-jsx/jsx.string-literal.ts
1711
- import { outdent as outdent22 } from "outdent";
1879
+ import { outdent as outdent23 } from "outdent";
1712
1880
  function generateQwikJsxStringLiteralFactory(ctx) {
1713
1881
  const { factoryName, componentName } = ctx.jsx;
1714
1882
  return {
1715
- js: outdent22`
1883
+ js: outdent23`
1716
1884
  import { h } from '@builder.io/qwik'
1885
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1717
1886
  ${ctx.file.import("css, cx", "../css/index")}
1718
1887
 
1719
1888
  function createStyledFn(Dynamic) {
1720
1889
  return function styledFn(template) {
1721
- const baseClassName = css(template)
1722
- const ${componentName} = function ${componentName}(props) {
1723
- const { as: Element = Dynamic, ...elementProps } = props
1724
- const classes = () => cx(baseClassName, elementProps.className)
1725
-
1726
- return h(Element, {
1727
- ...elementProps,
1728
- className: classes(),
1729
- })
1890
+ const styles = css.raw(template)
1891
+
1892
+ const ${componentName} = (props) => {
1893
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
1894
+
1895
+ function classes() {
1896
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
1897
+ }
1898
+
1899
+ return h(Element, {
1900
+ ...elementProps,
1901
+ className: classes(),
1902
+ })
1730
1903
  }
1731
1904
 
1732
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1905
+ const name = getDisplayName(Dynamic)
1906
+
1733
1907
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1908
+ ${componentName}.__styles__ = styles
1909
+ ${componentName}.__base__ = Dynamic
1910
+
1734
1911
  return ${componentName}
1735
1912
  }
1736
1913
  }
@@ -1758,18 +1935,18 @@ function generateQwikJsxStringLiteralFactory(ctx) {
1758
1935
  }
1759
1936
 
1760
1937
  // src/artifacts/qwik-jsx/types.string-literal.ts
1761
- import { outdent as outdent23 } from "outdent";
1938
+ import { outdent as outdent24 } from "outdent";
1762
1939
  function generateQwikJsxStringLiteralTypes(ctx) {
1763
1940
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1764
1941
  return {
1765
- jsxFactory: outdent23`
1942
+ jsxFactory: outdent24`
1766
1943
  ${ctx.file.importType(upperName, "../types/jsx")}
1767
1944
  export declare const ${factoryName}: ${upperName}
1768
1945
  `,
1769
- jsxType: outdent23`
1946
+ jsxType: outdent24`
1770
1947
  import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
1771
1948
 
1772
- type ElementType = keyof QwikIntrinsicElements | Component<any>
1949
+ export type ElementType = keyof QwikIntrinsicElements | Component<any>
1773
1950
 
1774
1951
  export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
1775
1952
  ? QwikIntrinsicElements[T]
@@ -1777,17 +1954,21 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
1777
1954
  ? P
1778
1955
  : never
1779
1956
 
1780
- type Dict = Record<string, unknown>
1957
+ interface Dict {
1958
+ [k: string]: unknown
1959
+ }
1781
1960
 
1782
1961
  export type ${componentName}<T extends ElementType> = {
1783
1962
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
1784
1963
  }
1785
1964
 
1786
- interface JsxFactory {
1965
+ export interface JsxFactory {
1787
1966
  <T extends ElementType>(component: T): ${componentName}<T>
1788
1967
  }
1789
1968
 
1790
- type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
1969
+ export type JsxElements = {
1970
+ [K in keyof QwikIntrinsicElements]: ${componentName}<K>
1971
+ }
1791
1972
 
1792
1973
  export type ${upperName} = JsxFactory & JsxElements
1793
1974
 
@@ -1797,47 +1978,52 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1797
1978
  }
1798
1979
 
1799
1980
  // src/artifacts/react-jsx/jsx.ts
1800
- import { outdent as outdent24 } from "outdent";
1981
+ import { outdent as outdent25 } from "outdent";
1801
1982
  function generateReactJsxFactory(ctx) {
1802
1983
  const { factoryName, componentName } = ctx.jsx;
1803
1984
  return {
1804
- js: outdent24`
1985
+ js: outdent25`
1805
1986
  import { createElement, forwardRef, useMemo } from 'react'
1806
1987
  ${ctx.file.import("css, cx, cva", "../css/index")}
1988
+ ${ctx.file.import(
1989
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1990
+ "./factory-helper"
1991
+ )}
1807
1992
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1808
1993
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1809
1994
 
1810
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1811
-
1812
1995
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1813
1996
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1814
1997
 
1815
1998
  const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1816
1999
  const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1817
-
2000
+
1818
2001
  const defaultProps = Object.assign(
1819
2002
  options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1820
2003
  options.defaultProps,
1821
2004
  )
1822
2005
 
1823
2006
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1824
- const { as: Element = Dynamic, children, ...restProps } = props
2007
+ const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
2008
+
2009
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2010
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1825
2011
 
1826
2012
  const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1827
2013
 
1828
- const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1829
- return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2014
+ const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] = useMemo(() => {
2015
+ return splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
1830
2016
  }, [combinedProps])
1831
2017
 
1832
2018
  function recipeClass() {
1833
2019
  const { css: cssStyles, ...propStyles } = styleProps
1834
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1835
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
2020
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
2021
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
1836
2022
  }
1837
2023
 
1838
2024
  function cvaClass() {
1839
2025
  const { css: cssStyles, ...propStyles } = styleProps
1840
- const cvaStyles = cvaFn.raw(variantProps)
2026
+ const cvaStyles = __cvaFn__.raw(variantProps)
1841
2027
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
1842
2028
  }
1843
2029
 
@@ -1853,8 +2039,13 @@ function generateReactJsxFactory(ctx) {
1853
2039
  })
1854
2040
  })
1855
2041
 
1856
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2042
+ const name = getDisplayName(Dynamic)
2043
+
1857
2044
  ${componentName}.displayName = \`${factoryName}.\${name}\`
2045
+ ${componentName}.__cva__ = cvaFn
2046
+ ${componentName}.__base__ = Dynamic
2047
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2048
+
1858
2049
  return ${componentName}
1859
2050
  }
1860
2051
 
@@ -1881,8 +2072,8 @@ function generateReactJsxFactory(ctx) {
1881
2072
  }
1882
2073
 
1883
2074
  // src/artifacts/react-jsx/pattern.ts
1884
- import { outdent as outdent25 } from "outdent";
1885
- import { match as match6 } from "ts-pattern";
2075
+ import { outdent as outdent26 } from "outdent";
2076
+ import { match as match7 } from "ts-pattern";
1886
2077
  function generateReactJsxPattern(ctx) {
1887
2078
  const { typeName, factoryName } = ctx.jsx;
1888
2079
  return ctx.patterns.details.map((pattern) => {
@@ -1890,20 +2081,20 @@ function generateReactJsxPattern(ctx) {
1890
2081
  const { description, jsxElement = "div" } = pattern.config;
1891
2082
  return {
1892
2083
  name: dashName,
1893
- js: outdent25`
2084
+ js: outdent26`
1894
2085
  import { createElement, forwardRef } from 'react'
1895
2086
  ${ctx.file.import(factoryName, "./factory")}
1896
2087
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1897
2088
 
1898
2089
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1899
- ${match6(props.length).with(
2090
+ ${match7(props.length).with(
1900
2091
  0,
1901
- () => outdent25`
2092
+ () => outdent26`
1902
2093
  const styleProps = ${styleFnName}()
1903
2094
  return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
1904
2095
  `
1905
2096
  ).otherwise(
1906
- () => outdent25`
2097
+ () => outdent26`
1907
2098
  const { ${props.join(", ")}, ...restProps } = props
1908
2099
  const styleProps = ${styleFnName}({${props.join(", ")}})
1909
2100
  return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
@@ -1911,7 +2102,7 @@ function generateReactJsxPattern(ctx) {
1911
2102
  )}
1912
2103
  })
1913
2104
  `,
1914
- dts: outdent25`
2105
+ dts: outdent26`
1915
2106
  import type { FunctionComponent } from 'react'
1916
2107
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1917
2108
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -1927,20 +2118,25 @@ function generateReactJsxPattern(ctx) {
1927
2118
  }
1928
2119
 
1929
2120
  // src/artifacts/react-jsx/types.ts
1930
- import { outdent as outdent26 } from "outdent";
2121
+ import { outdent as outdent27 } from "outdent";
1931
2122
  function generateReactJsxTypes(ctx) {
1932
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2123
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1933
2124
  return {
1934
- jsxFactory: outdent26`
2125
+ jsxFactory: outdent27`
1935
2126
  ${ctx.file.importType(upperName, "../types/jsx")}
1936
2127
  export declare const ${factoryName}: ${upperName}
1937
2128
  `,
1938
- jsxType: outdent26`
2129
+ jsxType: outdent27`
1939
2130
  import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
1940
- ${ctx.file.importType("Assign, DistributiveOmit, JsxHTMLProps, JsxStyleProps", "./system-types")}
1941
2131
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2132
+ ${ctx.file.importType(
2133
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2134
+ "./system-types"
2135
+ )}
1942
2136
 
1943
- type Dict = Record<string, unknown>
2137
+ interface Dict {
2138
+ [k: string]: unknown
2139
+ }
1944
2140
 
1945
2141
  export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
1946
2142
  ref?: Ref<ElementRef<T>>
@@ -1951,7 +2147,9 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1951
2147
  displayName?: string
1952
2148
  }
1953
2149
 
1954
- interface RecipeFn { __type: any }
2150
+ interface RecipeFn {
2151
+ __type: any
2152
+ }
1955
2153
 
1956
2154
  interface JsxFactoryOptions<TProps extends Dict> {
1957
2155
  dataAttr?: boolean
@@ -1961,49 +2159,66 @@ interface JsxFactoryOptions<TProps extends Dict> {
1961
2159
 
1962
2160
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1963
2161
 
1964
- interface JsxFactory {
2162
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2163
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2164
+ : ${componentName}<T, P>
2165
+
2166
+ export interface JsxFactory {
1965
2167
  <T extends ElementType>(component: T): ${componentName}<T, {}>
1966
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2168
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1967
2169
  T,
1968
2170
  RecipeSelection<P>
1969
2171
  >
1970
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2172
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1971
2173
  }
1972
2174
 
1973
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2175
+ export type JsxElements = {
2176
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2177
+ }
1974
2178
 
1975
2179
  export type ${upperName} = JsxFactory & JsxElements
1976
2180
 
1977
2181
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2182
+
2183
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1978
2184
  `
1979
2185
  };
1980
2186
  }
1981
2187
 
1982
2188
  // src/artifacts/react-jsx/jsx.string-literal.ts
1983
- import { outdent as outdent27 } from "outdent";
2189
+ import { outdent as outdent28 } from "outdent";
1984
2190
  function generateReactJsxStringLiteralFactory(ctx) {
1985
2191
  const { factoryName, componentName } = ctx.jsx;
1986
2192
  return {
1987
- js: outdent27`
2193
+ js: outdent28`
1988
2194
  import { createElement, forwardRef } from 'react'
2195
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1989
2196
  ${ctx.file.import("css, cx", "../css/index")}
1990
2197
 
1991
2198
  function createStyledFn(Dynamic) {
1992
2199
  return function styledFn(template) {
1993
- const baseClassName = css(template)
2200
+ const styles = css.raw(template)
2201
+
1994
2202
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1995
- const { as: Element = Dynamic, ...elementProps } = props
1996
- const classes = () => cx(baseClassName, elementProps.className)
2203
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
2204
+
2205
+ function classes() {
2206
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
2207
+ }
1997
2208
 
1998
- return createElement(Element, {
1999
- ref,
2000
- ...elementProps,
2001
- className: classes(),
2002
- })
2209
+ return createElement(Element, {
2210
+ ref,
2211
+ ...elementProps,
2212
+ className: classes(),
2213
+ })
2003
2214
  })
2004
2215
 
2005
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2216
+ const name = getDisplayName(Dynamic)
2217
+
2006
2218
  ${componentName}.displayName = \`${factoryName}.\${name}\`
2219
+ ${componentName}.__styles__ = styles
2220
+ ${componentName}.__base__ = Dynamic
2221
+
2007
2222
  return ${componentName}
2008
2223
  }
2009
2224
  }
@@ -2031,19 +2246,21 @@ function generateReactJsxStringLiteralFactory(ctx) {
2031
2246
  }
2032
2247
 
2033
2248
  // src/artifacts/react-jsx/types.string-literal.ts
2034
- import { outdent as outdent28 } from "outdent";
2249
+ import { outdent as outdent29 } from "outdent";
2035
2250
  function generateReactJsxStringLiteralTypes(ctx) {
2036
2251
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2037
2252
  return {
2038
- jsxFactory: outdent28`
2253
+ jsxFactory: outdent29`
2039
2254
  ${ctx.file.importType(upperName, "../types/jsx")}
2040
2255
  export declare const ${factoryName}: ${upperName}
2041
2256
  `,
2042
- jsxType: outdent28`
2257
+ jsxType: outdent29`
2043
2258
  import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
2044
2259
  ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
2045
2260
 
2046
- type Dict = Record<string, unknown>
2261
+ interface Dict {
2262
+ [k: string]: unknown
2263
+ }
2047
2264
 
2048
2265
  export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
2049
2266
  ref?: Ref<ElementRef<T>>
@@ -2054,11 +2271,13 @@ export type ${componentName}<T extends ElementType> = {
2054
2271
  displayName?: string
2055
2272
  }
2056
2273
 
2057
- interface JsxFactory {
2274
+ export interface JsxFactory {
2058
2275
  <T extends ElementType>(component: T): ${componentName}<T>
2059
2276
  }
2060
2277
 
2061
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2278
+ export type JsxElements = {
2279
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
2280
+ }
2062
2281
 
2063
2282
  export type ${upperName} = JsxFactory & JsxElements
2064
2283
 
@@ -2068,53 +2287,61 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
2068
2287
  }
2069
2288
 
2070
2289
  // src/artifacts/solid-jsx/jsx.ts
2071
- import { outdent as outdent29 } from "outdent";
2290
+ import { outdent as outdent30 } from "outdent";
2072
2291
  function generateSolidJsxFactory(ctx) {
2073
2292
  const { componentName, factoryName } = ctx.jsx;
2074
2293
  return {
2075
- js: outdent29`
2294
+ js: outdent30`
2076
2295
  import { Dynamic } from 'solid-js/web'
2077
2296
  import { createMemo, mergeProps, splitProps } from 'solid-js'
2078
2297
  import { createComponent } from 'solid-js/web'
2298
+ ${ctx.file.import(
2299
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
2300
+ "./factory-helper"
2301
+ )}
2302
+ ${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
2079
2303
  ${ctx.file.import("css, cx, cva", "../css/index")}
2080
2304
  ${ctx.file.import("normalizeHTMLProps", "../helpers")}
2081
- ${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
2082
-
2083
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2084
-
2305
+
2085
2306
  function styledFn(element, configOrCva = {}, options = {}) {
2086
2307
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2087
2308
 
2088
2309
  const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2089
2310
  const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2090
-
2311
+
2091
2312
  const defaultProps = Object.assign(
2092
2313
  options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2093
2314
  options.defaultProps,
2094
2315
  )
2095
2316
 
2096
- return function ${componentName}(props) {
2097
- const mergedProps = mergeProps({ as: element }, defaultProps, props)
2098
- const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
2317
+ const ${componentName} = (props) => {
2318
+ const mergedProps = mergeProps({ as: element.__base__ || element }, defaultProps, props)
2319
+
2320
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2321
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
2099
2322
 
2100
- const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2323
+ const forwardedKeys = createMemo(() =>
2324
+ Object.keys(props).filter((prop) => !normalizeHTMLProps.keys.includes(prop) && shouldForwardProp(prop)),
2325
+ )
2326
+
2327
+ const [localProps, htmlProps, forwardedProps, variantProps, styleProps, elementProps] = splitProps(
2101
2328
  mergedProps,
2102
2329
  ['as', 'class', 'className'],
2330
+ normalizeHTMLProps.keys,
2103
2331
  forwardedKeys(),
2104
- cvaFn.variantKeys,
2332
+ __cvaFn__.variantKeys,
2105
2333
  allCssProperties,
2106
- normalizeHTMLProps.keys
2107
2334
  )
2108
2335
 
2109
2336
  function recipeClass() {
2110
2337
  const { css: cssStyles, ...propStyles } = styleProps
2111
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2112
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
2338
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
2339
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
2113
2340
  }
2114
2341
 
2115
2342
  function cvaClass() {
2116
2343
  const { css: cssStyles, ...propStyles } = styleProps
2117
- const cvaStyles = cvaFn.raw(variantProps)
2344
+ const cvaStyles = __cvaFn__.raw(variantProps)
2118
2345
  return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
2119
2346
  }
2120
2347
 
@@ -2141,6 +2368,15 @@ function generateSolidJsxFactory(ctx) {
2141
2368
  )
2142
2369
  )
2143
2370
  }
2371
+
2372
+ const name = getDisplayName(element)
2373
+
2374
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2375
+ ${componentName}.__cva__ = cvaFn
2376
+ ${componentName}.__base__ = element
2377
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2378
+
2379
+ return ${componentName}
2144
2380
  }
2145
2381
 
2146
2382
  function createJsxFactory() {
@@ -2165,8 +2401,8 @@ function generateSolidJsxFactory(ctx) {
2165
2401
  }
2166
2402
 
2167
2403
  // src/artifacts/solid-jsx/pattern.ts
2168
- import { outdent as outdent30 } from "outdent";
2169
- import { match as match7 } from "ts-pattern";
2404
+ import { outdent as outdent31 } from "outdent";
2405
+ import { match as match8 } from "ts-pattern";
2170
2406
  function generateSolidJsxPattern(ctx) {
2171
2407
  const { typeName, factoryName } = ctx.jsx;
2172
2408
  return ctx.patterns.details.map((pattern) => {
@@ -2174,21 +2410,21 @@ function generateSolidJsxPattern(ctx) {
2174
2410
  const { description, jsxElement = "div" } = pattern.config;
2175
2411
  return {
2176
2412
  name: dashName,
2177
- js: outdent30`
2413
+ js: outdent31`
2178
2414
  import { splitProps, mergeProps } from 'solid-js'
2179
2415
  import { createComponent } from 'solid-js/web'
2180
2416
  ${ctx.file.import(factoryName, "./factory")}
2181
2417
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2182
2418
 
2183
2419
  export function ${jsxName}(props) {
2184
- ${match7(props.length).with(
2420
+ ${match8(props.length).with(
2185
2421
  0,
2186
- () => outdent30`
2422
+ () => outdent31`
2187
2423
  const styleProps = ${styleFnName}()
2188
2424
  return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
2189
2425
  `
2190
2426
  ).otherwise(
2191
- () => outdent30`
2427
+ () => outdent31`
2192
2428
  const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
2193
2429
  const styleProps = ${styleFnName}(patternProps)
2194
2430
  return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
@@ -2196,7 +2432,7 @@ function generateSolidJsxPattern(ctx) {
2196
2432
  )}
2197
2433
  }
2198
2434
  `,
2199
- dts: outdent30`
2435
+ dts: outdent31`
2200
2436
  import type { Component } from 'solid-js'
2201
2437
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2202
2438
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -2212,31 +2448,38 @@ function generateSolidJsxPattern(ctx) {
2212
2448
  }
2213
2449
 
2214
2450
  // src/artifacts/solid-jsx/types.ts
2215
- import { outdent as outdent31 } from "outdent";
2451
+ import { outdent as outdent32 } from "outdent";
2216
2452
  function generateSolidJsxTypes(ctx) {
2217
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2453
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2218
2454
  return {
2219
- jsxFactory: outdent31`
2455
+ jsxFactory: outdent32`
2220
2456
  ${ctx.file.importType(upperName, "../types/jsx")}
2221
2457
  export declare const ${factoryName}: ${upperName}
2222
2458
  `,
2223
- jsxType: outdent31`
2459
+ jsxType: outdent32`
2224
2460
  import type { ComponentProps, Component, JSX } from 'solid-js'
2225
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
2226
2461
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2462
+ ${ctx.file.importType(
2463
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2464
+ "./system-types"
2465
+ )}
2227
2466
 
2228
- type Dict = Record<string, unknown>
2467
+ interface Dict {
2468
+ [k: string]: unknown
2469
+ }
2229
2470
 
2230
- type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2471
+ export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2231
2472
 
2232
2473
  export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2233
2474
  (props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
2234
2475
  displayName?: string
2235
2476
  }
2236
2477
 
2237
- interface RecipeFn { __type: any }
2478
+ interface RecipeFn {
2479
+ __type: any
2480
+ }
2238
2481
 
2239
- interface JsxFactoryOptions<TProps extends Dict> {
2482
+ export interface JsxFactoryOptions<TProps extends Dict> {
2240
2483
  dataAttr?: boolean
2241
2484
  defaultProps?: TProps
2242
2485
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -2244,41 +2487,51 @@ interface JsxFactoryOptions<TProps extends Dict> {
2244
2487
 
2245
2488
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
2246
2489
 
2247
- interface JsxFactory {
2490
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2491
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2492
+ : ${componentName}<T, P>
2493
+
2494
+ export interface JsxFactory {
2248
2495
  <T extends ElementType>(component: T): ${componentName}<T, {}>
2249
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2496
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2250
2497
  T,
2251
2498
  RecipeSelection<P>
2252
2499
  >
2253
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2500
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
2254
2501
  }
2255
2502
 
2256
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2503
+ export type JsxElements = {
2504
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2505
+ }
2257
2506
 
2258
2507
  export type ${upperName} = JsxFactory & JsxElements
2259
2508
 
2260
2509
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2510
+
2511
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2261
2512
  `
2262
2513
  };
2263
2514
  }
2264
2515
 
2265
2516
  // src/artifacts/solid-jsx/jsx.string-literal.ts
2266
- import { outdent as outdent32 } from "outdent";
2517
+ import { outdent as outdent33 } from "outdent";
2267
2518
  function generateSolidJsxStringLiteralFactory(ctx) {
2268
2519
  const { componentName, factoryName } = ctx.jsx;
2269
2520
  return {
2270
- js: outdent32`
2521
+ js: outdent33`
2271
2522
  import { mergeProps, splitProps } from 'solid-js'
2272
2523
  import { Dynamic, createComponent } from 'solid-js/web'
2524
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
2273
2525
  ${ctx.file.import("css, cx", "../css/index")}
2274
2526
 
2275
2527
  function createStyled(element) {
2276
2528
  return function styledFn(template) {
2277
- const baseClassName = css(template)
2278
- return function ${componentName}(props) {
2279
- const mergedProps = mergeProps({ as: element }, props)
2280
- const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
2529
+ const styles = css.raw(template)
2281
2530
 
2531
+ const ${componentName} = (props) => {
2532
+ const mergedProps = mergeProps({ as: element.__base__ || element }, props)
2533
+ const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
2534
+
2282
2535
  return createComponent(
2283
2536
  Dynamic,
2284
2537
  mergeProps(
@@ -2287,13 +2540,21 @@ function createStyled(element) {
2287
2540
  return localProps.as
2288
2541
  },
2289
2542
  get class() {
2290
- return cx(baseClassName, localProps.class)
2543
+ return cx(css(element.__styles__, styles), localProps.class)
2291
2544
  },
2292
2545
  },
2293
2546
  elementProps,
2294
2547
  ),
2295
2548
  )
2296
2549
  }
2550
+
2551
+ const name = getDisplayName(element)
2552
+
2553
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2554
+ ${componentName}.__styles__ = styles
2555
+ ${componentName}.__base__ = element
2556
+
2557
+ return ${componentName}
2297
2558
  }
2298
2559
  }
2299
2560
 
@@ -2319,31 +2580,35 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2319
2580
  }
2320
2581
 
2321
2582
  // src/artifacts/solid-jsx/types.string-literal.ts
2322
- import { outdent as outdent33 } from "outdent";
2583
+ import { outdent as outdent34 } from "outdent";
2323
2584
  function generateSolidJsxStringLiteralTypes(ctx) {
2324
2585
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2325
2586
  return {
2326
- jsxFactory: outdent33`
2587
+ jsxFactory: outdent34`
2327
2588
  ${ctx.file.importType(upperName, "../types/jsx")}
2328
2589
  export declare const ${factoryName}: ${upperName}
2329
2590
  `,
2330
- jsxType: outdent33`
2591
+ jsxType: outdent34`
2331
2592
  import type { Component, ComponentProps, JSX } from 'solid-js'
2332
2593
 
2333
- type Dict = Record<string, unknown>
2594
+ interface Dict {
2595
+ [k: string]: unknown
2596
+ }
2334
2597
 
2335
- type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2598
+ export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2336
2599
 
2337
2600
  export type ${componentName}<T extends ElementType> = {
2338
2601
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
2339
2602
  displayName?: string
2340
2603
  }
2341
2604
 
2342
- interface JsxFactory {
2605
+ export interface JsxFactory {
2343
2606
  <T extends ElementType>(component: T): ${componentName}<T>
2344
2607
  }
2345
2608
 
2346
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2609
+ export type JsxElements = {
2610
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
2611
+ }
2347
2612
 
2348
2613
  export type ${upperName} = JsxFactory & JsxElements
2349
2614
 
@@ -2353,60 +2618,65 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
2353
2618
  }
2354
2619
 
2355
2620
  // src/artifacts/vue-jsx/jsx.ts
2356
- import { outdent as outdent34 } from "outdent";
2621
+ import { outdent as outdent35 } from "outdent";
2357
2622
  function generateVueJsxFactory(ctx) {
2358
- const { factoryName } = ctx.jsx;
2623
+ const { factoryName, componentName } = ctx.jsx;
2359
2624
  return {
2360
- js: outdent34`
2625
+ js: outdent35`
2361
2626
  import { defineComponent, h, computed } from 'vue'
2627
+ ${ctx.file.import(
2628
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
2629
+ "./factory-helper"
2630
+ )}
2631
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2362
2632
  ${ctx.file.import("css, cx, cva", "../css/index")}
2363
2633
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
2364
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2365
2634
 
2366
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2367
-
2368
2635
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
2369
2636
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2370
-
2637
+
2371
2638
  const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2372
2639
  const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2373
-
2640
+
2374
2641
  const defaultProps = Object.assign(
2375
2642
  options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2376
2643
  options.defaultProps,
2377
2644
  )
2378
-
2379
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2380
2645
 
2381
- return defineComponent({
2646
+ const name = getDisplayName(Dynamic)
2647
+
2648
+ const ${componentName} = defineComponent({
2382
2649
  name: \`${factoryName}.\${name}\`,
2383
2650
  inheritAttrs: false,
2384
- props: { as: { type: [String, Object], default: Dynamic } },
2651
+ props: { as: { type: [String, Object], default: Dynamic.__base__ || Dynamic } },
2385
2652
  setup(props, { slots, attrs }) {
2653
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2654
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
2655
+
2386
2656
  const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
2387
-
2657
+
2388
2658
  const splittedProps = computed(() => {
2389
- return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2659
+ return splitProps(combinedProps.value, normalizeHTMLProps.keys, shouldForwardProp, __cvaFn__.variantKeys, isCssProperty)
2390
2660
  })
2391
2661
 
2392
2662
  const recipeClass = computed(() => {
2393
- const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2663
+ const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
2394
2664
  const { css: cssStyles, ...propStyles } = styleProps
2395
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2396
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2665
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
2666
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2397
2667
  })
2398
2668
 
2399
2669
  const cvaClass = computed(() => {
2400
- const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2670
+ const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
2401
2671
  const { css: cssStyles, ...propStyles } = styleProps
2402
- const cvaStyles = cvaFn.raw(variantProps)
2672
+ const cvaStyles = __cvaFn__.raw(variantProps)
2403
2673
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
2404
2674
  })
2405
2675
 
2406
2676
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
2407
2677
 
2408
2678
  return () => {
2409
- const [forwardedProps, _variantProps, _styleProps, htmlProps, elementProps] = splittedProps.value
2679
+ const [htmlProps, forwardedProps, _variantProps, _styleProps, elementProps] = splittedProps.value
2410
2680
  return h(
2411
2681
  props.as,
2412
2682
  {
@@ -2420,6 +2690,13 @@ function generateVueJsxFactory(ctx) {
2420
2690
  }
2421
2691
  },
2422
2692
  })
2693
+
2694
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2695
+ ${componentName}.__cva__ = cvaFn
2696
+ ${componentName}.__base__ = Dynamic
2697
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2698
+
2699
+ return ${componentName}
2423
2700
  }
2424
2701
 
2425
2702
  function createJsxFactory() {
@@ -2440,25 +2717,30 @@ function generateVueJsxFactory(ctx) {
2440
2717
  }
2441
2718
 
2442
2719
  // src/artifacts/vue-jsx/jsx.string-literal.ts
2443
- import { outdent as outdent35 } from "outdent";
2720
+ import { outdent as outdent36 } from "outdent";
2444
2721
  function generateVueJsxStringLiteralFactory(ctx) {
2445
- const { factoryName } = ctx.jsx;
2722
+ const { componentName, factoryName } = ctx.jsx;
2446
2723
  return {
2447
- js: outdent35`
2724
+ js: outdent36`
2448
2725
  import { defineComponent, h, computed } from 'vue'
2726
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
2449
2727
  ${ctx.file.import("css, cx", "../css/index")}
2450
2728
 
2451
2729
  function createStyled(Dynamic) {
2452
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2730
+ const name = getDisplayName(Dynamic)
2453
2731
 
2454
2732
  function styledFn(template) {
2455
- const baseClassName = css(template)
2456
- return defineComponent({
2733
+ const styles = css.raw(template)
2734
+
2735
+ const ${componentName} = defineComponent({
2457
2736
  name: \`${factoryName}.\${name}\`,
2458
2737
  inheritAttrs: false,
2459
2738
  props: { as: { type: [String, Object], default: Dynamic } },
2460
2739
  setup(props, { slots, attrs }) {
2461
- const classes = computed(() => cx(baseClassName, elementProps.className))
2740
+ const classes = computed(() => {
2741
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
2742
+ })
2743
+
2462
2744
  return () => {
2463
2745
  return h(
2464
2746
  props.as,
@@ -2471,6 +2753,11 @@ function generateVueJsxStringLiteralFactory(ctx) {
2471
2753
  }
2472
2754
  },
2473
2755
  })
2756
+
2757
+ ${componentName}.__styles__ = styles
2758
+ ${componentName}.__base__ = element
2759
+
2760
+ return ${componentName}
2474
2761
  }
2475
2762
  }
2476
2763
 
@@ -2496,7 +2783,7 @@ function generateVueJsxStringLiteralFactory(ctx) {
2496
2783
  }
2497
2784
 
2498
2785
  // src/artifacts/vue-jsx/pattern.ts
2499
- import { outdent as outdent36 } from "outdent";
2786
+ import { outdent as outdent37 } from "outdent";
2500
2787
  function generateVueJsxPattern(ctx) {
2501
2788
  const { typeName, factoryName } = ctx.jsx;
2502
2789
  return ctx.patterns.details.map((pattern) => {
@@ -2505,7 +2792,7 @@ function generateVueJsxPattern(ctx) {
2505
2792
  const propList = props.map((v) => JSON.stringify(v)).join(", ");
2506
2793
  return {
2507
2794
  name: dashName,
2508
- js: outdent36`
2795
+ js: outdent37`
2509
2796
  import { defineComponent, h, computed } from 'vue'
2510
2797
  ${ctx.file.import(factoryName, "./factory")}
2511
2798
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
@@ -2523,7 +2810,7 @@ function generateVueJsxPattern(ctx) {
2523
2810
  }
2524
2811
  })
2525
2812
  `,
2526
- dts: outdent36`
2813
+ dts: outdent37`
2527
2814
  import type { FunctionalComponent } from 'vue'
2528
2815
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2529
2816
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -2539,23 +2826,27 @@ function generateVueJsxPattern(ctx) {
2539
2826
  }
2540
2827
 
2541
2828
  // src/artifacts/vue-jsx/types.ts
2542
- import { outdent as outdent37 } from "outdent";
2829
+ import { outdent as outdent38 } from "outdent";
2543
2830
  function generateVueJsxTypes(ctx) {
2544
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2831
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2545
2832
  return {
2546
- jsxFactory: outdent37`
2833
+ jsxFactory: outdent38`
2547
2834
  ${ctx.file.importType(upperName, "../types/jsx")}
2548
2835
 
2549
2836
  export declare const ${factoryName}: ${upperName}
2550
2837
  `,
2551
- jsxType: outdent37`
2838
+ jsxType: outdent38`
2552
2839
  import type { Component, FunctionalComponent, NativeElements } from 'vue'
2553
2840
 
2554
2841
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2555
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
2842
+ ${ctx.file.importType(
2843
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2844
+ "./system-types"
2845
+ )}
2556
2846
 
2557
- type IntrinsicElement = keyof NativeElements
2558
- type ElementType = IntrinsicElement | Component
2847
+ export type IntrinsicElement = keyof NativeElements
2848
+
2849
+ export type ElementType = IntrinsicElement | Component
2559
2850
 
2560
2851
  export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2561
2852
  ? NativeElements[T]
@@ -2563,13 +2854,15 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2563
2854
  ? Props
2564
2855
  : never
2565
2856
 
2566
- interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
2567
- JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2857
+ export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
2858
+ JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2568
2859
  > {}
2569
2860
 
2570
- interface RecipeFn { __type: any }
2861
+ interface RecipeFn {
2862
+ __type: any
2863
+ }
2571
2864
 
2572
- interface JsxFactoryOptions<TProps extends Dict> {
2865
+ export interface JsxFactoryOptions<TProps extends Dict> {
2573
2866
  dataAttr?: boolean
2574
2867
  defaultProps?: TProps
2575
2868
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -2577,39 +2870,48 @@ interface JsxFactoryOptions<TProps extends Dict> {
2577
2870
 
2578
2871
  export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
2579
2872
 
2580
- interface JsxFactory {
2873
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2874
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2875
+ : ${componentName}<T, P>
2876
+
2877
+ export interface JsxFactory {
2581
2878
  <T extends ElementType>(component: T): ${componentName}<T, {}>
2582
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2879
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2583
2880
  T,
2584
2881
  RecipeSelection<P>
2585
2882
  >
2586
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): ${componentName}<T, P['__type']>
2883
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): JsxElement<T, P['__type']>
2587
2884
  }
2588
2885
 
2589
- type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
2886
+ export type JsxElements = {
2887
+ [K in IntrinsicElement]: ${componentName}<K, {}>
2888
+ }
2590
2889
 
2591
2890
  export type ${upperName} = JsxFactory & JsxElements
2592
2891
 
2593
2892
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2893
+
2894
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2594
2895
  `
2595
2896
  };
2596
2897
  }
2597
2898
 
2598
2899
  // src/artifacts/vue-jsx/types.string-literal.ts
2599
- import { outdent as outdent38 } from "outdent";
2900
+ import { outdent as outdent39 } from "outdent";
2600
2901
  function generateVueJsxStringLiteralTypes(ctx) {
2601
2902
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2602
2903
  return {
2603
- jsxFactory: outdent38`
2904
+ jsxFactory: outdent39`
2604
2905
  ${ctx.file.importType(upperName, "../types/jsx")}
2605
2906
 
2606
2907
  export declare const ${factoryName}: ${upperName}
2607
2908
  `,
2608
- jsxType: outdent38`
2909
+ jsxType: outdent39`
2609
2910
  import type { Component, FunctionalComponent, NativeElements } from 'vue'
2610
2911
 
2611
- type IntrinsicElement = keyof NativeElements
2612
- type ElementType = IntrinsicElement | Component
2912
+ export type IntrinsicElement = keyof NativeElements
2913
+
2914
+ export type ElementType = IntrinsicElement | Component
2613
2915
 
2614
2916
  export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2615
2917
  ? NativeElements[T]
@@ -2617,14 +2919,16 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2617
2919
  ? Props
2618
2920
  : never
2619
2921
 
2620
- type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
2922
+ export type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
2621
2923
  >
2622
2924
 
2623
- interface JsxFactory {
2925
+ export interface JsxFactory {
2624
2926
  <T extends ElementType>(component: T): ${componentName}<T>
2625
2927
  }
2626
2928
 
2627
- type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
2929
+ export type JsxElements = {
2930
+ [K in IntrinsicElement]: ${componentName}<K>
2931
+ }
2628
2932
 
2629
2933
  export type ${upperName} = JsxFactory & JsxElements
2630
2934
 
@@ -2741,12 +3045,12 @@ var csstype_d_ts_default = {
2741
3045
 
2742
3046
  // src/artifacts/generated/system-types.d.ts.json
2743
3047
  var system_types_d_ts_default = {
2744
- content: "import type { ConditionalValue, Conditions, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ntype MinimalNested<P> = {\n [K in keyof Conditions]?: Nested<P>\n}\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<{\n [K in Property]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemProperties & MinimalNested<SystemStyleObject>\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n"
3048
+ content: "import type { ConditionalValue, Conditions, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ntype MinimalNested<P> = {\n [K in keyof Conditions]?: Nested<P>\n}\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<{\n [K in Property]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemProperties & MinimalNested<SystemStyleObject>\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n"
2745
3049
  };
2746
3050
 
2747
3051
  // src/artifacts/generated/composition.d.ts.json
2748
3052
  var composition_d_ts_default = {
2749
- content: "import type { CompositionStyleObject } from './system-types'\n\ninterface Recursive<T> {\n [key: string]: Recursive<T> | T\n}\n\nexport interface Token<Value = any> {\n value: Value\n description?: string\n}\n\n/* -----------------------------------------------------------------------------\n * Text styles\n * -----------------------------------------------------------------------------*/\n\ntype TextStyleProperty =\n | 'fontSize'\n | 'fontSizeAdjust'\n | 'fontVariationSettings'\n | 'fontVariantPosition'\n | 'fontVariantCaps'\n | 'fontVariantNumeric'\n | 'fontVariantAlternates'\n | 'fontVariantLigatures'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontSynthesis'\n | 'fontStyle'\n | 'fontVariant'\n | 'lineHeight'\n | 'letterSpacing'\n | 'textDecoration'\n | 'textTransform'\n | 'textIndent'\n | 'textDecorationColor'\n | 'textDecorationLine'\n | 'textDecorationStyle'\n | 'textEmphasisColor'\n | 'textEmphasisPosition'\n | 'textEmphasisStyle'\n | 'hyphenateCharacter'\n | 'textOrientation'\n | 'textOverflow'\n | 'textRendering'\n\nexport type TextStyle = CompositionStyleObject<TextStyleProperty>\n\nexport type TextStyles = Recursive<Token<TextStyle>>\n\n/* -----------------------------------------------------------------------------\n * Layer styles\n * -----------------------------------------------------------------------------*/\n\ntype Placement =\n | 'Top'\n | 'Right'\n | 'Bottom'\n | 'Left'\n | 'Inline'\n | 'Block'\n | 'InlineStart'\n | 'InlineEnd'\n | 'BlockStart'\n | 'BlockEnd'\n\ntype Radius =\n | `Top${'Right' | 'Left'}`\n | `Bottom${'Right' | 'Left'}`\n | `Start${'Start' | 'End'}`\n | `End${'Start' | 'End'}`\n\ntype LayerStyleProperty =\n | 'background'\n | 'backgroundColor'\n | 'backgroundImage'\n | 'borderRadius'\n | 'border'\n | 'borderWidth'\n | 'borderColor'\n | 'borderStyle'\n | 'boxShadow'\n | 'filter'\n | 'backdropFilter'\n | 'transform'\n | 'color'\n | 'opacity'\n | 'backgroundBlendMode'\n | 'backgroundAttachment'\n | 'backgroundClip'\n | 'backgroundOrigin'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundSize'\n | `border${Placement}`\n | `border${Placement}Width`\n | 'borderRadius'\n | `border${Radius}Radius`\n | `border${Placement}Color`\n | `border${Placement}Style`\n | 'padding'\n | `padding${Placement}`\n\nexport type LayerStyle = CompositionStyleObject<LayerStyleProperty>\n\nexport type LayerStyles = Recursive<Token<LayerStyle>>\n\nexport interface CompositionStyles {\n textStyles: TextStyles\n layerStyles: LayerStyles\n}\n"
3053
+ content: "import type { CompositionStyleObject } from './system-types'\nimport type { Token } from '../tokens'\n\ninterface Recursive<T> {\n [key: string]: Recursive<T> | T\n}\n\n/* -----------------------------------------------------------------------------\n * Text styles\n * -----------------------------------------------------------------------------*/\n\ntype TextStyleProperty =\n | 'fontSize'\n | 'fontSizeAdjust'\n | 'fontVariationSettings'\n | 'fontVariantPosition'\n | 'fontVariantCaps'\n | 'fontVariantNumeric'\n | 'fontVariantAlternates'\n | 'fontVariantLigatures'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontSynthesis'\n | 'fontStyle'\n | 'fontVariant'\n | 'lineHeight'\n | 'letterSpacing'\n | 'textDecoration'\n | 'textTransform'\n | 'textIndent'\n | 'textDecorationColor'\n | 'textDecorationLine'\n | 'textDecorationStyle'\n | 'textEmphasisColor'\n | 'textEmphasisPosition'\n | 'textEmphasisStyle'\n | 'hyphenateCharacter'\n | 'textOrientation'\n | 'textOverflow'\n | 'textRendering'\n\nexport type TextStyle = CompositionStyleObject<TextStyleProperty>\n\nexport type TextStyles = Recursive<Token<TextStyle>>\n\n/* -----------------------------------------------------------------------------\n * Layer styles\n * -----------------------------------------------------------------------------*/\n\ntype Placement =\n | 'Top'\n | 'Right'\n | 'Bottom'\n | 'Left'\n | 'Inline'\n | 'Block'\n | 'InlineStart'\n | 'InlineEnd'\n | 'BlockStart'\n | 'BlockEnd'\n\ntype Radius =\n | `Top${'Right' | 'Left'}`\n | `Bottom${'Right' | 'Left'}`\n | `Start${'Start' | 'End'}`\n | `End${'Start' | 'End'}`\n\ntype LayerStyleProperty =\n | 'background'\n | 'backgroundColor'\n | 'backgroundImage'\n | 'borderRadius'\n | 'border'\n | 'borderWidth'\n | 'borderColor'\n | 'borderStyle'\n | 'boxShadow'\n | 'filter'\n | 'backdropFilter'\n | 'transform'\n | 'color'\n | 'opacity'\n | 'backgroundBlendMode'\n | 'backgroundAttachment'\n | 'backgroundClip'\n | 'backgroundOrigin'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundSize'\n | `border${Placement}`\n | `border${Placement}Width`\n | 'borderRadius'\n | `border${Radius}Radius`\n | `border${Placement}Color`\n | `border${Placement}Style`\n | 'padding'\n | `padding${Placement}`\n\nexport type LayerStyle = CompositionStyleObject<LayerStyleProperty>\n\nexport type LayerStyles = Recursive<Token<LayerStyle>>\n\nexport interface CompositionStyles {\n textStyles: TextStyles\n layerStyles: LayerStyles\n}\n"
2750
3054
  };
2751
3055
 
2752
3056
  // src/artifacts/generated/recipe.d.ts.json
@@ -2756,12 +3060,12 @@ var recipe_d_ts_default = {
2756
3060
 
2757
3061
  // src/artifacts/generated/pattern.d.ts.json
2758
3062
  var pattern_d_ts_default = {
2759
- 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 interface 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 interface 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"
3063
+ 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 interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport interface 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"
2760
3064
  };
2761
3065
 
2762
3066
  // src/artifacts/generated/parts.d.ts.json
2763
3067
  var parts_d_ts_default = {
2764
- content: "export interface Part {\n selector: string\n}\n\nexport type Parts = Record<string, Part>\n"
3068
+ content: "export interface Part {\n selector: string\n}\n\nexport interface Parts {\n [key: string]: Part\n}\n"
2765
3069
  };
2766
3070
 
2767
3071
  // src/artifacts/generated/selectors.d.ts.json
@@ -2770,7 +3074,7 @@ var selectors_d_ts_default = {
2770
3074
  };
2771
3075
 
2772
3076
  // src/artifacts/types/generated.ts
2773
- import { match as match8 } from "ts-pattern";
3077
+ import { match as match9 } from "ts-pattern";
2774
3078
  var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
2775
3079
  function getGeneratedTypes(ctx) {
2776
3080
  const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
@@ -2782,15 +3086,32 @@ function getGeneratedTypes(ctx) {
2782
3086
  composition: rewriteImports(composition_d_ts_default.content),
2783
3087
  selectors: rewriteImports(selectors_d_ts_default.content),
2784
3088
  system: rewriteImports(
2785
- match8(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with("minimal", () => system_types_d_ts_default.content.replace(jsxStyleProps, "export type JsxStyleProps = WithCss")).with("none", () => system_types_d_ts_default.content.replace(jsxStyleProps, "export type JsxStyleProps = {}")).exhaustive()
3089
+ match9(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
3090
+ "minimal",
3091
+ () => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
3092
+ ).with(
3093
+ "none",
3094
+ () => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = {}")
3095
+ ).exhaustive()
2786
3096
  )
2787
3097
  };
2788
3098
  }
2789
3099
 
2790
3100
  // src/artifacts/types/main.ts
2791
- import { outdent as outdent39 } from "outdent";
2792
- var generateTypesEntry = (ctx) => ({
2793
- global: outdent39`
3101
+ import { outdent as outdent40 } from "outdent";
3102
+ var generateTypesEntry = (ctx, isJsxRequired) => {
3103
+ const indexExports = [
3104
+ // We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
3105
+ `import '${ctx.file.extDts("./global")}'`,
3106
+ ctx.file.exportTypeStar("./conditions"),
3107
+ ctx.file.exportTypeStar("./pattern"),
3108
+ ctx.file.exportTypeStar("./recipe"),
3109
+ ctx.file.exportTypeStar("./system-types"),
3110
+ isJsxRequired && ctx.file.exportTypeStar("./jsx"),
3111
+ ctx.file.exportTypeStar("./style-props")
3112
+ ].filter(Boolean);
3113
+ return {
3114
+ global: outdent40`
2794
3115
  // @ts-nocheck
2795
3116
  import type * as Panda from '@pandacss/dev'
2796
3117
  ${ctx.file.importType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
@@ -2810,24 +3131,17 @@ var generateTypesEntry = (ctx) => ({
2810
3131
  export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
2811
3132
  }
2812
3133
  `,
2813
- // We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
2814
- index: outdent39`
2815
- import '${ctx.file.extDts("./global")}'
2816
- ${ctx.file.exportTypeStar("./conditions")}
2817
- ${ctx.file.exportTypeStar("./pattern")}
2818
- ${ctx.file.exportTypeStar("./recipe")}
2819
- ${ctx.file.exportTypeStar("./system-types")}
2820
- ${ctx.file.exportTypeStar("./jsx")}
2821
- ${ctx.file.exportTypeStar("./style-props")}
2822
-
3134
+ index: outdent40`
3135
+ ${indexExports.join("\n")}
2823
3136
  `,
2824
- helpers: outdent39`
2825
- export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
2826
- `
2827
- });
3137
+ helpers: outdent40`
3138
+ export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
3139
+ `
3140
+ };
3141
+ };
2828
3142
 
2829
3143
  // src/artifacts/types/prop-types.ts
2830
- import { outdent as outdent40 } from "outdent";
3144
+ import { outdent as outdent41 } from "outdent";
2831
3145
  function generatePropTypes(ctx) {
2832
3146
  const {
2833
3147
  config: { strictTokens },
@@ -2835,7 +3149,7 @@ function generatePropTypes(ctx) {
2835
3149
  } = ctx;
2836
3150
  const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
2837
3151
  const result = [
2838
- outdent40`
3152
+ outdent41`
2839
3153
  ${ctx.file.importType("ConditionalValue", "./conditions")}
2840
3154
  ${ctx.file.importType("CssProperties", "./system-types")}
2841
3155
  ${ctx.file.importType("Tokens", "../tokens/index")}
@@ -2858,7 +3172,7 @@ function generatePropTypes(ctx) {
2858
3172
  result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
2859
3173
  });
2860
3174
  result.push("}");
2861
- return outdent40`
3175
+ return outdent41`
2862
3176
  ${result.join("\n")}
2863
3177
 
2864
3178
  export type PropertyValue<T extends string> = T extends keyof PropertyTypes
@@ -2871,10 +3185,10 @@ function generatePropTypes(ctx) {
2871
3185
 
2872
3186
  // src/artifacts/types/style-props.ts
2873
3187
  import { allCssProperties } from "@pandacss/is-valid-prop";
2874
- import outdent41 from "outdent";
3188
+ import outdent42 from "outdent";
2875
3189
  function generateStyleProps(ctx) {
2876
3190
  const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
2877
- return outdent41`
3191
+ return outdent42`
2878
3192
  ${ctx.file.importType("ConditionalValue", "./conditions")}
2879
3193
  ${ctx.file.importType("PropertyValue", "./prop-type")}
2880
3194
  ${ctx.file.importType("Token", "../tokens/index")}
@@ -2891,7 +3205,7 @@ function generateStyleProps(ctx) {
2891
3205
 
2892
3206
  // src/artifacts/types/token-types.ts
2893
3207
  import { capitalize, unionType as unionType3 } from "@pandacss/shared";
2894
- import { outdent as outdent42 } from "outdent";
3208
+ import { outdent as outdent43 } from "outdent";
2895
3209
  import pluralize from "pluralize";
2896
3210
  var categories = [
2897
3211
  "zIndex",
@@ -2942,7 +3256,7 @@ function generateTokenTypes(ctx) {
2942
3256
  result.add("} & { [token: string]: never }");
2943
3257
  set.add(Array.from(result).join("\n"));
2944
3258
  set.add(`export type TokenCategory = ${unionType3(categories)}`);
2945
- return outdent42.string(Array.from(set).join("\n\n"));
3259
+ return outdent43.string(Array.from(set).join("\n\n"));
2946
3260
  }
2947
3261
 
2948
3262
  // src/artifacts/index.ts
@@ -2978,7 +3292,7 @@ function setupTypes(ctx) {
2978
3292
  const gen = getGeneratedTypes(ctx);
2979
3293
  const conditions = generateConditions(ctx);
2980
3294
  const jsx = generateJsxTypes(ctx);
2981
- const entry = generateTypesEntry(ctx);
3295
+ const entry = generateTypesEntry(ctx, jsx != null);
2982
3296
  return {
2983
3297
  dir: ctx.paths.types,
2984
3298
  files: [
@@ -2988,7 +3302,6 @@ function setupTypes(ctx) {
2988
3302
  { file: ctx.file.extDts("selectors"), code: gen.selectors },
2989
3303
  { file: ctx.file.extDts("composition"), code: gen.composition },
2990
3304
  { file: ctx.file.extDts("global"), code: entry.global },
2991
- { file: ctx.file.extDts("helpers"), code: entry.helpers },
2992
3305
  { file: ctx.file.extDts("recipe"), code: gen.recipe },
2993
3306
  { file: ctx.file.extDts("pattern"), code: gen.pattern },
2994
3307
  { file: ctx.file.extDts("parts"), code: gen.parts },
@@ -3051,8 +3364,8 @@ function setupRecipes(ctx) {
3051
3364
  return;
3052
3365
  const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
3053
3366
  const index = {
3054
- js: outdent43.string(indexFiles.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3055
- dts: outdent43.string(indexFiles.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3367
+ js: outdent44.string(indexFiles.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3368
+ dts: outdent44.string(indexFiles.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3056
3369
  };
3057
3370
  return {
3058
3371
  dir: ctx.paths.recipe,
@@ -3071,8 +3384,8 @@ function setupPatterns(ctx) {
3071
3384
  if (!files)
3072
3385
  return;
3073
3386
  const index = {
3074
- js: outdent43.string(files.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3075
- dts: outdent43.string(files.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3387
+ js: outdent44.string(files.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3388
+ dts: outdent44.string(files.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3076
3389
  };
3077
3390
  return {
3078
3391
  dir: ctx.paths.pattern,
@@ -3091,18 +3404,19 @@ function setupJsx(ctx) {
3091
3404
  const types = generateJsxTypes(ctx);
3092
3405
  const factory = generateJsxFactory(ctx);
3093
3406
  const patterns = generateJsxPatterns(ctx);
3407
+ const helpers3 = generatedJsxHelpers(ctx);
3094
3408
  const index = {
3095
- js: outdent43`
3409
+ js: outdent44`
3096
3410
  ${ctx.file.exportStar("./factory")}
3097
3411
  ${isValidProp?.js ? ctx.file.exportStar("./is-valid-prop") : ""}
3098
- ${outdent43.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
3412
+ ${outdent44.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
3099
3413
  `,
3100
- dts: outdent43`
3414
+ dts: outdent44`
3101
3415
  ${ctx.file.exportTypeStar("./factory")}
3102
3416
 
3103
3417
  ${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
3104
3418
 
3105
- ${outdent43.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
3419
+ ${outdent44.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
3106
3420
 
3107
3421
  ${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
3108
3422
  `
@@ -3114,6 +3428,7 @@ function setupJsx(ctx) {
3114
3428
  ...patterns.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
3115
3429
  { file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
3116
3430
  { file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts },
3431
+ { file: ctx.file.ext("factory-helper"), code: helpers3.js },
3117
3432
  { file: ctx.file.ext("factory"), code: factory?.js },
3118
3433
  { file: ctx.file.extDts("factory"), code: types.jsxFactory },
3119
3434
  { file: ctx.file.ext("index"), code: index.js },
@@ -3123,13 +3438,13 @@ function setupJsx(ctx) {
3123
3438
  }
3124
3439
  function setupCssIndex(ctx) {
3125
3440
  const index = {
3126
- js: outdent43`
3441
+ js: outdent44`
3127
3442
  ${ctx.file.exportStar("./css")}
3128
3443
  ${ctx.file.exportStar("./cx")}
3129
3444
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./cva")}
3130
3445
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./sva")}
3131
3446
  `,
3132
- dts: outdent43`
3447
+ dts: outdent44`
3133
3448
  ${ctx.file.exportTypeStar("./css")}
3134
3449
  ${ctx.file.exportTypeStar("./cx")}
3135
3450
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./cva")}
@@ -3191,6 +3506,8 @@ var generateArtifacts = (ctx) => () => {
3191
3506
  ].filter(Boolean).map((artifact) => {
3192
3507
  const files = artifact?.files ?? [];
3193
3508
  files.forEach((file) => {
3509
+ if (!file)
3510
+ return;
3194
3511
  if (ctx.file.isTypeFile(file.file)) {
3195
3512
  file.code = `/* eslint-disable */
3196
3513
  ${file.code}`;
@@ -3229,85 +3546,81 @@ var generateFlattenedCss = (ctx) => (options) => {
3229
3546
 
3230
3547
  // src/artifacts/css/parser-css.ts
3231
3548
  import { logger } from "@pandacss/logger";
3232
- import { pipe, tap, tryCatch } from "lil-fp/func";
3233
- import { P, match as match9 } from "ts-pattern";
3234
- var generateParserCss = (ctx) => (result) => pipe(
3235
- { ...ctx, sheet: ctx.createSheet(), result },
3236
- tap(({ sheet, result: result2, patterns, recipes }) => {
3237
- result2.css.forEach((css2) => {
3238
- css2.data.forEach((data) => {
3239
- sheet.processAtomic(data);
3240
- });
3549
+ import { P, match as match10 } from "ts-pattern";
3550
+ var generateParserCss = (ctx) => (result) => {
3551
+ const { patterns, recipes } = ctx;
3552
+ const sheet = ctx.createSheet();
3553
+ result.css.forEach((css2) => {
3554
+ css2.data.forEach((data) => {
3555
+ sheet.processAtomic(data);
3241
3556
  });
3242
- result2.cva.forEach((cva) => {
3243
- cva.data.forEach((data) => {
3244
- sheet.processAtomicRecipe(data);
3245
- });
3557
+ });
3558
+ result.cva.forEach((cva) => {
3559
+ cva.data.forEach((data) => {
3560
+ sheet.processAtomicRecipe(data);
3246
3561
  });
3247
- result2.sva.forEach((sva) => {
3248
- sva.data.forEach((data) => {
3249
- sheet.processAtomicSlotRecipe(data);
3250
- });
3562
+ });
3563
+ result.sva.forEach((sva) => {
3564
+ sva.data.forEach((data) => {
3565
+ sheet.processAtomicSlotRecipe(data);
3251
3566
  });
3252
- result2.jsx.forEach((jsx) => {
3253
- jsx.data.forEach((data) => {
3254
- sheet.processStyleProps(filterProps(ctx, data));
3255
- });
3567
+ });
3568
+ result.jsx.forEach((jsx) => {
3569
+ jsx.data.forEach((data) => {
3570
+ sheet.processStyleProps(filterProps(ctx, data));
3256
3571
  });
3257
- result2.recipe.forEach((recipeSet, recipeName) => {
3258
- try {
3259
- for (const recipe of recipeSet) {
3260
- const recipeConfig = recipes.getConfig(recipeName);
3261
- if (!recipeConfig)
3262
- continue;
3263
- match9(recipe).with({ type: "jsx-recipe" }, () => {
3264
- recipe.data.forEach((data) => {
3265
- const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3266
- sheet.processStyleProps(filterProps(ctx, styleProps));
3267
- sheet.processRecipe(recipeName, recipeConfig, recipeProps);
3268
- });
3269
- }).otherwise(() => {
3270
- recipe.data.forEach((data) => {
3271
- sheet.processRecipe(recipeName, recipeConfig, data);
3272
- });
3572
+ });
3573
+ result.recipe.forEach((recipeSet, recipeName) => {
3574
+ try {
3575
+ for (const recipe of recipeSet) {
3576
+ const recipeConfig = recipes.getConfig(recipeName);
3577
+ if (!recipeConfig)
3578
+ continue;
3579
+ match10(recipe).with({ type: "jsx-recipe" }, () => {
3580
+ recipe.data.forEach((data) => {
3581
+ const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3582
+ sheet.processStyleProps(filterProps(ctx, styleProps));
3583
+ sheet.processRecipe(recipeName, recipeConfig, recipeProps);
3273
3584
  });
3274
- }
3275
- } catch (error) {
3276
- logger.error("serializer:recipe", error);
3585
+ }).otherwise(() => {
3586
+ recipe.data.forEach((data) => {
3587
+ sheet.processRecipe(recipeName, recipeConfig, data);
3588
+ });
3589
+ });
3277
3590
  }
3278
- });
3279
- result2.pattern.forEach((patternSet, name) => {
3280
- try {
3281
- for (const pattern of patternSet) {
3282
- match9(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3283
- pattern.data.forEach((data) => {
3284
- const fnName = patterns.find(jsxName);
3285
- const styleProps = patterns.transform(fnName, data);
3286
- sheet.processStyleProps(filterProps(ctx, styleProps));
3287
- });
3288
- }).otherwise(() => {
3289
- pattern.data.forEach((data) => {
3290
- const styleProps = patterns.transform(name, data);
3291
- sheet.processAtomic(styleProps);
3292
- });
3591
+ } catch (error) {
3592
+ logger.error("serializer:recipe", error);
3593
+ }
3594
+ });
3595
+ result.pattern.forEach((patternSet, name) => {
3596
+ try {
3597
+ for (const pattern of patternSet) {
3598
+ match10(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3599
+ pattern.data.forEach((data) => {
3600
+ const fnName = patterns.find(jsxName);
3601
+ const styleProps = patterns.transform(fnName, data);
3602
+ sheet.processStyleProps(filterProps(ctx, styleProps));
3293
3603
  });
3294
- }
3295
- } catch (error) {
3296
- logger.error("serializer:pattern", error);
3604
+ }).otherwise(() => {
3605
+ pattern.data.forEach((data) => {
3606
+ const styleProps = patterns.transform(name, data);
3607
+ sheet.processAtomic(styleProps);
3608
+ });
3609
+ });
3297
3610
  }
3298
- });
3299
- }),
3300
- tryCatch(
3301
- ({ sheet, result: result2, config: { minify, optimize } }) => {
3302
- const css2 = !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
3303
- void ctx.hooks.callHook("parser:css", result2.filePath ?? "", css2);
3304
- return css2;
3305
- },
3306
- (err) => {
3307
- logger.error("serializer:css", "Failed to serialize CSS: " + err);
3611
+ } catch (error) {
3612
+ logger.error("serializer:pattern", error);
3308
3613
  }
3309
- )
3310
- );
3614
+ });
3615
+ try {
3616
+ const { minify, optimize } = ctx.config;
3617
+ const css2 = !result.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
3618
+ void ctx.hooks.callHook("parser:css", result.filePath ?? "", css2);
3619
+ return css2;
3620
+ } catch (err) {
3621
+ logger.error("serializer:css", "Failed to serialize CSS: " + err);
3622
+ }
3623
+ };
3311
3624
  var filterProps = (ctx, props) => {
3312
3625
  const clone = {};
3313
3626
  for (const [key, value] of Object.entries(props)) {
@@ -3362,7 +3675,7 @@ var getBaseEngine = (conf) => {
3362
3675
  strictTokens: config.strictTokens
3363
3676
  });
3364
3677
  const conditions = new Conditions({
3365
- conditions: isTemplateLiteralSyntax ? {} : config.conditions,
3678
+ conditions: config.conditions,
3366
3679
  breakpoints: config.theme?.breakpoints
3367
3680
  });
3368
3681
  const { textStyles, layerStyles } = theme;
@@ -3438,6 +3751,7 @@ var getJsxEngine = (config) => {
3438
3751
  factoryName: jsxFactory,
3439
3752
  upperName: capitalize2(jsxFactory),
3440
3753
  typeName: `HTML${capitalize2(jsxFactory)}Props`,
3754
+ variantName: `${capitalize2(jsxFactory)}VariantProps`,
3441
3755
  componentName: `${capitalize2(jsxFactory)}Component`,
3442
3756
  framework: jsxFramework,
3443
3757
  styleProps: jsxStyleProps2 ?? "all"
@@ -3507,45 +3821,84 @@ var getPatternEngine = (config) => {
3507
3821
  };
3508
3822
  };
3509
3823
 
3824
+ // src/engines/file.ts
3825
+ var getFileEngine = (config) => {
3826
+ const { forceConsistentTypeExtension, outExtension } = config;
3827
+ return {
3828
+ ext(file) {
3829
+ return `${file}.${outExtension}`;
3830
+ },
3831
+ extDts(file) {
3832
+ const dts = outExtension === "mjs" && forceConsistentTypeExtension ? "d.mts" : "d.ts";
3833
+ return `${file}.${dts}`;
3834
+ },
3835
+ __extDts(file) {
3836
+ return forceConsistentTypeExtension ? this.extDts(file) : file;
3837
+ },
3838
+ import(mod, file) {
3839
+ return `import { ${mod} } from '${this.ext(file)}';`;
3840
+ },
3841
+ importType(mod, file) {
3842
+ return `import type { ${mod} } from '${this.__extDts(file)}';`;
3843
+ },
3844
+ exportType(mod, file) {
3845
+ return `export type { ${mod} } from '${this.__extDts(file)}';`;
3846
+ },
3847
+ exportStar(file) {
3848
+ return `export * from '${this.ext(file)}';`;
3849
+ },
3850
+ exportTypeStar(file) {
3851
+ return `export * from '${this.__extDts(file)}';`;
3852
+ },
3853
+ isTypeFile(file) {
3854
+ return file.endsWith(".d.ts") || file.endsWith(".d.mts");
3855
+ }
3856
+ };
3857
+ };
3858
+
3510
3859
  // src/engines/index.ts
3511
3860
  var getEngine = (conf) => {
3512
3861
  const { config } = conf;
3513
- const { forceConsistentTypeExtension, outExtension } = config;
3514
3862
  return {
3515
3863
  ...getBaseEngine(conf),
3516
3864
  patterns: getPatternEngine(config),
3517
3865
  jsx: getJsxEngine(config),
3518
3866
  paths: getPathEngine(config),
3519
- file: {
3520
- ext(file) {
3521
- return `${file}.${outExtension}`;
3522
- },
3523
- extDts(file) {
3524
- const dts = outExtension === "mjs" && forceConsistentTypeExtension ? "d.mts" : "d.ts";
3525
- return `${file}.${dts}`;
3526
- },
3527
- __extDts(file) {
3528
- return forceConsistentTypeExtension ? this.extDts(file) : file;
3529
- },
3530
- import(mod, file) {
3531
- return `import { ${mod} } from '${this.ext(file)}';`;
3532
- },
3533
- importType(mod, file) {
3534
- return `import type { ${mod} } from '${this.__extDts(file)}';`;
3535
- },
3536
- exportType(mod, file) {
3537
- return `export type { ${mod} } from '${this.__extDts(file)}';`;
3538
- },
3539
- exportStar(file) {
3540
- return `export * from '${this.ext(file)}';`;
3541
- },
3542
- exportTypeStar(file) {
3543
- return `export * from '${this.__extDts(file)}';`;
3544
- },
3545
- isTypeFile(file) {
3546
- return file.endsWith(".d.ts") || file.endsWith(".d.mts");
3547
- }
3548
- }
3867
+ file: getFileEngine(config)
3868
+ };
3869
+ };
3870
+
3871
+ // src/parser-options.ts
3872
+ var getImportMap = (outdir, configImportMap) => {
3873
+ const { css: css2, recipes, patterns, jsx } = configImportMap ?? {};
3874
+ return {
3875
+ css: css2 ? [css2] : [outdir, "css"],
3876
+ recipe: recipes ? [recipes] : [outdir, "recipes"],
3877
+ pattern: patterns ? [patterns] : [outdir, "patterns"],
3878
+ jsx: jsx ? [jsx] : [outdir, "jsx"]
3879
+ };
3880
+ };
3881
+ var getParserOptions = (ctx) => {
3882
+ const { config, jsx, isValidProperty, patterns, recipes, tsconfig, tsOptions } = ctx;
3883
+ const compilerOptions = tsconfig?.compilerOptions ?? {};
3884
+ const baseUrl = compilerOptions.baseUrl ?? "";
3885
+ const cwd = config.cwd;
3886
+ const relativeBaseUrl = baseUrl !== cwd ? baseUrl.replace(cwd, "").slice(1) : cwd;
3887
+ return {
3888
+ importMap: getImportMap(config.outdir.replace(relativeBaseUrl, ""), config.importMap),
3889
+ jsx: {
3890
+ framework: jsx.framework,
3891
+ factory: jsx.factoryName,
3892
+ styleProps: jsx.styleProps,
3893
+ isStyleProp: isValidProperty,
3894
+ nodes: [...patterns.details, ...recipes.details]
3895
+ },
3896
+ patternKeys: patterns.keys,
3897
+ recipeKeys: recipes.keys,
3898
+ getRecipesByJsxName: recipes.filter,
3899
+ getPatternsByJsxName: patterns.filter,
3900
+ compilerOptions,
3901
+ tsOptions
3549
3902
  };
3550
3903
  };
3551
3904
 
@@ -3570,19 +3923,9 @@ var defaults = (conf) => ({
3570
3923
  }
3571
3924
  }
3572
3925
  });
3573
- var getImportMap = (outdir, configImportMap) => ({
3574
- css: configImportMap?.css ? [configImportMap.css] : [outdir, "css"],
3575
- recipe: configImportMap?.recipes ? [configImportMap.recipes] : [outdir, "recipes"],
3576
- pattern: configImportMap?.patterns ? [configImportMap.patterns] : [outdir, "patterns"],
3577
- jsx: configImportMap?.jsx ? [configImportMap.jsx] : [outdir, "jsx"]
3578
- });
3579
3926
  var createGenerator = (conf) => {
3580
3927
  const ctx = getEngine(defaults(conf));
3581
- const { config, jsx, isValidProperty, patterns, recipes } = ctx;
3582
- const compilerOptions = conf.tsconfig?.compilerOptions ?? {};
3583
- const baseUrl = compilerOptions.baseUrl ?? "";
3584
- const cwd = conf.config.cwd;
3585
- const relativeBaseUrl = baseUrl !== cwd ? baseUrl.replace(cwd, "").slice(1) : cwd;
3928
+ const parserOptions = getParserOptions(ctx);
3586
3929
  return {
3587
3930
  ...ctx,
3588
3931
  getArtifacts: generateArtifacts(ctx),
@@ -3597,22 +3940,7 @@ var createGenerator = (conf) => {
3597
3940
  getParserCss: generateParserCss(ctx),
3598
3941
  //
3599
3942
  messages: getMessages(ctx),
3600
- parserOptions: {
3601
- importMap: getImportMap(config.outdir.replace(relativeBaseUrl, ""), config.importMap),
3602
- jsx: {
3603
- framework: jsx.framework,
3604
- factory: jsx.factoryName,
3605
- styleProps: jsx.styleProps,
3606
- isStyleProp: isValidProperty,
3607
- nodes: [...patterns.details, ...recipes.details]
3608
- },
3609
- patternKeys: patterns.keys,
3610
- recipeKeys: recipes.keys,
3611
- getRecipesByJsxName: recipes.filter,
3612
- getPatternsByJsxName: patterns.filter,
3613
- compilerOptions,
3614
- tsOptions: conf.tsOptions
3615
- }
3943
+ parserOptions
3616
3944
  };
3617
3945
  };
3618
3946
  export {