@pandacss/generator 0.15.5 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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) => {
@@ -487,12 +487,25 @@ function getDeepestNode(node) {
487
487
  function cleanupSelectors(css2, varSelector) {
488
488
  const root = postcss2.parse(css2);
489
489
  root.walkRules((rule) => {
490
+ const selectors = [];
490
491
  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);
492
+ selectors.push(selector.trim());
495
493
  });
494
+ const ruleSelector = selectors.join(", ");
495
+ if (ruleSelector === varSelector) {
496
+ return;
497
+ }
498
+ const trimmedSelector = selectors.join(",");
499
+ if (trimmedSelector === varSelector) {
500
+ return;
501
+ }
502
+ const selectorsWithoutVarRoot = selectors.map((selector) => {
503
+ const res = selector.split(varSelector).filter(Boolean);
504
+ return res.join("");
505
+ }).filter(Boolean);
506
+ if (selectorsWithoutVarRoot.length === 0)
507
+ return;
508
+ rule.selector = selectorsWithoutVarRoot.join(", ");
496
509
  });
497
510
  return root.toString();
498
511
  }
@@ -606,11 +619,7 @@ function generateStringLiteralConditions(ctx) {
606
619
  // src/artifacts/js/css-fn.ts
607
620
  import { outdent as outdent4 } from "outdent";
608
621
  function generateCssFn(ctx) {
609
- const {
610
- utility,
611
- config: { hash, prefix },
612
- conditions
613
- } = ctx;
622
+ const { utility, hash, prefix, conditions } = ctx;
614
623
  const { separator, getPropShorthands } = utility;
615
624
  return {
616
625
  dts: outdent4`
@@ -665,14 +674,14 @@ function generateCssFn(ctx) {
665
674
  `}
666
675
 
667
676
  const context = {
668
- ${hash ? "hash: true," : ""}
677
+ ${hash.className ? "hash: true," : ""}
669
678
  conditions: {
670
679
  shift: sortConditions,
671
680
  finalize: finalizeConditions,
672
681
  breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
673
682
  },
674
683
  utility: {
675
- ${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
684
+ ${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
676
685
  transform: ${utility.hasShorthand ? `(prop, value) => {
677
686
  const key = resolveShorthand(prop)
678
687
  const propKey = classNameByProp.get(key) || hypenateProperty(key)
@@ -695,18 +704,15 @@ function generateCssFn(ctx) {
695
704
  // src/artifacts/js/css-fn.string-literal.ts
696
705
  import { outdent as outdent5 } from "outdent";
697
706
  function generateStringLiteralCssFn(ctx) {
698
- const {
699
- utility,
700
- config: { hash, prefix }
701
- } = ctx;
707
+ const { utility, hash, prefix } = ctx;
702
708
  const { separator } = utility;
703
709
  return {
704
710
  dts: outdent5`
705
711
  export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
706
712
  `,
707
713
  js: outdent5`
708
- ${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
709
- ${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
714
+ ${ctx.file.import("astish, createCss, isObject, mergeProps, withoutSpace", "../helpers")}
715
+ ${ctx.file.import("finalizeConditions, sortConditions", "./conditions")}
710
716
 
711
717
  function transform(prop, value) {
712
718
  const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
@@ -714,14 +720,14 @@ function generateStringLiteralCssFn(ctx) {
714
720
  }
715
721
 
716
722
  const context = {
717
- hash: ${hash ? "true" : "false"},
723
+ hash: ${hash.className ? "true" : "false"},
718
724
  conditions: {
719
725
  shift: sortConditions,
720
726
  finalize: finalizeConditions,
721
727
  breakpoints: { keys: [] },
722
728
  },
723
729
  utility: {
724
- prefix: ${prefix ? JSON.stringify(prefix) : void 0},
730
+ prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
725
731
  transform,
726
732
  hasShorthand: false,
727
733
  resolveShorthand(prop) {
@@ -732,9 +738,9 @@ function generateStringLiteralCssFn(ctx) {
732
738
 
733
739
  const cssFn = createCss(context)
734
740
 
735
- export const css = (str) => {
736
- return cssFn(astish(str[0]))
737
- }
741
+ const fn = (style) => (isObject(style) ? style : astish(style[0]))
742
+ export const css = (...styles) => cssFn(mergeProps(...styles.filter(Boolean).map(fn)))
743
+ css.raw = (...styles) => mergeProps(...styles.filter(Boolean).map(fn))
738
744
  `
739
745
  };
740
746
  }
@@ -744,11 +750,19 @@ import { outdent as outdent6 } from "outdent";
744
750
  function generateCvaFn(ctx) {
745
751
  return {
746
752
  js: outdent6`
747
- ${ctx.file.import("compact, splitProps", "../helpers")}
753
+ ${ctx.file.import("compact, mergeProps, splitProps, uniq", "../helpers")}
748
754
  ${ctx.file.import("css, mergeCss", "./css")}
749
755
 
756
+ const defaults = (conf) => ({
757
+ base: {},
758
+ variants: {},
759
+ defaultVariants: {},
760
+ compoundVariants: [],
761
+ ...conf,
762
+ })
763
+
750
764
  export function cva(config) {
751
- const { base = {}, variants = {}, defaultVariants = {}, compoundVariants = [] } = config
765
+ const { base, variants, defaultVariants, compoundVariants } = defaults(config)
752
766
 
753
767
  function resolve(props = {}) {
754
768
  const computedVariants = { ...defaultVariants, ...compact(props) }
@@ -762,6 +776,19 @@ function generateCvaFn(ctx) {
762
776
  return mergeCss(variantCss, compoundVariantCss)
763
777
  }
764
778
 
779
+ function merge(cvaConfig) {
780
+ const override = defaults(cvaConfig)
781
+ const variantKeys = uniq(override.variantKeys, Object.keys(variants))
782
+ return cva({
783
+ base: mergeCss(base, override.base),
784
+ variants: Object.fromEntries(
785
+ variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
786
+ ),
787
+ defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
788
+ compoundVariants: [...compoundVariants, ...override.compoundVariants],
789
+ })
790
+ }
791
+
765
792
  function cvaFn(props) {
766
793
  return css(resolve(props))
767
794
  }
@@ -780,6 +807,7 @@ function generateCvaFn(ctx) {
780
807
  variantKeys,
781
808
  raw: resolve,
782
809
  config,
810
+ merge,
783
811
  splitVariantProps,
784
812
  })
785
813
  }
@@ -854,7 +882,7 @@ import { outdent as outdent8 } from "outdent";
854
882
 
855
883
  // src/artifacts/generated/helpers.mjs.json
856
884
  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'
885
+ 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 __sources = sources.filter(Boolean);\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}\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
886
  };
859
887
 
860
888
  // src/artifacts/generated/astish.mjs.json
@@ -922,11 +950,52 @@ function generateIsValidProp(ctx) {
922
950
  };
923
951
  }
924
952
 
953
+ // src/artifacts/js/jsx-helper.ts
954
+ import { outdent as outdent10 } from "outdent";
955
+ import { match as match2 } from "ts-pattern";
956
+ function generatedJsxHelpers(ctx) {
957
+ return {
958
+ js: match2(ctx.isTemplateLiteralSyntax).with(
959
+ true,
960
+ () => outdent10`
961
+ export const getDisplayName = (Component) => {
962
+ if (typeof Component === 'string') return Component
963
+ return Component?.displayName || Component?.name || 'Component'
964
+ }`
965
+ ).otherwise(
966
+ () => outdent10`
967
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
968
+
969
+ export const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
970
+
971
+ export const composeShouldForwardProps = (tag, shouldForwardProp) =>
972
+ tag.__shouldForwardProps__ && shouldForwardProp
973
+ ? (propName) => tag.__shouldForwardProps__(propName) && shouldForwardProp(propName)
974
+ : shouldForwardProp
975
+
976
+ export const composeCvaFn = (cvaA, cvaB) => {
977
+ if (cvaA && !cvaB) return cvaA
978
+ if (!cvaA && cvaB) return cvaB
979
+ if ((cvaA.__cva__ && cvaB.__cva__) || (cvaA.__recipe__ && cvaB.__recipe__)) return cvaA.merge(cvaB.config)
980
+ const error = new TypeError('Cannot merge cva with recipe. Please use either cva or recipe.')
981
+ TypeError.captureStackTrace?.(error)
982
+ throw error
983
+ }
984
+
985
+ export const getDisplayName = (Component) => {
986
+ if (typeof Component === 'string') return Component
987
+ return Component?.displayName || Component?.name || 'Component'
988
+ }
989
+ `
990
+ )
991
+ };
992
+ }
993
+
925
994
  // src/artifacts/js/pattern.ts
926
995
  import { unionType } from "@pandacss/shared";
927
996
  import { stringify } from "javascript-stringify";
928
- import { outdent as outdent10 } from "outdent";
929
- import { match as match2 } from "ts-pattern";
997
+ import { outdent as outdent11 } from "outdent";
998
+ import { match as match3 } from "ts-pattern";
930
999
  function generatePattern(ctx) {
931
1000
  if (ctx.patterns.isEmpty())
932
1001
  return;
@@ -943,7 +1012,7 @@ function generatePattern(ctx) {
943
1012
  }
944
1013
  return {
945
1014
  name: dashName,
946
- dts: outdent10`
1015
+ dts: outdent11`
947
1016
  ${ctx.file.importType("SystemStyleObject, ConditionalValue", "../types/index")}
948
1017
  ${ctx.file.importType("Properties", "../types/csstype")}
949
1018
  ${ctx.file.importType("PropertyValue", "../types/prop-type")}
@@ -953,7 +1022,7 @@ function generatePattern(ctx) {
953
1022
  export interface ${upperName}Properties {
954
1023
  ${Object.keys(properties ?? {}).map((key) => {
955
1024
  const value = properties[key];
956
- return match2(value).with({ type: "property" }, (value2) => {
1025
+ return match3(value).with({ type: "property" }, (value2) => {
957
1026
  return `${key}?: PropertyValue<'${value2.value}'>`;
958
1027
  }).with({ type: "token" }, (value2) => {
959
1028
  if (value2.property) {
@@ -968,7 +1037,7 @@ function generatePattern(ctx) {
968
1037
  }).join("\n ")}
969
1038
  }
970
1039
 
971
- ${strict ? outdent10`export declare function ${baseName}(styles: ${upperName}Properties): string` : outdent10`
1040
+ ${strict ? outdent11`export declare function ${baseName}(styles: ${upperName}Properties): string` : outdent11`
972
1041
 
973
1042
  interface ${upperName}Styles extends ${upperName}Properties, DistributiveOmit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}> {}
974
1043
 
@@ -982,7 +1051,7 @@ function generatePattern(ctx) {
982
1051
  `}
983
1052
 
984
1053
  `,
985
- js: outdent10`
1054
+ js: outdent11`
986
1055
  ${ctx.file.import(helperImports.join(", "), "../helpers")}
987
1056
  ${ctx.file.import("css", "../css/index")}
988
1057
 
@@ -1001,8 +1070,8 @@ transform`)}
1001
1070
  // src/artifacts/js/recipe.ts
1002
1071
  import { isSlotRecipe } from "@pandacss/core";
1003
1072
  import { unionType as unionType2 } from "@pandacss/shared";
1004
- import { outdent as outdent11 } from "outdent";
1005
- import { match as match3 } from "ts-pattern";
1073
+ import { outdent as outdent12 } from "outdent";
1074
+ import { match as match4 } from "ts-pattern";
1006
1075
  var stringify2 = (value) => JSON.stringify(value, null, 2);
1007
1076
  var isBooleanValue = (value) => value === "true" || value === "false";
1008
1077
  function generateRecipes(ctx) {
@@ -1016,11 +1085,11 @@ function generateRecipes(ctx) {
1016
1085
  const createRecipeFn = {
1017
1086
  name: "create-recipe",
1018
1087
  dts: "",
1019
- js: outdent11`
1088
+ js: outdent12`
1020
1089
  ${ctx.file.import("css", "../css/css")}
1021
1090
  ${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
1022
1091
  ${ctx.file.import("cx", "../css/cx")}
1023
- ${ctx.file.import("compact, createCss, withoutSpace", "../helpers")}
1092
+ ${ctx.file.import("compact, createCss, splitProps, uniq, withoutSpace", "../helpers")}
1024
1093
 
1025
1094
  export const createRecipe = (name, defaultVariants, compoundVariants) => {
1026
1095
  const getRecipeStyles = (variants) => {
@@ -1067,6 +1136,30 @@ function generateRecipes(ctx) {
1067
1136
  },
1068
1137
  })
1069
1138
  }
1139
+
1140
+ export const mergeRecipes = (recipeA, recipeB) => {
1141
+ if (recipeA && !recipeB) return recipeA
1142
+ if (!recipeA && recipeB) return recipeB
1143
+
1144
+ const recipeFn = (...args) => cx(recipeA(...args), recipeB(...args))
1145
+ const variantKeys = uniq(recipeA.variantKeys, recipeB.variantKeys)
1146
+ const variantMap = variantKeys.reduce((acc, key) => {
1147
+ acc[key] = uniq(recipeA.variantMap[key], recipeB.variantMap[key])
1148
+ return acc
1149
+ }, {})
1150
+
1151
+ return Object.assign(recipeFn, {
1152
+ __recipe__: true,
1153
+ __name__: \`$\{recipeA.__name__} \${recipeB.__name__}\`,
1154
+ raw: (props) => props,
1155
+ variantKeys,
1156
+ variantMap,
1157
+ splitVariantProps(props) {
1158
+ return splitProps(props, variantKeys)
1159
+ },
1160
+ })
1161
+ }
1162
+ }
1070
1163
  `
1071
1164
  };
1072
1165
  return [
@@ -1074,9 +1167,9 @@ function generateRecipes(ctx) {
1074
1167
  ...ctx.recipes.details.map((recipe) => {
1075
1168
  const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
1076
1169
  const { description, defaultVariants, compoundVariants } = config;
1077
- const jsCode = match3(config).when(
1170
+ const jsCode = match4(config).when(
1078
1171
  isSlotRecipe,
1079
- (config2) => outdent11`
1172
+ (config2) => outdent12`
1080
1173
  ${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
1081
1174
  ${ctx.file.import("createRecipe", "./create-recipe")}
1082
1175
 
@@ -1104,9 +1197,9 @@ function generateRecipes(ctx) {
1104
1197
  })
1105
1198
  `
1106
1199
  ).otherwise(
1107
- (config2) => outdent11`
1200
+ (config2) => outdent12`
1108
1201
  ${ctx.file.import("splitProps", "../helpers")}
1109
- ${ctx.file.import("createRecipe", "./create-recipe")}
1202
+ ${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
1110
1203
 
1111
1204
  const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
1112
1205
  defaultVariants ?? {}
@@ -1122,6 +1215,9 @@ function generateRecipes(ctx) {
1122
1215
  raw: (props) => props,
1123
1216
  variantKeys: ${baseName}VariantKeys,
1124
1217
  variantMap: ${baseName}VariantMap,
1218
+ merge(recipe) {
1219
+ return mergeRecipes(this, recipe)
1220
+ },
1125
1221
  splitVariantProps(props) {
1126
1222
  return splitProps(props, ${baseName}VariantKeys)
1127
1223
  },
@@ -1131,10 +1227,9 @@ function generateRecipes(ctx) {
1131
1227
  return {
1132
1228
  name: dashName,
1133
1229
  js: jsCode,
1134
- dts: outdent11`
1230
+ dts: outdent12`
1135
1231
  ${ctx.file.importType("ConditionalValue", "../types/index")}
1136
- ${ctx.file.importType("Pretty", "../types/helpers")}
1137
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
1232
+ ${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
1138
1233
 
1139
1234
  interface ${upperName}Variant {
1140
1235
  ${Object.keys(variantKeyMap).map((key) => {
@@ -1171,10 +1266,10 @@ function generateRecipes(ctx) {
1171
1266
  }
1172
1267
 
1173
1268
  // src/artifacts/js/sva.ts
1174
- import { outdent as outdent12 } from "outdent";
1269
+ import { outdent as outdent13 } from "outdent";
1175
1270
  function generateSvaFn(ctx) {
1176
1271
  return {
1177
- js: outdent12`
1272
+ js: outdent13`
1178
1273
  ${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
1179
1274
  ${ctx.file.import("cva", "./cva")}
1180
1275
 
@@ -1211,7 +1306,7 @@ function generateSvaFn(ctx) {
1211
1306
  })
1212
1307
  }
1213
1308
  `,
1214
- dts: outdent12`
1309
+ dts: outdent13`
1215
1310
  ${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
1216
1311
 
1217
1312
  export declare const sva: SlotRecipeCreatorFn
@@ -1220,7 +1315,7 @@ function generateSvaFn(ctx) {
1220
1315
  }
1221
1316
 
1222
1317
  // src/artifacts/js/token.ts
1223
- import outdent13 from "outdent";
1318
+ import outdent14 from "outdent";
1224
1319
  function generateTokenJs(ctx) {
1225
1320
  const { tokens } = ctx;
1226
1321
  const map = /* @__PURE__ */ new Map();
@@ -1231,7 +1326,7 @@ function generateTokenJs(ctx) {
1231
1326
  });
1232
1327
  const obj = Object.fromEntries(map);
1233
1328
  return {
1234
- js: outdent13`
1329
+ js: outdent14`
1235
1330
  const tokens = ${JSON.stringify(obj, null, 2)}
1236
1331
 
1237
1332
  export function token(path, fallback) {
@@ -1244,7 +1339,7 @@ function generateTokenJs(ctx) {
1244
1339
 
1245
1340
  token.var = tokenVar
1246
1341
  `,
1247
- dts: outdent13`
1342
+ dts: outdent14`
1248
1343
  ${ctx.file.importType("Token", "./tokens")}
1249
1344
 
1250
1345
  export declare const token: {
@@ -1258,19 +1353,21 @@ function generateTokenJs(ctx) {
1258
1353
  }
1259
1354
 
1260
1355
  // src/artifacts/preact-jsx/jsx.ts
1261
- import { outdent as outdent14 } from "outdent";
1356
+ import { outdent as outdent15 } from "outdent";
1262
1357
  function generatePreactJsxFactory(ctx) {
1263
1358
  const { factoryName, componentName } = ctx.jsx;
1264
1359
  return {
1265
- js: outdent14`
1360
+ js: outdent15`
1266
1361
  import { h } from 'preact'
1267
1362
  import { forwardRef } from 'preact/compat'
1268
1363
  import { useMemo } from 'preact/hooks'
1364
+ ${ctx.file.import(
1365
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1366
+ "./factory-helper"
1367
+ )}
1368
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1269
1369
  ${ctx.file.import("css, cx, cva", "../css/index")}
1270
1370
  ${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
1371
 
1275
1372
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1276
1373
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
@@ -1284,23 +1381,26 @@ function generatePreactJsxFactory(ctx) {
1284
1381
  )
1285
1382
 
1286
1383
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1287
- const { as: Element = Dynamic, children, ...restProps } = props
1384
+ const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
1385
+
1386
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1387
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1288
1388
 
1289
1389
  const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1290
1390
 
1291
1391
  const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1292
- return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1392
+ return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1293
1393
  }, [combinedProps])
1294
1394
 
1295
1395
  function recipeClass() {
1296
1396
  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)
1397
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
1398
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1299
1399
  }
1300
1400
 
1301
1401
  function cvaClass() {
1302
1402
  const { css: cssStyles, ...propStyles } = styleProps
1303
- const cvaStyles = cvaFn.raw(variantProps)
1403
+ const cvaStyles = __cvaFn__.raw(variantProps)
1304
1404
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1305
1405
  }
1306
1406
 
@@ -1316,8 +1416,13 @@ function generatePreactJsxFactory(ctx) {
1316
1416
  })
1317
1417
  })
1318
1418
 
1319
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1419
+ const name = getDisplayName(Dynamic)
1420
+
1320
1421
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1422
+ ${componentName}.__cva__ = cvaFn
1423
+ ${componentName}.__base__ = Dynamic
1424
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
1425
+
1321
1426
  return ${componentName}
1322
1427
  }
1323
1428
 
@@ -1343,8 +1448,8 @@ function generatePreactJsxFactory(ctx) {
1343
1448
  }
1344
1449
 
1345
1450
  // src/artifacts/preact-jsx/pattern.ts
1346
- import { outdent as outdent15 } from "outdent";
1347
- import { match as match4 } from "ts-pattern";
1451
+ import { outdent as outdent16 } from "outdent";
1452
+ import { match as match5 } from "ts-pattern";
1348
1453
  function generatePreactJsxPattern(ctx) {
1349
1454
  const { typeName, factoryName } = ctx.jsx;
1350
1455
  return ctx.patterns.details.map((pattern) => {
@@ -1352,21 +1457,21 @@ function generatePreactJsxPattern(ctx) {
1352
1457
  const { description, jsxElement = "div" } = pattern.config;
1353
1458
  return {
1354
1459
  name: dashName,
1355
- js: outdent15`
1460
+ js: outdent16`
1356
1461
  import { h } from 'preact'
1357
1462
  import { forwardRef } from 'preact/compat'
1358
1463
  ${ctx.file.import(factoryName, "./factory")}
1359
1464
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1360
1465
 
1361
1466
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1362
- ${match4(props.length).with(
1467
+ ${match5(props.length).with(
1363
1468
  0,
1364
- () => outdent15`
1469
+ () => outdent16`
1365
1470
  const styleProps = ${styleFnName}()
1366
1471
  return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
1367
1472
  `
1368
1473
  ).otherwise(
1369
- () => outdent15`
1474
+ () => outdent16`
1370
1475
  const { ${props.join(", ")}, ...restProps } = props
1371
1476
  const styleProps = ${styleFnName}({${props.join(", ")}})
1372
1477
  return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
@@ -1374,7 +1479,7 @@ function generatePreactJsxPattern(ctx) {
1374
1479
  )}
1375
1480
  })
1376
1481
  `,
1377
- dts: outdent15`
1482
+ dts: outdent16`
1378
1483
  import type { FunctionComponent } from 'preact'
1379
1484
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1380
1485
  ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
@@ -1390,72 +1495,92 @@ function generatePreactJsxPattern(ctx) {
1390
1495
  }
1391
1496
 
1392
1497
  // src/artifacts/preact-jsx/types.ts
1393
- import { outdent as outdent16 } from "outdent";
1498
+ import { outdent as outdent17 } from "outdent";
1394
1499
  function generatePreactJsxTypes(ctx) {
1395
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1500
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1396
1501
  return {
1397
- jsxFactory: outdent16`
1502
+ jsxFactory: outdent17`
1398
1503
  import type { ${upperName} } from '../types/jsx'
1399
1504
  export declare const ${factoryName}: ${upperName}
1400
1505
  `,
1401
- jsxType: outdent16`
1506
+ jsxType: outdent17`
1402
1507
  import type { ComponentProps, JSX } from 'preact'
1403
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
1404
1508
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1509
+ ${ctx.file.importType(
1510
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
1511
+ "./system-types"
1512
+ )}
1405
1513
 
1406
- type ElementType = keyof JSX.IntrinsicElements
1514
+ export type ElementType = JSX.ElementType
1407
1515
 
1408
- type Dict = Record<string, unknown>
1516
+ interface Dict {
1517
+ [k: string]: unknown
1518
+ }
1409
1519
 
1410
1520
  export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1411
1521
  (props: JsxHTMLProps<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
1412
1522
  displayName?: string
1413
1523
  }
1414
1524
 
1415
- interface RecipeFn { __type: any }
1525
+ interface RecipeFn {
1526
+ __type: any
1527
+ }
1416
1528
 
1417
- interface JsxFactoryOptions<TProps extends Dict> {
1529
+ export interface JsxFactoryOptions<TProps extends Dict> {
1418
1530
  dataAttr?: boolean
1419
1531
  defaultProps?: TProps
1420
1532
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1421
1533
  }
1422
1534
 
1423
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1535
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>
1424
1536
 
1425
- interface JsxFactory {
1537
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
1538
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1539
+ : ${componentName}<T, P>
1540
+
1541
+ export interface JsxFactory {
1426
1542
  <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}<
1543
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1428
1544
  T,
1429
1545
  RecipeSelection<P>
1430
1546
  >
1431
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1547
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1432
1548
  }
1433
1549
 
1434
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1550
+ export type JsxElements = {
1551
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
1552
+ }
1435
1553
 
1436
1554
  export type ${upperName} = JsxFactory & JsxElements
1437
1555
 
1438
1556
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1557
+
1558
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1439
1559
  `
1440
1560
  };
1441
1561
  }
1442
1562
 
1443
1563
  // src/artifacts/preact-jsx/jsx.string-literal.ts
1444
- import { outdent as outdent17 } from "outdent";
1564
+ import { outdent as outdent18 } from "outdent";
1445
1565
  function generatePreactJsxStringLiteralFactory(ctx) {
1446
1566
  const { factoryName, componentName } = ctx.jsx;
1447
1567
  return {
1448
- js: outdent17`
1568
+ js: outdent18`
1449
1569
  import { h } from 'preact'
1450
1570
  import { forwardRef } from 'preact/compat'
1571
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1451
1572
  ${ctx.file.import("css, cx", "../css/index")}
1452
1573
 
1453
1574
  function createStyledFn(Dynamic) {
1454
1575
  return function styledFn(template) {
1455
- const baseClassName = css(template)
1576
+ const styles = css.raw(template)
1577
+
1456
1578
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1457
- const { as: Element = Dynamic, ...elementProps } = props
1458
- const classes = () => cx(baseClassName, elementProps.className)
1579
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
1580
+
1581
+ function classes() {
1582
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
1583
+ }
1459
1584
 
1460
1585
  return h(Element, {
1461
1586
  ref,
@@ -1464,8 +1589,12 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1464
1589
  })
1465
1590
  })
1466
1591
 
1467
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1592
+ const name = getDisplayName(Dynamic)
1593
+
1468
1594
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1595
+ ${componentName}.__styles__ = styles
1596
+ ${componentName}.__base__ = Dynamic
1597
+
1469
1598
  return ${componentName}
1470
1599
  }
1471
1600
  }
@@ -1492,31 +1621,35 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1492
1621
  }
1493
1622
 
1494
1623
  // src/artifacts/preact-jsx/types.string-literal.ts
1495
- import { outdent as outdent18 } from "outdent";
1624
+ import { outdent as outdent19 } from "outdent";
1496
1625
  function generatePreactJsxStringLiteralTypes(ctx) {
1497
1626
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1498
1627
  return {
1499
- jsxFactory: outdent18`
1628
+ jsxFactory: outdent19`
1500
1629
  ${ctx.file.importType(upperName, "../types/jsx")}
1501
1630
  export declare const ${factoryName}: ${upperName}
1502
1631
  `,
1503
- jsxType: outdent18`
1632
+ jsxType: outdent19`
1504
1633
  import type { ComponentProps, JSX } from 'preact'
1505
1634
 
1506
- type ElementType = keyof JSX.IntrinsicElements
1635
+ export type ElementType = JSX.ElementType
1507
1636
 
1508
- type Dict = Record<string, unknown>
1637
+ interface Dict {
1638
+ [k: string]: unknown
1639
+ }
1509
1640
 
1510
1641
  export type ${componentName}<T extends ElementType> = {
1511
1642
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
1512
1643
  displayName?: string
1513
1644
  }
1514
1645
 
1515
- interface JsxFactory {
1646
+ export interface JsxFactory {
1516
1647
  <T extends ElementType>(component: T): ${componentName}<T>
1517
1648
  }
1518
1649
 
1519
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
1650
+ export type JsxElements = {
1651
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
1652
+ }
1520
1653
 
1521
1654
  export type ${upperName} = JsxFactory & JsxElements
1522
1655
 
@@ -1526,18 +1659,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1526
1659
  }
1527
1660
 
1528
1661
  // src/artifacts/qwik-jsx/jsx.ts
1529
- import { outdent as outdent19 } from "outdent";
1662
+ import { outdent as outdent20 } from "outdent";
1530
1663
  function generateQwikJsxFactory(ctx) {
1531
1664
  const { factoryName, componentName } = ctx.jsx;
1532
1665
  return {
1533
- js: outdent19`
1666
+ js: outdent20`
1534
1667
  import { h } from '@builder.io/qwik'
1668
+ ${ctx.file.import(
1669
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1670
+ "./factory-helper"
1671
+ )}
1672
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1535
1673
  ${ctx.file.import("css, cx, cva", "../css/index")}
1536
1674
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1537
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1538
1675
 
1539
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1540
-
1541
1676
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1542
1677
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1543
1678
 
@@ -1550,22 +1685,25 @@ function generateQwikJsxFactory(ctx) {
1550
1685
  )
1551
1686
 
1552
1687
  const ${componentName} = function ${componentName}(props) {
1553
- const { as: Element = Dynamic, children, className, ...restProps } = props
1688
+ const { as: Element = Dynamic.__base__ || Dynamic, children, className, ...restProps } = props
1689
+
1690
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1691
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1554
1692
 
1555
1693
  const combinedProps = Object.assign({}, defaultProps, restProps)
1556
1694
 
1557
1695
  const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
1558
- splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1559
-
1560
- const { css: cssStyles, ...propStyles } = styleProps
1696
+ splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1561
1697
 
1562
1698
  function recipeClass() {
1563
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1564
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1699
+ const { css: cssStyles, ...propStyles } = styleProps
1700
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
1701
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1565
1702
  }
1566
-
1703
+
1567
1704
  function cvaClass() {
1568
- const cvaStyles = cvaFn.raw(variantProps)
1705
+ const { css: cssStyles, ...propStyles } = styleProps
1706
+ const cvaStyles = __cvaFn__.raw(variantProps)
1569
1707
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
1570
1708
  }
1571
1709
 
@@ -1580,8 +1718,13 @@ function generateQwikJsxFactory(ctx) {
1580
1718
  })
1581
1719
  }
1582
1720
 
1583
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1721
+ const name = getDisplayName(Dynamic)
1722
+
1584
1723
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1724
+ ${componentName}.__cva__ = cvaFn
1725
+ ${componentName}.__base__ = Dynamic
1726
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
1727
+
1585
1728
  return ${componentName}
1586
1729
  }
1587
1730
 
@@ -1608,8 +1751,8 @@ function generateQwikJsxFactory(ctx) {
1608
1751
  }
1609
1752
 
1610
1753
  // src/artifacts/qwik-jsx/pattern.ts
1611
- import { outdent as outdent20 } from "outdent";
1612
- import { match as match5 } from "ts-pattern";
1754
+ import { outdent as outdent21 } from "outdent";
1755
+ import { match as match6 } from "ts-pattern";
1613
1756
  function generateQwikJsxPattern(ctx) {
1614
1757
  const { typeName, factoryName } = ctx.jsx;
1615
1758
  return ctx.patterns.details.map((pattern) => {
@@ -1617,20 +1760,20 @@ function generateQwikJsxPattern(ctx) {
1617
1760
  const { description, jsxElement = "div" } = pattern.config;
1618
1761
  return {
1619
1762
  name: dashName,
1620
- js: outdent20`
1763
+ js: outdent21`
1621
1764
  import { h } from '@builder.io/qwik'
1622
1765
  ${ctx.file.import(factoryName, "./factory")}
1623
1766
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1624
1767
 
1625
1768
  export const ${jsxName} = function ${jsxName}(props) {
1626
- ${match5(props.length).with(
1769
+ ${match6(props.length).with(
1627
1770
  0,
1628
- () => outdent20`
1771
+ () => outdent21`
1629
1772
  const styleProps = ${styleFnName}()
1630
1773
  return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
1631
1774
  `
1632
1775
  ).otherwise(
1633
- () => outdent20`
1776
+ () => outdent21`
1634
1777
  const { ${props.join(", ")}, ...restProps } = props
1635
1778
  const styleProps = ${styleFnName}({${props.join(", ")}})
1636
1779
  return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
@@ -1638,7 +1781,7 @@ function generateQwikJsxPattern(ctx) {
1638
1781
  )}
1639
1782
  }
1640
1783
  `,
1641
- dts: outdent20`
1784
+ dts: outdent21`
1642
1785
  import type { Component } from '@builder.io/qwik'
1643
1786
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1644
1787
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -1654,20 +1797,23 @@ function generateQwikJsxPattern(ctx) {
1654
1797
  }
1655
1798
 
1656
1799
  // src/artifacts/qwik-jsx/types.ts
1657
- import { outdent as outdent21 } from "outdent";
1800
+ import { outdent as outdent22 } from "outdent";
1658
1801
  function generateQwikJsxTypes(ctx) {
1659
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1802
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1660
1803
  return {
1661
- jsxFactory: outdent21`
1804
+ jsxFactory: outdent22`
1662
1805
  ${ctx.file.importType(upperName, "../types/jsx")}
1663
1806
  export declare const ${factoryName}: ${upperName}
1664
1807
  `,
1665
- jsxType: outdent21`
1808
+ jsxType: outdent22`
1666
1809
  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'
1810
+ ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1811
+ ${ctx.file.importType(
1812
+ "Assign, DistributiveOmit, DistributiveUnion, JsxStyleProps, PatchedHTMLProps, Pretty",
1813
+ "./system-types"
1814
+ )}
1669
1815
 
1670
- type ElementType = keyof QwikIntrinsicElements | Component<any>
1816
+ export type ElementType = keyof QwikIntrinsicElements | Component<any>
1671
1817
 
1672
1818
  export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
1673
1819
  ? QwikIntrinsicElements[T]
@@ -1675,13 +1821,17 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
1675
1821
  ? P
1676
1822
  : never
1677
1823
 
1678
- type Dict = Record<string, unknown>
1824
+ interface Dict {
1825
+ [k: string]: unknown
1826
+ }
1679
1827
 
1680
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T>, PatchedHTMLProps, Assign<JsxStyleProps, P>>> {}
1828
+ export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T>, Assign<PatchedHTMLProps, Assign<JsxStyleProps, P>>>> {}
1681
1829
 
1682
- interface RecipeFn { __type: any }
1830
+ interface RecipeFn {
1831
+ __type: any
1832
+ }
1683
1833
 
1684
- interface JsxFactoryOptions<TProps extends Dict> {
1834
+ export interface JsxFactoryOptions<TProps extends Dict> {
1685
1835
  dataAttr?: boolean
1686
1836
  defaultProps?: TProps
1687
1837
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -1689,48 +1839,65 @@ interface JsxFactoryOptions<TProps extends Dict> {
1689
1839
 
1690
1840
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1691
1841
 
1692
- interface JsxFactory {
1842
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
1843
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1844
+ : ${componentName}<T, P>
1845
+
1846
+ export interface JsxFactory {
1693
1847
  <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}<
1848
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1695
1849
  T,
1696
1850
  RecipeSelection<P>
1697
1851
  >
1698
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1852
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1699
1853
  }
1700
1854
 
1701
- type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
1855
+ export type JsxElements = {
1856
+ [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}>
1857
+ }
1702
1858
 
1703
1859
  export type ${upperName} = JsxFactory & JsxElements
1704
1860
 
1705
1861
  export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
1862
+
1863
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1706
1864
  `
1707
1865
  };
1708
1866
  }
1709
1867
 
1710
1868
  // src/artifacts/qwik-jsx/jsx.string-literal.ts
1711
- import { outdent as outdent22 } from "outdent";
1869
+ import { outdent as outdent23 } from "outdent";
1712
1870
  function generateQwikJsxStringLiteralFactory(ctx) {
1713
1871
  const { factoryName, componentName } = ctx.jsx;
1714
1872
  return {
1715
- js: outdent22`
1873
+ js: outdent23`
1716
1874
  import { h } from '@builder.io/qwik'
1875
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1717
1876
  ${ctx.file.import("css, cx", "../css/index")}
1718
1877
 
1719
1878
  function createStyledFn(Dynamic) {
1720
1879
  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
- })
1880
+ const styles = css.raw(template)
1881
+
1882
+ const ${componentName} = (props) => {
1883
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
1884
+
1885
+ function classes() {
1886
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
1887
+ }
1888
+
1889
+ return h(Element, {
1890
+ ...elementProps,
1891
+ className: classes(),
1892
+ })
1730
1893
  }
1731
1894
 
1732
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
1895
+ const name = getDisplayName(Dynamic)
1896
+
1733
1897
  ${componentName}.displayName = \`${factoryName}.\${name}\`
1898
+ ${componentName}.__styles__ = styles
1899
+ ${componentName}.__base__ = Dynamic
1900
+
1734
1901
  return ${componentName}
1735
1902
  }
1736
1903
  }
@@ -1758,18 +1925,18 @@ function generateQwikJsxStringLiteralFactory(ctx) {
1758
1925
  }
1759
1926
 
1760
1927
  // src/artifacts/qwik-jsx/types.string-literal.ts
1761
- import { outdent as outdent23 } from "outdent";
1928
+ import { outdent as outdent24 } from "outdent";
1762
1929
  function generateQwikJsxStringLiteralTypes(ctx) {
1763
1930
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1764
1931
  return {
1765
- jsxFactory: outdent23`
1932
+ jsxFactory: outdent24`
1766
1933
  ${ctx.file.importType(upperName, "../types/jsx")}
1767
1934
  export declare const ${factoryName}: ${upperName}
1768
1935
  `,
1769
- jsxType: outdent23`
1936
+ jsxType: outdent24`
1770
1937
  import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
1771
1938
 
1772
- type ElementType = keyof QwikIntrinsicElements | Component<any>
1939
+ export type ElementType = keyof QwikIntrinsicElements | Component<any>
1773
1940
 
1774
1941
  export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
1775
1942
  ? QwikIntrinsicElements[T]
@@ -1777,17 +1944,21 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
1777
1944
  ? P
1778
1945
  : never
1779
1946
 
1780
- type Dict = Record<string, unknown>
1947
+ interface Dict {
1948
+ [k: string]: unknown
1949
+ }
1781
1950
 
1782
1951
  export type ${componentName}<T extends ElementType> = {
1783
1952
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
1784
1953
  }
1785
1954
 
1786
- interface JsxFactory {
1955
+ export interface JsxFactory {
1787
1956
  <T extends ElementType>(component: T): ${componentName}<T>
1788
1957
  }
1789
1958
 
1790
- type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
1959
+ export type JsxElements = {
1960
+ [K in keyof QwikIntrinsicElements]: ${componentName}<K>
1961
+ }
1791
1962
 
1792
1963
  export type ${upperName} = JsxFactory & JsxElements
1793
1964
 
@@ -1797,18 +1968,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1797
1968
  }
1798
1969
 
1799
1970
  // src/artifacts/react-jsx/jsx.ts
1800
- import { outdent as outdent24 } from "outdent";
1971
+ import { outdent as outdent25 } from "outdent";
1801
1972
  function generateReactJsxFactory(ctx) {
1802
1973
  const { factoryName, componentName } = ctx.jsx;
1803
1974
  return {
1804
- js: outdent24`
1975
+ js: outdent25`
1805
1976
  import { createElement, forwardRef, useMemo } from 'react'
1806
1977
  ${ctx.file.import("css, cx, cva", "../css/index")}
1978
+ ${ctx.file.import(
1979
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
1980
+ "./factory-helper"
1981
+ )}
1807
1982
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1808
1983
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1809
1984
 
1810
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1811
-
1812
1985
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
1813
1986
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1814
1987
 
@@ -1821,23 +1994,26 @@ function generateReactJsxFactory(ctx) {
1821
1994
  )
1822
1995
 
1823
1996
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1824
- const { as: Element = Dynamic, children, ...restProps } = props
1997
+ const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
1998
+
1999
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2000
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1825
2001
 
1826
2002
  const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1827
2003
 
1828
2004
  const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1829
- return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2005
+ return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1830
2006
  }, [combinedProps])
1831
2007
 
1832
2008
  function recipeClass() {
1833
2009
  const { css: cssStyles, ...propStyles } = styleProps
1834
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1835
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
2010
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
2011
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
1836
2012
  }
1837
2013
 
1838
2014
  function cvaClass() {
1839
2015
  const { css: cssStyles, ...propStyles } = styleProps
1840
- const cvaStyles = cvaFn.raw(variantProps)
2016
+ const cvaStyles = __cvaFn__.raw(variantProps)
1841
2017
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
1842
2018
  }
1843
2019
 
@@ -1853,8 +2029,13 @@ function generateReactJsxFactory(ctx) {
1853
2029
  })
1854
2030
  })
1855
2031
 
1856
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2032
+ const name = getDisplayName(Dynamic)
2033
+
1857
2034
  ${componentName}.displayName = \`${factoryName}.\${name}\`
2035
+ ${componentName}.__cva__ = cvaFn
2036
+ ${componentName}.__base__ = Dynamic
2037
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2038
+
1858
2039
  return ${componentName}
1859
2040
  }
1860
2041
 
@@ -1881,8 +2062,8 @@ function generateReactJsxFactory(ctx) {
1881
2062
  }
1882
2063
 
1883
2064
  // src/artifacts/react-jsx/pattern.ts
1884
- import { outdent as outdent25 } from "outdent";
1885
- import { match as match6 } from "ts-pattern";
2065
+ import { outdent as outdent26 } from "outdent";
2066
+ import { match as match7 } from "ts-pattern";
1886
2067
  function generateReactJsxPattern(ctx) {
1887
2068
  const { typeName, factoryName } = ctx.jsx;
1888
2069
  return ctx.patterns.details.map((pattern) => {
@@ -1890,20 +2071,20 @@ function generateReactJsxPattern(ctx) {
1890
2071
  const { description, jsxElement = "div" } = pattern.config;
1891
2072
  return {
1892
2073
  name: dashName,
1893
- js: outdent25`
2074
+ js: outdent26`
1894
2075
  import { createElement, forwardRef } from 'react'
1895
2076
  ${ctx.file.import(factoryName, "./factory")}
1896
2077
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1897
2078
 
1898
2079
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1899
- ${match6(props.length).with(
2080
+ ${match7(props.length).with(
1900
2081
  0,
1901
- () => outdent25`
2082
+ () => outdent26`
1902
2083
  const styleProps = ${styleFnName}()
1903
2084
  return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
1904
2085
  `
1905
2086
  ).otherwise(
1906
- () => outdent25`
2087
+ () => outdent26`
1907
2088
  const { ${props.join(", ")}, ...restProps } = props
1908
2089
  const styleProps = ${styleFnName}({${props.join(", ")}})
1909
2090
  return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
@@ -1911,7 +2092,7 @@ function generateReactJsxPattern(ctx) {
1911
2092
  )}
1912
2093
  })
1913
2094
  `,
1914
- dts: outdent25`
2095
+ dts: outdent26`
1915
2096
  import type { FunctionComponent } from 'react'
1916
2097
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1917
2098
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -1927,20 +2108,25 @@ function generateReactJsxPattern(ctx) {
1927
2108
  }
1928
2109
 
1929
2110
  // src/artifacts/react-jsx/types.ts
1930
- import { outdent as outdent26 } from "outdent";
2111
+ import { outdent as outdent27 } from "outdent";
1931
2112
  function generateReactJsxTypes(ctx) {
1932
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2113
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1933
2114
  return {
1934
- jsxFactory: outdent26`
2115
+ jsxFactory: outdent27`
1935
2116
  ${ctx.file.importType(upperName, "../types/jsx")}
1936
2117
  export declare const ${factoryName}: ${upperName}
1937
2118
  `,
1938
- jsxType: outdent26`
2119
+ jsxType: outdent27`
1939
2120
  import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
1940
- ${ctx.file.importType("Assign, DistributiveOmit, JsxHTMLProps, JsxStyleProps", "./system-types")}
1941
2121
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2122
+ ${ctx.file.importType(
2123
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2124
+ "./system-types"
2125
+ )}
1942
2126
 
1943
- type Dict = Record<string, unknown>
2127
+ interface Dict {
2128
+ [k: string]: unknown
2129
+ }
1944
2130
 
1945
2131
  export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
1946
2132
  ref?: Ref<ElementRef<T>>
@@ -1951,7 +2137,9 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1951
2137
  displayName?: string
1952
2138
  }
1953
2139
 
1954
- interface RecipeFn { __type: any }
2140
+ interface RecipeFn {
2141
+ __type: any
2142
+ }
1955
2143
 
1956
2144
  interface JsxFactoryOptions<TProps extends Dict> {
1957
2145
  dataAttr?: boolean
@@ -1961,49 +2149,66 @@ interface JsxFactoryOptions<TProps extends Dict> {
1961
2149
 
1962
2150
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1963
2151
 
1964
- interface JsxFactory {
2152
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2153
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2154
+ : ${componentName}<T, P>
2155
+
2156
+ export interface JsxFactory {
1965
2157
  <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}<
2158
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1967
2159
  T,
1968
2160
  RecipeSelection<P>
1969
2161
  >
1970
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2162
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1971
2163
  }
1972
2164
 
1973
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2165
+ export type JsxElements = {
2166
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2167
+ }
1974
2168
 
1975
2169
  export type ${upperName} = JsxFactory & JsxElements
1976
2170
 
1977
2171
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2172
+
2173
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1978
2174
  `
1979
2175
  };
1980
2176
  }
1981
2177
 
1982
2178
  // src/artifacts/react-jsx/jsx.string-literal.ts
1983
- import { outdent as outdent27 } from "outdent";
2179
+ import { outdent as outdent28 } from "outdent";
1984
2180
  function generateReactJsxStringLiteralFactory(ctx) {
1985
2181
  const { factoryName, componentName } = ctx.jsx;
1986
2182
  return {
1987
- js: outdent27`
2183
+ js: outdent28`
1988
2184
  import { createElement, forwardRef } from 'react'
2185
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
1989
2186
  ${ctx.file.import("css, cx", "../css/index")}
1990
2187
 
1991
2188
  function createStyledFn(Dynamic) {
1992
2189
  return function styledFn(template) {
1993
- const baseClassName = css(template)
2190
+ const styles = css.raw(template)
2191
+
1994
2192
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1995
- const { as: Element = Dynamic, ...elementProps } = props
1996
- const classes = () => cx(baseClassName, elementProps.className)
2193
+ const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
2194
+
2195
+ function classes() {
2196
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
2197
+ }
1997
2198
 
1998
- return createElement(Element, {
1999
- ref,
2000
- ...elementProps,
2001
- className: classes(),
2002
- })
2199
+ return createElement(Element, {
2200
+ ref,
2201
+ ...elementProps,
2202
+ className: classes(),
2203
+ })
2003
2204
  })
2004
2205
 
2005
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2206
+ const name = getDisplayName(Dynamic)
2207
+
2006
2208
  ${componentName}.displayName = \`${factoryName}.\${name}\`
2209
+ ${componentName}.__styles__ = styles
2210
+ ${componentName}.__base__ = Dynamic
2211
+
2007
2212
  return ${componentName}
2008
2213
  }
2009
2214
  }
@@ -2031,19 +2236,21 @@ function generateReactJsxStringLiteralFactory(ctx) {
2031
2236
  }
2032
2237
 
2033
2238
  // src/artifacts/react-jsx/types.string-literal.ts
2034
- import { outdent as outdent28 } from "outdent";
2239
+ import { outdent as outdent29 } from "outdent";
2035
2240
  function generateReactJsxStringLiteralTypes(ctx) {
2036
2241
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2037
2242
  return {
2038
- jsxFactory: outdent28`
2243
+ jsxFactory: outdent29`
2039
2244
  ${ctx.file.importType(upperName, "../types/jsx")}
2040
2245
  export declare const ${factoryName}: ${upperName}
2041
2246
  `,
2042
- jsxType: outdent28`
2247
+ jsxType: outdent29`
2043
2248
  import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
2044
2249
  ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
2045
2250
 
2046
- type Dict = Record<string, unknown>
2251
+ interface Dict {
2252
+ [k: string]: unknown
2253
+ }
2047
2254
 
2048
2255
  export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
2049
2256
  ref?: Ref<ElementRef<T>>
@@ -2054,11 +2261,13 @@ export type ${componentName}<T extends ElementType> = {
2054
2261
  displayName?: string
2055
2262
  }
2056
2263
 
2057
- interface JsxFactory {
2264
+ export interface JsxFactory {
2058
2265
  <T extends ElementType>(component: T): ${componentName}<T>
2059
2266
  }
2060
2267
 
2061
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2268
+ export type JsxElements = {
2269
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
2270
+ }
2062
2271
 
2063
2272
  export type ${upperName} = JsxFactory & JsxElements
2064
2273
 
@@ -2068,19 +2277,21 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
2068
2277
  }
2069
2278
 
2070
2279
  // src/artifacts/solid-jsx/jsx.ts
2071
- import { outdent as outdent29 } from "outdent";
2280
+ import { outdent as outdent30 } from "outdent";
2072
2281
  function generateSolidJsxFactory(ctx) {
2073
2282
  const { componentName, factoryName } = ctx.jsx;
2074
2283
  return {
2075
- js: outdent29`
2284
+ js: outdent30`
2076
2285
  import { Dynamic } from 'solid-js/web'
2077
2286
  import { createMemo, mergeProps, splitProps } from 'solid-js'
2078
2287
  import { createComponent } from 'solid-js/web'
2288
+ ${ctx.file.import(
2289
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
2290
+ "./factory-helper"
2291
+ )}
2292
+ ${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
2079
2293
  ${ctx.file.import("css, cx, cva", "../css/index")}
2080
2294
  ${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
2295
 
2085
2296
  function styledFn(element, configOrCva = {}, options = {}) {
2086
2297
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
@@ -2093,28 +2304,32 @@ function generateSolidJsxFactory(ctx) {
2093
2304
  options.defaultProps,
2094
2305
  )
2095
2306
 
2096
- return function ${componentName}(props) {
2097
- const mergedProps = mergeProps({ as: element }, defaultProps, props)
2307
+ const ${componentName} = (props) => {
2308
+ const mergedProps = mergeProps({ as: element.__base__ || element }, defaultProps, props)
2309
+
2310
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2311
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
2312
+
2098
2313
  const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
2099
2314
 
2100
2315
  const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2101
2316
  mergedProps,
2102
2317
  ['as', 'class', 'className'],
2103
2318
  forwardedKeys(),
2104
- cvaFn.variantKeys,
2319
+ __cvaFn__.variantKeys,
2105
2320
  allCssProperties,
2106
2321
  normalizeHTMLProps.keys
2107
2322
  )
2108
2323
 
2109
2324
  function recipeClass() {
2110
2325
  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)
2326
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
2327
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
2113
2328
  }
2114
2329
 
2115
2330
  function cvaClass() {
2116
2331
  const { css: cssStyles, ...propStyles } = styleProps
2117
- const cvaStyles = cvaFn.raw(variantProps)
2332
+ const cvaStyles = __cvaFn__.raw(variantProps)
2118
2333
  return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
2119
2334
  }
2120
2335
 
@@ -2141,6 +2356,15 @@ function generateSolidJsxFactory(ctx) {
2141
2356
  )
2142
2357
  )
2143
2358
  }
2359
+
2360
+ const name = getDisplayName(element)
2361
+
2362
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2363
+ ${componentName}.__cva__ = cvaFn
2364
+ ${componentName}.__base__ = element
2365
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2366
+
2367
+ return ${componentName}
2144
2368
  }
2145
2369
 
2146
2370
  function createJsxFactory() {
@@ -2165,8 +2389,8 @@ function generateSolidJsxFactory(ctx) {
2165
2389
  }
2166
2390
 
2167
2391
  // src/artifacts/solid-jsx/pattern.ts
2168
- import { outdent as outdent30 } from "outdent";
2169
- import { match as match7 } from "ts-pattern";
2392
+ import { outdent as outdent31 } from "outdent";
2393
+ import { match as match8 } from "ts-pattern";
2170
2394
  function generateSolidJsxPattern(ctx) {
2171
2395
  const { typeName, factoryName } = ctx.jsx;
2172
2396
  return ctx.patterns.details.map((pattern) => {
@@ -2174,21 +2398,21 @@ function generateSolidJsxPattern(ctx) {
2174
2398
  const { description, jsxElement = "div" } = pattern.config;
2175
2399
  return {
2176
2400
  name: dashName,
2177
- js: outdent30`
2401
+ js: outdent31`
2178
2402
  import { splitProps, mergeProps } from 'solid-js'
2179
2403
  import { createComponent } from 'solid-js/web'
2180
2404
  ${ctx.file.import(factoryName, "./factory")}
2181
2405
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2182
2406
 
2183
2407
  export function ${jsxName}(props) {
2184
- ${match7(props.length).with(
2408
+ ${match8(props.length).with(
2185
2409
  0,
2186
- () => outdent30`
2410
+ () => outdent31`
2187
2411
  const styleProps = ${styleFnName}()
2188
2412
  return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
2189
2413
  `
2190
2414
  ).otherwise(
2191
- () => outdent30`
2415
+ () => outdent31`
2192
2416
  const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
2193
2417
  const styleProps = ${styleFnName}(patternProps)
2194
2418
  return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
@@ -2196,7 +2420,7 @@ function generateSolidJsxPattern(ctx) {
2196
2420
  )}
2197
2421
  }
2198
2422
  `,
2199
- dts: outdent30`
2423
+ dts: outdent31`
2200
2424
  import type { Component } from 'solid-js'
2201
2425
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2202
2426
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -2212,31 +2436,38 @@ function generateSolidJsxPattern(ctx) {
2212
2436
  }
2213
2437
 
2214
2438
  // src/artifacts/solid-jsx/types.ts
2215
- import { outdent as outdent31 } from "outdent";
2439
+ import { outdent as outdent32 } from "outdent";
2216
2440
  function generateSolidJsxTypes(ctx) {
2217
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2441
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2218
2442
  return {
2219
- jsxFactory: outdent31`
2443
+ jsxFactory: outdent32`
2220
2444
  ${ctx.file.importType(upperName, "../types/jsx")}
2221
2445
  export declare const ${factoryName}: ${upperName}
2222
2446
  `,
2223
- jsxType: outdent31`
2447
+ jsxType: outdent32`
2224
2448
  import type { ComponentProps, Component, JSX } from 'solid-js'
2225
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
2226
2449
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2450
+ ${ctx.file.importType(
2451
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2452
+ "./system-types"
2453
+ )}
2227
2454
 
2228
- type Dict = Record<string, unknown>
2455
+ interface Dict {
2456
+ [k: string]: unknown
2457
+ }
2229
2458
 
2230
- type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2459
+ export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2231
2460
 
2232
2461
  export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2233
2462
  (props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
2234
2463
  displayName?: string
2235
2464
  }
2236
2465
 
2237
- interface RecipeFn { __type: any }
2466
+ interface RecipeFn {
2467
+ __type: any
2468
+ }
2238
2469
 
2239
- interface JsxFactoryOptions<TProps extends Dict> {
2470
+ export interface JsxFactoryOptions<TProps extends Dict> {
2240
2471
  dataAttr?: boolean
2241
2472
  defaultProps?: TProps
2242
2473
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -2244,41 +2475,51 @@ interface JsxFactoryOptions<TProps extends Dict> {
2244
2475
 
2245
2476
  export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
2246
2477
 
2247
- interface JsxFactory {
2478
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2479
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2480
+ : ${componentName}<T, P>
2481
+
2482
+ export interface JsxFactory {
2248
2483
  <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}<
2484
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2250
2485
  T,
2251
2486
  RecipeSelection<P>
2252
2487
  >
2253
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2488
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
2254
2489
  }
2255
2490
 
2256
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2491
+ export type JsxElements = {
2492
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2493
+ }
2257
2494
 
2258
2495
  export type ${upperName} = JsxFactory & JsxElements
2259
2496
 
2260
2497
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2498
+
2499
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2261
2500
  `
2262
2501
  };
2263
2502
  }
2264
2503
 
2265
2504
  // src/artifacts/solid-jsx/jsx.string-literal.ts
2266
- import { outdent as outdent32 } from "outdent";
2505
+ import { outdent as outdent33 } from "outdent";
2267
2506
  function generateSolidJsxStringLiteralFactory(ctx) {
2268
2507
  const { componentName, factoryName } = ctx.jsx;
2269
2508
  return {
2270
- js: outdent32`
2509
+ js: outdent33`
2271
2510
  import { mergeProps, splitProps } from 'solid-js'
2272
2511
  import { Dynamic, createComponent } from 'solid-js/web'
2512
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
2273
2513
  ${ctx.file.import("css, cx", "../css/index")}
2274
2514
 
2275
2515
  function createStyled(element) {
2276
2516
  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'])
2517
+ const styles = css.raw(template)
2281
2518
 
2519
+ const ${componentName} = (props) => {
2520
+ const mergedProps = mergeProps({ as: element.__base__ || element }, props)
2521
+ const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
2522
+
2282
2523
  return createComponent(
2283
2524
  Dynamic,
2284
2525
  mergeProps(
@@ -2287,13 +2528,21 @@ function createStyled(element) {
2287
2528
  return localProps.as
2288
2529
  },
2289
2530
  get class() {
2290
- return cx(baseClassName, localProps.class)
2531
+ return cx(css(element.__styles__, styles), localProps.class)
2291
2532
  },
2292
2533
  },
2293
2534
  elementProps,
2294
2535
  ),
2295
2536
  )
2296
2537
  }
2538
+
2539
+ const name = getDisplayName(element)
2540
+
2541
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2542
+ ${componentName}.__styles__ = styles
2543
+ ${componentName}.__base__ = element
2544
+
2545
+ return ${componentName}
2297
2546
  }
2298
2547
  }
2299
2548
 
@@ -2319,31 +2568,35 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2319
2568
  }
2320
2569
 
2321
2570
  // src/artifacts/solid-jsx/types.string-literal.ts
2322
- import { outdent as outdent33 } from "outdent";
2571
+ import { outdent as outdent34 } from "outdent";
2323
2572
  function generateSolidJsxStringLiteralTypes(ctx) {
2324
2573
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2325
2574
  return {
2326
- jsxFactory: outdent33`
2575
+ jsxFactory: outdent34`
2327
2576
  ${ctx.file.importType(upperName, "../types/jsx")}
2328
2577
  export declare const ${factoryName}: ${upperName}
2329
2578
  `,
2330
- jsxType: outdent33`
2579
+ jsxType: outdent34`
2331
2580
  import type { Component, ComponentProps, JSX } from 'solid-js'
2332
2581
 
2333
- type Dict = Record<string, unknown>
2582
+ interface Dict {
2583
+ [k: string]: unknown
2584
+ }
2334
2585
 
2335
- type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2586
+ export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
2336
2587
 
2337
2588
  export type ${componentName}<T extends ElementType> = {
2338
2589
  (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
2339
2590
  displayName?: string
2340
2591
  }
2341
2592
 
2342
- interface JsxFactory {
2593
+ export interface JsxFactory {
2343
2594
  <T extends ElementType>(component: T): ${componentName}<T>
2344
2595
  }
2345
2596
 
2346
- type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2597
+ export type JsxElements = {
2598
+ [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
2599
+ }
2347
2600
 
2348
2601
  export type ${upperName} = JsxFactory & JsxElements
2349
2602
 
@@ -2353,18 +2606,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
2353
2606
  }
2354
2607
 
2355
2608
  // src/artifacts/vue-jsx/jsx.ts
2356
- import { outdent as outdent34 } from "outdent";
2609
+ import { outdent as outdent35 } from "outdent";
2357
2610
  function generateVueJsxFactory(ctx) {
2358
- const { factoryName } = ctx.jsx;
2611
+ const { factoryName, componentName } = ctx.jsx;
2359
2612
  return {
2360
- js: outdent34`
2613
+ js: outdent35`
2361
2614
  import { defineComponent, h, computed } from 'vue'
2615
+ ${ctx.file.import(
2616
+ "defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
2617
+ "./factory-helper"
2618
+ )}
2619
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2362
2620
  ${ctx.file.import("css, cx, cva", "../css/index")}
2363
2621
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
2364
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2365
2622
 
2366
- const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2367
-
2368
2623
  function styledFn(Dynamic, configOrCva = {}, options = {}) {
2369
2624
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2370
2625
 
@@ -2376,30 +2631,33 @@ function generateVueJsxFactory(ctx) {
2376
2631
  options.defaultProps,
2377
2632
  )
2378
2633
 
2379
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2634
+ const name = getDisplayName(Dynamic)
2380
2635
 
2381
- return defineComponent({
2636
+ const ${componentName} = defineComponent({
2382
2637
  name: \`${factoryName}.\${name}\`,
2383
2638
  inheritAttrs: false,
2384
- props: { as: { type: [String, Object], default: Dynamic } },
2639
+ props: { as: { type: [String, Object], default: Dynamic.__base__ || Dynamic } },
2385
2640
  setup(props, { slots, attrs }) {
2641
+ const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2642
+ const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
2643
+
2386
2644
  const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
2387
2645
 
2388
2646
  const splittedProps = computed(() => {
2389
- return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2647
+ return splitProps(combinedProps.value, shouldForwardProp, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2390
2648
  })
2391
2649
 
2392
2650
  const recipeClass = computed(() => {
2393
2651
  const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2394
2652
  const { css: cssStyles, ...propStyles } = styleProps
2395
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2396
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2653
+ const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
2654
+ return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2397
2655
  })
2398
2656
 
2399
2657
  const cvaClass = computed(() => {
2400
2658
  const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2401
2659
  const { css: cssStyles, ...propStyles } = styleProps
2402
- const cvaStyles = cvaFn.raw(variantProps)
2660
+ const cvaStyles = __cvaFn__.raw(variantProps)
2403
2661
  return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
2404
2662
  })
2405
2663
 
@@ -2420,6 +2678,13 @@ function generateVueJsxFactory(ctx) {
2420
2678
  }
2421
2679
  },
2422
2680
  })
2681
+
2682
+ ${componentName}.displayName = \`${factoryName}.\${name}\`
2683
+ ${componentName}.__cva__ = cvaFn
2684
+ ${componentName}.__base__ = Dynamic
2685
+ ${componentName}.__shouldForwardProps__ = shouldForwardProp
2686
+
2687
+ return ${componentName}
2423
2688
  }
2424
2689
 
2425
2690
  function createJsxFactory() {
@@ -2440,25 +2705,30 @@ function generateVueJsxFactory(ctx) {
2440
2705
  }
2441
2706
 
2442
2707
  // src/artifacts/vue-jsx/jsx.string-literal.ts
2443
- import { outdent as outdent35 } from "outdent";
2708
+ import { outdent as outdent36 } from "outdent";
2444
2709
  function generateVueJsxStringLiteralFactory(ctx) {
2445
- const { factoryName } = ctx.jsx;
2710
+ const { componentName, factoryName } = ctx.jsx;
2446
2711
  return {
2447
- js: outdent35`
2712
+ js: outdent36`
2448
2713
  import { defineComponent, h, computed } from 'vue'
2714
+ ${ctx.file.import("getDisplayName", "./factory-helper")}
2449
2715
  ${ctx.file.import("css, cx", "../css/index")}
2450
2716
 
2451
2717
  function createStyled(Dynamic) {
2452
- const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2718
+ const name = getDisplayName(Dynamic)
2453
2719
 
2454
2720
  function styledFn(template) {
2455
- const baseClassName = css(template)
2456
- return defineComponent({
2721
+ const styles = css.raw(template)
2722
+
2723
+ const ${componentName} = defineComponent({
2457
2724
  name: \`${factoryName}.\${name}\`,
2458
2725
  inheritAttrs: false,
2459
2726
  props: { as: { type: [String, Object], default: Dynamic } },
2460
2727
  setup(props, { slots, attrs }) {
2461
- const classes = computed(() => cx(baseClassName, elementProps.className))
2728
+ const classes = computed(() => {
2729
+ return cx(css(Dynamic.__styles__, styles), elementProps.className)
2730
+ })
2731
+
2462
2732
  return () => {
2463
2733
  return h(
2464
2734
  props.as,
@@ -2471,6 +2741,11 @@ function generateVueJsxStringLiteralFactory(ctx) {
2471
2741
  }
2472
2742
  },
2473
2743
  })
2744
+
2745
+ ${componentName}.__styles__ = styles
2746
+ ${componentName}.__base__ = element
2747
+
2748
+ return ${componentName}
2474
2749
  }
2475
2750
  }
2476
2751
 
@@ -2496,7 +2771,7 @@ function generateVueJsxStringLiteralFactory(ctx) {
2496
2771
  }
2497
2772
 
2498
2773
  // src/artifacts/vue-jsx/pattern.ts
2499
- import { outdent as outdent36 } from "outdent";
2774
+ import { outdent as outdent37 } from "outdent";
2500
2775
  function generateVueJsxPattern(ctx) {
2501
2776
  const { typeName, factoryName } = ctx.jsx;
2502
2777
  return ctx.patterns.details.map((pattern) => {
@@ -2505,7 +2780,7 @@ function generateVueJsxPattern(ctx) {
2505
2780
  const propList = props.map((v) => JSON.stringify(v)).join(", ");
2506
2781
  return {
2507
2782
  name: dashName,
2508
- js: outdent36`
2783
+ js: outdent37`
2509
2784
  import { defineComponent, h, computed } from 'vue'
2510
2785
  ${ctx.file.import(factoryName, "./factory")}
2511
2786
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
@@ -2523,7 +2798,7 @@ function generateVueJsxPattern(ctx) {
2523
2798
  }
2524
2799
  })
2525
2800
  `,
2526
- dts: outdent36`
2801
+ dts: outdent37`
2527
2802
  import type { FunctionalComponent } from 'vue'
2528
2803
  ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2529
2804
  ${ctx.file.importType(typeName, "../types/jsx")}
@@ -2539,23 +2814,27 @@ function generateVueJsxPattern(ctx) {
2539
2814
  }
2540
2815
 
2541
2816
  // src/artifacts/vue-jsx/types.ts
2542
- import { outdent as outdent37 } from "outdent";
2817
+ import { outdent as outdent38 } from "outdent";
2543
2818
  function generateVueJsxTypes(ctx) {
2544
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2819
+ const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2545
2820
  return {
2546
- jsxFactory: outdent37`
2821
+ jsxFactory: outdent38`
2547
2822
  ${ctx.file.importType(upperName, "../types/jsx")}
2548
2823
 
2549
2824
  export declare const ${factoryName}: ${upperName}
2550
2825
  `,
2551
- jsxType: outdent37`
2826
+ jsxType: outdent38`
2552
2827
  import type { Component, FunctionalComponent, NativeElements } from 'vue'
2553
2828
 
2554
2829
  ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2555
- ${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
2830
+ ${ctx.file.importType(
2831
+ "Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
2832
+ "./system-types"
2833
+ )}
2556
2834
 
2557
- type IntrinsicElement = keyof NativeElements
2558
- type ElementType = IntrinsicElement | Component
2835
+ export type IntrinsicElement = keyof NativeElements
2836
+
2837
+ export type ElementType = IntrinsicElement | Component
2559
2838
 
2560
2839
  export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2561
2840
  ? NativeElements[T]
@@ -2563,13 +2842,15 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2563
2842
  ? Props
2564
2843
  : never
2565
2844
 
2566
- interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
2567
- JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2845
+ export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
2846
+ JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2568
2847
  > {}
2569
2848
 
2570
- interface RecipeFn { __type: any }
2849
+ interface RecipeFn {
2850
+ __type: any
2851
+ }
2571
2852
 
2572
- interface JsxFactoryOptions<TProps extends Dict> {
2853
+ export interface JsxFactoryOptions<TProps extends Dict> {
2573
2854
  dataAttr?: boolean
2574
2855
  defaultProps?: TProps
2575
2856
  shouldForwardProp?(prop: string, variantKeys: string[]): boolean
@@ -2577,39 +2858,48 @@ interface JsxFactoryOptions<TProps extends Dict> {
2577
2858
 
2578
2859
  export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
2579
2860
 
2580
- interface JsxFactory {
2861
+ export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
2862
+ ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2863
+ : ${componentName}<T, P>
2864
+
2865
+ export interface JsxFactory {
2581
2866
  <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}<
2867
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2583
2868
  T,
2584
2869
  RecipeSelection<P>
2585
2870
  >
2586
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): ${componentName}<T, P['__type']>
2871
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): JsxElement<T, P['__type']>
2587
2872
  }
2588
2873
 
2589
- type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
2874
+ export type JsxElements = {
2875
+ [K in IntrinsicElement]: ${componentName}<K, {}>
2876
+ }
2590
2877
 
2591
2878
  export type ${upperName} = JsxFactory & JsxElements
2592
2879
 
2593
2880
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2881
+
2882
+ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2594
2883
  `
2595
2884
  };
2596
2885
  }
2597
2886
 
2598
2887
  // src/artifacts/vue-jsx/types.string-literal.ts
2599
- import { outdent as outdent38 } from "outdent";
2888
+ import { outdent as outdent39 } from "outdent";
2600
2889
  function generateVueJsxStringLiteralTypes(ctx) {
2601
2890
  const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2602
2891
  return {
2603
- jsxFactory: outdent38`
2892
+ jsxFactory: outdent39`
2604
2893
  ${ctx.file.importType(upperName, "../types/jsx")}
2605
2894
 
2606
2895
  export declare const ${factoryName}: ${upperName}
2607
2896
  `,
2608
- jsxType: outdent38`
2897
+ jsxType: outdent39`
2609
2898
  import type { Component, FunctionalComponent, NativeElements } from 'vue'
2610
2899
 
2611
- type IntrinsicElement = keyof NativeElements
2612
- type ElementType = IntrinsicElement | Component
2900
+ export type IntrinsicElement = keyof NativeElements
2901
+
2902
+ export type ElementType = IntrinsicElement | Component
2613
2903
 
2614
2904
  export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2615
2905
  ? NativeElements[T]
@@ -2617,14 +2907,16 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
2617
2907
  ? Props
2618
2908
  : never
2619
2909
 
2620
- type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
2910
+ export type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
2621
2911
  >
2622
2912
 
2623
- interface JsxFactory {
2913
+ export interface JsxFactory {
2624
2914
  <T extends ElementType>(component: T): ${componentName}<T>
2625
2915
  }
2626
2916
 
2627
- type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
2917
+ export type JsxElements = {
2918
+ [K in IntrinsicElement]: ${componentName}<K>
2919
+ }
2628
2920
 
2629
2921
  export type ${upperName} = JsxFactory & JsxElements
2630
2922
 
@@ -2741,12 +3033,12 @@ var csstype_d_ts_default = {
2741
3033
 
2742
3034
  // src/artifacts/generated/system-types.d.ts.json
2743
3035
  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"
3036
+ 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
3037
  };
2746
3038
 
2747
3039
  // src/artifacts/generated/composition.d.ts.json
2748
3040
  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"
3041
+ 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
3042
  };
2751
3043
 
2752
3044
  // src/artifacts/generated/recipe.d.ts.json
@@ -2770,7 +3062,7 @@ var selectors_d_ts_default = {
2770
3062
  };
2771
3063
 
2772
3064
  // src/artifacts/types/generated.ts
2773
- import { match as match8 } from "ts-pattern";
3065
+ import { match as match9 } from "ts-pattern";
2774
3066
  var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
2775
3067
  function getGeneratedTypes(ctx) {
2776
3068
  const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
@@ -2782,15 +3074,15 @@ function getGeneratedTypes(ctx) {
2782
3074
  composition: rewriteImports(composition_d_ts_default.content),
2783
3075
  selectors: rewriteImports(selectors_d_ts_default.content),
2784
3076
  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()
3077
+ match9(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()
2786
3078
  )
2787
3079
  };
2788
3080
  }
2789
3081
 
2790
3082
  // src/artifacts/types/main.ts
2791
- import { outdent as outdent39 } from "outdent";
3083
+ import { outdent as outdent40 } from "outdent";
2792
3084
  var generateTypesEntry = (ctx) => ({
2793
- global: outdent39`
3085
+ global: outdent40`
2794
3086
  // @ts-nocheck
2795
3087
  import type * as Panda from '@pandacss/dev'
2796
3088
  ${ctx.file.importType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
@@ -2811,7 +3103,7 @@ var generateTypesEntry = (ctx) => ({
2811
3103
  }
2812
3104
  `,
2813
3105
  // 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`
3106
+ index: outdent40`
2815
3107
  import '${ctx.file.extDts("./global")}'
2816
3108
  ${ctx.file.exportTypeStar("./conditions")}
2817
3109
  ${ctx.file.exportTypeStar("./pattern")}
@@ -2821,13 +3113,13 @@ var generateTypesEntry = (ctx) => ({
2821
3113
  ${ctx.file.exportTypeStar("./style-props")}
2822
3114
 
2823
3115
  `,
2824
- helpers: outdent39`
3116
+ helpers: outdent40`
2825
3117
  export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
2826
3118
  `
2827
3119
  });
2828
3120
 
2829
3121
  // src/artifacts/types/prop-types.ts
2830
- import { outdent as outdent40 } from "outdent";
3122
+ import { outdent as outdent41 } from "outdent";
2831
3123
  function generatePropTypes(ctx) {
2832
3124
  const {
2833
3125
  config: { strictTokens },
@@ -2835,7 +3127,7 @@ function generatePropTypes(ctx) {
2835
3127
  } = ctx;
2836
3128
  const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
2837
3129
  const result = [
2838
- outdent40`
3130
+ outdent41`
2839
3131
  ${ctx.file.importType("ConditionalValue", "./conditions")}
2840
3132
  ${ctx.file.importType("CssProperties", "./system-types")}
2841
3133
  ${ctx.file.importType("Tokens", "../tokens/index")}
@@ -2858,7 +3150,7 @@ function generatePropTypes(ctx) {
2858
3150
  result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
2859
3151
  });
2860
3152
  result.push("}");
2861
- return outdent40`
3153
+ return outdent41`
2862
3154
  ${result.join("\n")}
2863
3155
 
2864
3156
  export type PropertyValue<T extends string> = T extends keyof PropertyTypes
@@ -2871,10 +3163,10 @@ function generatePropTypes(ctx) {
2871
3163
 
2872
3164
  // src/artifacts/types/style-props.ts
2873
3165
  import { allCssProperties } from "@pandacss/is-valid-prop";
2874
- import outdent41 from "outdent";
3166
+ import outdent42 from "outdent";
2875
3167
  function generateStyleProps(ctx) {
2876
3168
  const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
2877
- return outdent41`
3169
+ return outdent42`
2878
3170
  ${ctx.file.importType("ConditionalValue", "./conditions")}
2879
3171
  ${ctx.file.importType("PropertyValue", "./prop-type")}
2880
3172
  ${ctx.file.importType("Token", "../tokens/index")}
@@ -2891,7 +3183,7 @@ function generateStyleProps(ctx) {
2891
3183
 
2892
3184
  // src/artifacts/types/token-types.ts
2893
3185
  import { capitalize, unionType as unionType3 } from "@pandacss/shared";
2894
- import { outdent as outdent42 } from "outdent";
3186
+ import { outdent as outdent43 } from "outdent";
2895
3187
  import pluralize from "pluralize";
2896
3188
  var categories = [
2897
3189
  "zIndex",
@@ -2942,7 +3234,7 @@ function generateTokenTypes(ctx) {
2942
3234
  result.add("} & { [token: string]: never }");
2943
3235
  set.add(Array.from(result).join("\n"));
2944
3236
  set.add(`export type TokenCategory = ${unionType3(categories)}`);
2945
- return outdent42.string(Array.from(set).join("\n\n"));
3237
+ return outdent43.string(Array.from(set).join("\n\n"));
2946
3238
  }
2947
3239
 
2948
3240
  // src/artifacts/index.ts
@@ -2988,7 +3280,6 @@ function setupTypes(ctx) {
2988
3280
  { file: ctx.file.extDts("selectors"), code: gen.selectors },
2989
3281
  { file: ctx.file.extDts("composition"), code: gen.composition },
2990
3282
  { file: ctx.file.extDts("global"), code: entry.global },
2991
- { file: ctx.file.extDts("helpers"), code: entry.helpers },
2992
3283
  { file: ctx.file.extDts("recipe"), code: gen.recipe },
2993
3284
  { file: ctx.file.extDts("pattern"), code: gen.pattern },
2994
3285
  { file: ctx.file.extDts("parts"), code: gen.parts },
@@ -3051,8 +3342,8 @@ function setupRecipes(ctx) {
3051
3342
  return;
3052
3343
  const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
3053
3344
  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"))
3345
+ js: outdent44.string(indexFiles.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3346
+ dts: outdent44.string(indexFiles.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3056
3347
  };
3057
3348
  return {
3058
3349
  dir: ctx.paths.recipe,
@@ -3071,8 +3362,8 @@ function setupPatterns(ctx) {
3071
3362
  if (!files)
3072
3363
  return;
3073
3364
  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"))
3365
+ js: outdent44.string(files.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
3366
+ dts: outdent44.string(files.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
3076
3367
  };
3077
3368
  return {
3078
3369
  dir: ctx.paths.pattern,
@@ -3091,18 +3382,19 @@ function setupJsx(ctx) {
3091
3382
  const types = generateJsxTypes(ctx);
3092
3383
  const factory = generateJsxFactory(ctx);
3093
3384
  const patterns = generateJsxPatterns(ctx);
3385
+ const helpers3 = generatedJsxHelpers(ctx);
3094
3386
  const index = {
3095
- js: outdent43`
3387
+ js: outdent44`
3096
3388
  ${ctx.file.exportStar("./factory")}
3097
3389
  ${isValidProp?.js ? ctx.file.exportStar("./is-valid-prop") : ""}
3098
- ${outdent43.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
3390
+ ${outdent44.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
3099
3391
  `,
3100
- dts: outdent43`
3392
+ dts: outdent44`
3101
3393
  ${ctx.file.exportTypeStar("./factory")}
3102
3394
 
3103
3395
  ${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
3104
3396
 
3105
- ${outdent43.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
3397
+ ${outdent44.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
3106
3398
 
3107
3399
  ${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
3108
3400
  `
@@ -3114,6 +3406,7 @@ function setupJsx(ctx) {
3114
3406
  ...patterns.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
3115
3407
  { file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
3116
3408
  { file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts },
3409
+ { file: ctx.file.ext("factory-helper"), code: helpers3.js },
3117
3410
  { file: ctx.file.ext("factory"), code: factory?.js },
3118
3411
  { file: ctx.file.extDts("factory"), code: types.jsxFactory },
3119
3412
  { file: ctx.file.ext("index"), code: index.js },
@@ -3123,13 +3416,13 @@ function setupJsx(ctx) {
3123
3416
  }
3124
3417
  function setupCssIndex(ctx) {
3125
3418
  const index = {
3126
- js: outdent43`
3419
+ js: outdent44`
3127
3420
  ${ctx.file.exportStar("./css")}
3128
3421
  ${ctx.file.exportStar("./cx")}
3129
3422
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./cva")}
3130
3423
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./sva")}
3131
3424
  `,
3132
- dts: outdent43`
3425
+ dts: outdent44`
3133
3426
  ${ctx.file.exportTypeStar("./css")}
3134
3427
  ${ctx.file.exportTypeStar("./cx")}
3135
3428
  ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./cva")}
@@ -3191,6 +3484,8 @@ var generateArtifacts = (ctx) => () => {
3191
3484
  ].filter(Boolean).map((artifact) => {
3192
3485
  const files = artifact?.files ?? [];
3193
3486
  files.forEach((file) => {
3487
+ if (!file)
3488
+ return;
3194
3489
  if (ctx.file.isTypeFile(file.file)) {
3195
3490
  file.code = `/* eslint-disable */
3196
3491
  ${file.code}`;
@@ -3230,7 +3525,7 @@ var generateFlattenedCss = (ctx) => (options) => {
3230
3525
  // src/artifacts/css/parser-css.ts
3231
3526
  import { logger } from "@pandacss/logger";
3232
3527
  import { pipe, tap, tryCatch } from "lil-fp/func";
3233
- import { P, match as match9 } from "ts-pattern";
3528
+ import { P, match as match10 } from "ts-pattern";
3234
3529
  var generateParserCss = (ctx) => (result) => pipe(
3235
3530
  { ...ctx, sheet: ctx.createSheet(), result },
3236
3531
  tap(({ sheet, result: result2, patterns, recipes }) => {
@@ -3260,7 +3555,7 @@ var generateParserCss = (ctx) => (result) => pipe(
3260
3555
  const recipeConfig = recipes.getConfig(recipeName);
3261
3556
  if (!recipeConfig)
3262
3557
  continue;
3263
- match9(recipe).with({ type: "jsx-recipe" }, () => {
3558
+ match10(recipe).with({ type: "jsx-recipe" }, () => {
3264
3559
  recipe.data.forEach((data) => {
3265
3560
  const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3266
3561
  sheet.processStyleProps(filterProps(ctx, styleProps));
@@ -3279,7 +3574,7 @@ var generateParserCss = (ctx) => (result) => pipe(
3279
3574
  result2.pattern.forEach((patternSet, name) => {
3280
3575
  try {
3281
3576
  for (const pattern of patternSet) {
3282
- match9(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3577
+ match10(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3283
3578
  pattern.data.forEach((data) => {
3284
3579
  const fnName = patterns.find(jsxName);
3285
3580
  const styleProps = patterns.transform(fnName, data);
@@ -3438,6 +3733,7 @@ var getJsxEngine = (config) => {
3438
3733
  factoryName: jsxFactory,
3439
3734
  upperName: capitalize2(jsxFactory),
3440
3735
  typeName: `HTML${capitalize2(jsxFactory)}Props`,
3736
+ variantName: `${capitalize2(jsxFactory)}VariantProps`,
3441
3737
  componentName: `${capitalize2(jsxFactory)}Component`,
3442
3738
  framework: jsxFramework,
3443
3739
  styleProps: jsxStyleProps2 ?? "all"
@@ -3586,8 +3882,16 @@ var createGenerator = (conf) => {
3586
3882
  return {
3587
3883
  ...ctx,
3588
3884
  getArtifacts: generateArtifacts(ctx),
3885
+ //
3886
+ getStaticCss: generateStaticCss,
3887
+ getResetCss: generateResetCss,
3888
+ getTokenCss: generateTokenCss,
3889
+ getKeyframeCss: generateKeyframeCss,
3890
+ getGlobalCss: generateGlobalCss,
3891
+ //
3589
3892
  getCss: generateFlattenedCss(ctx),
3590
3893
  getParserCss: generateParserCss(ctx),
3894
+ //
3591
3895
  messages: getMessages(ctx),
3592
3896
  parserOptions: {
3593
3897
  importMap: getImportMap(config.outdir.replace(relativeBaseUrl, ""), config.importMap),