@pandacss/generator 0.15.3 → 0.15.4

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.
Files changed (3) hide show
  1. package/dist/index.js +210 -129
  2. package/dist/index.mjs +210 -129
  3. package/package.json +8 -8
package/dist/index.mjs CHANGED
@@ -1094,6 +1094,7 @@ function generateRecipes(ctx) {
1094
1094
 
1095
1095
  export const ${baseName} = Object.assign(${baseName}Fn, {
1096
1096
  __recipe__: false,
1097
+ __name__: '${baseName}',
1097
1098
  raw: (props) => props,
1098
1099
  variantKeys: ${baseName}VariantKeys,
1099
1100
  variantMap: ${stringify2(variantKeyMap)},
@@ -1115,6 +1116,7 @@ function generateRecipes(ctx) {
1115
1116
  const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
1116
1117
  export const ${baseName} = Object.assign(${baseName}Fn, {
1117
1118
  __recipe__: true,
1119
+ __name__: '${baseName}',
1118
1120
  raw: (props) => props,
1119
1121
  variantKeys: ${baseName}VariantKeys,
1120
1122
  variantMap: ${baseName}VariantMap,
@@ -1266,33 +1268,47 @@ function generatePreactJsxFactory(ctx) {
1266
1268
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1267
1269
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1268
1270
 
1269
- function styledFn(Dynamic, configOrCva = {}) {
1271
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1272
+
1273
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1270
1274
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1271
1275
 
1276
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1277
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1278
+
1279
+ const defaultProps = Object.assign(
1280
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1281
+ options.defaultProps,
1282
+ )
1283
+
1272
1284
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1273
- const { as: Element = Dynamic, ...restProps } = props
1285
+ const { as: Element = Dynamic, children, ...restProps } = props
1286
+
1287
+ const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1274
1288
 
1275
- const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1276
- return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1277
- }, [restProps])
1289
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1290
+ return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1291
+ }, [combinedProps])
1278
1292
 
1279
1293
  function recipeClass() {
1280
1294
  const { css: cssStyles, ...propStyles } = styleProps
1281
1295
  const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1282
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.className, elementProps.class)
1296
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1283
1297
  }
1284
1298
 
1285
1299
  function cvaClass() {
1286
1300
  const { css: cssStyles, ...propStyles } = styleProps
1287
1301
  const cvaStyles = cvaFn.raw(variantProps)
1288
- return cx(css(cvaStyles, propStyles, cssStyles), elementProps.className, elementProps.class)
1302
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1289
1303
  }
1290
1304
 
1291
1305
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1292
1306
 
1293
1307
  return h(Element, {
1308
+ ...forwardedProps,
1294
1309
  ...elementProps,
1295
1310
  ...normalizeHTMLProps(htmlProps),
1311
+ children,
1296
1312
  ref,
1297
1313
  className: classes()
1298
1314
  })
@@ -1374,7 +1390,7 @@ function generatePreactJsxPattern(ctx) {
1374
1390
  // src/artifacts/preact-jsx/types.ts
1375
1391
  import { outdent as outdent16 } from "outdent";
1376
1392
  function generatePreactJsxTypes(ctx) {
1377
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1393
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1378
1394
  return {
1379
1395
  jsxFactory: outdent16`
1380
1396
  import type { ${upperName} } from '../types/jsx'
@@ -1396,18 +1412,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1396
1412
 
1397
1413
  interface RecipeFn = { __type: any }
1398
1414
 
1415
+ interface JsxFactoryOptions<TProps extends Dict> {
1416
+ dataAttr?: boolean
1417
+ defaultProps?: TProps
1418
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1419
+ }
1420
+
1421
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1422
+
1399
1423
  interface JsxFactory {
1400
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1401
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1424
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1425
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1402
1426
  T,
1403
1427
  RecipeSelection<P>
1404
1428
  >
1405
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1429
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1406
1430
  }
1407
1431
 
1408
1432
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1409
1433
 
1410
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1434
+ export type ${upperName} = JsxFactory & JsxElements
1411
1435
 
1412
1436
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1413
1437
  `
@@ -1468,7 +1492,7 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1468
1492
  // src/artifacts/preact-jsx/types.string-literal.ts
1469
1493
  import { outdent as outdent18 } from "outdent";
1470
1494
  function generatePreactJsxStringLiteralTypes(ctx) {
1471
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1495
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1472
1496
  return {
1473
1497
  jsxFactory: outdent18`
1474
1498
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1492,7 +1516,7 @@ interface JsxFactory {
1492
1516
 
1493
1517
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
1494
1518
 
1495
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1519
+ export type ${upperName} = JsxFactory & JsxElements
1496
1520
 
1497
1521
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
1498
1522
  `
@@ -1510,32 +1534,46 @@ function generateQwikJsxFactory(ctx) {
1510
1534
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1511
1535
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1512
1536
 
1513
- function styledFn(Dynamic, configOrCva = {}) {
1537
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1538
+
1539
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1514
1540
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1515
1541
 
1542
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1543
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1544
+
1545
+ const defaultProps = Object.assign(
1546
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1547
+ options.defaultProps,
1548
+ )
1549
+
1516
1550
  const ${componentName} = function ${componentName}(props) {
1517
- const { as: Element = Dynamic, ...restProps } = props
1551
+ const { as: Element = Dynamic, children, className, ...restProps } = props
1518
1552
 
1519
- const [variantProps, styleProps, htmlProps, elementProps] =
1520
- splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1553
+ const combinedProps = Object.assign({}, defaultProps, restProps)
1554
+
1555
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
1556
+ splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1521
1557
 
1522
1558
  const { css: cssStyles, ...propStyles } = styleProps
1523
1559
 
1524
1560
  function recipeClass() {
1525
1561
  const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1526
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.class)
1562
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1527
1563
  }
1528
1564
 
1529
1565
  function cvaClass() {
1530
1566
  const cvaStyles = cvaFn.raw(variantProps)
1531
- return cx(css(cvaStyles, propStyles, cssStyles), elementProps.class)
1567
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
1532
1568
  }
1533
1569
 
1534
1570
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1535
1571
 
1536
1572
  return h(Element, {
1573
+ ...forwardedProps,
1537
1574
  ...elementProps,
1538
1575
  ...normalizeHTMLProps(htmlProps),
1576
+ children,
1539
1577
  class: classes(),
1540
1578
  })
1541
1579
  }
@@ -1616,7 +1654,7 @@ function generateQwikJsxPattern(ctx) {
1616
1654
  // src/artifacts/qwik-jsx/types.ts
1617
1655
  import { outdent as outdent21 } from "outdent";
1618
1656
  function generateQwikJsxTypes(ctx) {
1619
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1657
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1620
1658
  return {
1621
1659
  jsxFactory: outdent21`
1622
1660
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1641,18 +1679,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> ex
1641
1679
 
1642
1680
  interface RecipeFn { __type: any }
1643
1681
 
1682
+ interface JsxFactoryOptions<TProps extends Dict> {
1683
+ dataAttr?: boolean
1684
+ defaultProps?: TProps
1685
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1686
+ }
1687
+
1688
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1689
+
1644
1690
  interface JsxFactory {
1645
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1646
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1691
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1692
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1647
1693
  T,
1648
1694
  RecipeSelection<P>
1649
1695
  >
1650
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1696
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1651
1697
  }
1652
1698
 
1653
1699
  type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
1654
1700
 
1655
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1701
+ export type ${upperName} = JsxFactory & JsxElements
1656
1702
 
1657
1703
  export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
1658
1704
  `
@@ -1712,7 +1758,7 @@ function generateQwikJsxStringLiteralFactory(ctx) {
1712
1758
  // src/artifacts/qwik-jsx/types.string-literal.ts
1713
1759
  import { outdent as outdent23 } from "outdent";
1714
1760
  function generateQwikJsxStringLiteralTypes(ctx) {
1715
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1761
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1716
1762
  return {
1717
1763
  jsxFactory: outdent23`
1718
1764
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1741,7 +1787,7 @@ interface JsxFactory {
1741
1787
 
1742
1788
  type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
1743
1789
 
1744
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1790
+ export type ${upperName} = JsxFactory & JsxElements
1745
1791
 
1746
1792
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
1747
1793
  `
@@ -1750,7 +1796,6 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1750
1796
 
1751
1797
  // src/artifacts/react-jsx/jsx.ts
1752
1798
  import { outdent as outdent24 } from "outdent";
1753
- import { match as match6 } from "ts-pattern";
1754
1799
  function generateReactJsxFactory(ctx) {
1755
1800
  const { factoryName, componentName } = ctx.jsx;
1756
1801
  return {
@@ -1758,70 +1803,50 @@ function generateReactJsxFactory(ctx) {
1758
1803
  import { createElement, forwardRef, useMemo } from 'react'
1759
1804
  ${ctx.file.import("css, cx, cva", "../css/index")}
1760
1805
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1761
- ${ctx.jsx.styleProps === "all" ? ctx.file.import("isCssProperty", "./is-valid-prop") : ""}
1806
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1762
1807
 
1763
- function styledFn(Dynamic, configOrCva = {}) {
1808
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1809
+
1810
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1764
1811
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1765
1812
 
1766
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1767
- const { as: Element = Dynamic, ...restProps } = props
1768
-
1769
- ${match6(ctx.jsx.styleProps).with("all", () => {
1770
- return outdent24`
1771
- const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1772
- return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1773
- }, [restProps])
1813
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1814
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1815
+
1816
+ const defaultProps = Object.assign(
1817
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1818
+ options.defaultProps,
1819
+ )
1774
1820
 
1775
- function recipeClass() {
1776
- const { css: cssStyles, ...propStyles } = styleProps
1777
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1778
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.className)
1779
- }
1821
+ const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1822
+ const { as: Element = Dynamic, children, ...restProps } = props
1780
1823
 
1781
- function cvaClass() {
1782
- const { css: cssStyles, ...propStyles } = styleProps
1783
- const cvaStyles = cvaFn.raw(variantProps)
1784
- return cx(css(cvaStyles, propStyles, cssStyles), elementProps.className)
1785
- }`;
1786
- }).with("minimal", () => {
1787
- return outdent24`
1788
- const [variantProps, htmlProps, elementProps] = useMemo(() => {
1789
- return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
1790
- }, [restProps])
1791
-
1792
- function recipeClass() {
1793
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1794
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, elementProps.css), elementProps.className)
1795
- }
1824
+ const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1796
1825
 
1797
- function cvaClass() {
1798
- const cvaStyles = cvaFn.raw(variantProps)
1799
- return cx(css(cvaStyles, elementProps.css), elementProps.className)
1800
- }`;
1801
- }).with("none", () => {
1802
- return outdent24`
1803
- const [variantProps, htmlProps, elementProps] = useMemo(() => {
1804
- return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
1805
- }, [restProps])
1806
-
1807
- function recipeClass() {
1808
- const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1809
- return cx(cvaFn(variantProps, false), elementProps.className)
1810
- }
1826
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1827
+ return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1828
+ }, [combinedProps])
1811
1829
 
1812
- function cvaClass() {
1813
- const cvaStyles = cvaFn.raw(variantProps)
1814
- return cx(css(cvaStyles), elementProps.className)
1815
- }`;
1816
- }).run()}
1830
+ function recipeClass() {
1831
+ const { css: cssStyles, ...propStyles } = styleProps
1832
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1833
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
1834
+ }
1817
1835
 
1836
+ function cvaClass() {
1837
+ const { css: cssStyles, ...propStyles } = styleProps
1838
+ const cvaStyles = cvaFn.raw(variantProps)
1839
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
1840
+ }
1818
1841
 
1819
1842
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1820
1843
 
1821
1844
  return createElement(Element, {
1822
1845
  ref,
1846
+ ...forwardedProps,
1823
1847
  ...elementProps,
1824
1848
  ...normalizeHTMLProps(htmlProps),
1849
+ children,
1825
1850
  className: classes(),
1826
1851
  })
1827
1852
  })
@@ -1855,7 +1880,7 @@ function generateReactJsxFactory(ctx) {
1855
1880
 
1856
1881
  // src/artifacts/react-jsx/pattern.ts
1857
1882
  import { outdent as outdent25 } from "outdent";
1858
- import { match as match7 } from "ts-pattern";
1883
+ import { match as match6 } from "ts-pattern";
1859
1884
  function generateReactJsxPattern(ctx) {
1860
1885
  const { typeName, factoryName } = ctx.jsx;
1861
1886
  return ctx.patterns.details.map((pattern) => {
@@ -1869,7 +1894,7 @@ function generateReactJsxPattern(ctx) {
1869
1894
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1870
1895
 
1871
1896
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1872
- ${match7(props.length).with(
1897
+ ${match6(props.length).with(
1873
1898
  0,
1874
1899
  () => outdent25`
1875
1900
  const styleProps = ${styleFnName}()
@@ -1902,7 +1927,7 @@ function generateReactJsxPattern(ctx) {
1902
1927
  // src/artifacts/react-jsx/types.ts
1903
1928
  import { outdent as outdent26 } from "outdent";
1904
1929
  function generateReactJsxTypes(ctx) {
1905
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1930
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1906
1931
  return {
1907
1932
  jsxFactory: outdent26`
1908
1933
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1926,18 +1951,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1926
1951
 
1927
1952
  interface RecipeFn { __type: any }
1928
1953
 
1954
+ interface JsxFactoryOptions<TProps extends Dict> {
1955
+ dataAttr?: boolean
1956
+ defaultProps?: TProps
1957
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1958
+ }
1959
+
1960
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1961
+
1929
1962
  interface JsxFactory {
1930
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1931
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1963
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1964
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1932
1965
  T,
1933
1966
  RecipeSelection<P>
1934
1967
  >
1935
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1968
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1936
1969
  }
1937
1970
 
1938
1971
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1939
1972
 
1940
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1973
+ export type ${upperName} = JsxFactory & JsxElements
1941
1974
 
1942
1975
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1943
1976
  `
@@ -1998,7 +2031,7 @@ function generateReactJsxStringLiteralFactory(ctx) {
1998
2031
  // src/artifacts/react-jsx/types.string-literal.ts
1999
2032
  import { outdent as outdent28 } from "outdent";
2000
2033
  function generateReactJsxStringLiteralTypes(ctx) {
2001
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2034
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2002
2035
  return {
2003
2036
  jsxFactory: outdent28`
2004
2037
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2025,7 +2058,7 @@ interface JsxFactory {
2025
2058
 
2026
2059
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2027
2060
 
2028
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2061
+ export type ${upperName} = JsxFactory & JsxElements
2029
2062
 
2030
2063
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2031
2064
  `
@@ -2039,21 +2072,33 @@ function generateSolidJsxFactory(ctx) {
2039
2072
  return {
2040
2073
  js: outdent29`
2041
2074
  import { Dynamic } from 'solid-js/web'
2042
- import { mergeProps, splitProps } from 'solid-js'
2075
+ import { createMemo, mergeProps, splitProps } from 'solid-js'
2043
2076
  import { createComponent } from 'solid-js/web'
2044
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
2077
+ ${ctx.file.import("css, cx, cva", "../css/index")}
2045
2078
  ${ctx.file.import("normalizeHTMLProps", "../helpers")}
2046
- ${ctx.file.import("allCssProperties", "./is-valid-prop")}
2047
-
2048
- function styledFn(element, configOrCva = {}) {
2079
+ ${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
2080
+
2081
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2082
+
2083
+ function styledFn(element, configOrCva = {}, options = {}) {
2049
2084
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2050
2085
 
2086
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2087
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2088
+
2089
+ const defaultProps = Object.assign(
2090
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2091
+ options.defaultProps,
2092
+ )
2093
+
2051
2094
  return function ${componentName}(props) {
2052
- const mergedProps = mergeProps({ as: element }, props)
2095
+ const mergedProps = mergeProps({ as: element }, defaultProps, props)
2096
+ const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
2053
2097
 
2054
- const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2098
+ const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2055
2099
  mergedProps,
2056
- ['as', 'class'],
2100
+ ['as', 'class', 'className'],
2101
+ forwardedKeys(),
2057
2102
  cvaFn.variantKeys,
2058
2103
  allCssProperties,
2059
2104
  normalizeHTMLProps.keys
@@ -2061,20 +2106,28 @@ function generateSolidJsxFactory(ctx) {
2061
2106
 
2062
2107
  function recipeClass() {
2063
2108
  const { css: cssStyles, ...propStyles } = styleProps
2064
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class)
2109
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2110
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
2065
2111
  }
2066
2112
 
2067
2113
  function cvaClass() {
2068
2114
  const { css: cssStyles, ...propStyles } = styleProps
2069
2115
  const cvaStyles = cvaFn.raw(variantProps)
2070
- return cx(css(cvaStyles, propStyles, cssStyles), localProps.class)
2116
+ return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
2071
2117
  }
2072
2118
 
2073
2119
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
2074
2120
 
2121
+ if (forwardedProps.className) {
2122
+ delete forwardedProps.className
2123
+ }
2124
+
2075
2125
  return createComponent(
2076
2126
  Dynamic,
2077
2127
  mergeProps(
2128
+ forwardedProps,
2129
+ elementProps,
2130
+ normalizeHTMLProps(htmlProps),
2078
2131
  {
2079
2132
  get component() {
2080
2133
  return localProps.as
@@ -2083,8 +2136,6 @@ function generateSolidJsxFactory(ctx) {
2083
2136
  return classes()
2084
2137
  }
2085
2138
  },
2086
- elementProps,
2087
- normalizeHTMLProps(htmlProps)
2088
2139
  )
2089
2140
  )
2090
2141
  }
@@ -2113,7 +2164,7 @@ function generateSolidJsxFactory(ctx) {
2113
2164
 
2114
2165
  // src/artifacts/solid-jsx/pattern.ts
2115
2166
  import { outdent as outdent30 } from "outdent";
2116
- import { match as match8 } from "ts-pattern";
2167
+ import { match as match7 } from "ts-pattern";
2117
2168
  function generateSolidJsxPattern(ctx) {
2118
2169
  const { typeName, factoryName } = ctx.jsx;
2119
2170
  return ctx.patterns.details.map((pattern) => {
@@ -2128,7 +2179,7 @@ function generateSolidJsxPattern(ctx) {
2128
2179
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2129
2180
 
2130
2181
  export function ${jsxName}(props) {
2131
- ${match8(props.length).with(
2182
+ ${match7(props.length).with(
2132
2183
  0,
2133
2184
  () => outdent30`
2134
2185
  const styleProps = ${styleFnName}()
@@ -2161,7 +2212,7 @@ function generateSolidJsxPattern(ctx) {
2161
2212
  // src/artifacts/solid-jsx/types.ts
2162
2213
  import { outdent as outdent31 } from "outdent";
2163
2214
  function generateSolidJsxTypes(ctx) {
2164
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2215
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2165
2216
  return {
2166
2217
  jsxFactory: outdent31`
2167
2218
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2183,18 +2234,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2183
2234
 
2184
2235
  interface RecipeFn { __type: any }
2185
2236
 
2237
+ interface JsxFactoryOptions<TProps extends Dict> {
2238
+ dataAttr?: boolean
2239
+ defaultProps?: TProps
2240
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
2241
+ }
2242
+
2243
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
2244
+
2186
2245
  interface JsxFactory {
2187
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
2188
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
2246
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
2247
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2189
2248
  T,
2190
2249
  RecipeSelection<P>
2191
2250
  >
2192
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
2251
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2193
2252
  }
2194
2253
 
2195
2254
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2196
2255
 
2197
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2256
+ export type ${upperName} = JsxFactory & JsxElements
2198
2257
 
2199
2258
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2200
2259
  `
@@ -2260,7 +2319,7 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2260
2319
  // src/artifacts/solid-jsx/types.string-literal.ts
2261
2320
  import { outdent as outdent33 } from "outdent";
2262
2321
  function generateSolidJsxStringLiteralTypes(ctx) {
2263
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2322
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2264
2323
  return {
2265
2324
  jsxFactory: outdent33`
2266
2325
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2284,7 +2343,7 @@ interface JsxFactory {
2284
2343
 
2285
2344
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2286
2345
 
2287
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2346
+ export type ${upperName} = JsxFactory & JsxElements
2288
2347
 
2289
2348
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2290
2349
  `
@@ -2298,12 +2357,23 @@ function generateVueJsxFactory(ctx) {
2298
2357
  return {
2299
2358
  js: outdent34`
2300
2359
  import { defineComponent, h, computed } from 'vue'
2301
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
2360
+ ${ctx.file.import("css, cx, cva", "../css/index")}
2302
2361
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
2303
2362
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2304
2363
 
2305
- function styledFn(Dynamic, configOrCva = {}) {
2364
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2365
+
2366
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
2306
2367
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2368
+
2369
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2370
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2371
+
2372
+ const defaultProps = Object.assign(
2373
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2374
+ options.defaultProps,
2375
+ )
2376
+
2307
2377
  const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2308
2378
 
2309
2379
  return defineComponent({
@@ -2311,34 +2381,37 @@ function generateVueJsxFactory(ctx) {
2311
2381
  inheritAttrs: false,
2312
2382
  props: { as: { type: [String, Object], default: Dynamic } },
2313
2383
  setup(props, { slots, attrs }) {
2384
+ const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
2385
+
2314
2386
  const splittedProps = computed(() => {
2315
- return splitProps(attrs, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2387
+ return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2316
2388
  })
2317
2389
 
2318
2390
  const recipeClass = computed(() => {
2319
- const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
2391
+ const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2320
2392
  const { css: cssStyles, ...propStyles } = styleProps
2321
2393
  const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2322
- return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.className)
2394
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2323
2395
  })
2324
2396
 
2325
2397
  const cvaClass = computed(() => {
2326
- const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
2398
+ const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2327
2399
  const { css: cssStyles, ...propStyles } = styleProps
2328
- return cx(cvaFn(variantProps), css(propStyles, cssStyles), elementProps.className)
2400
+ const cvaStyles = cvaFn.raw(variantProps)
2401
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
2329
2402
  })
2330
2403
 
2331
2404
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
2332
2405
 
2333
2406
  return () => {
2334
- const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
2335
-
2407
+ const [forwardedProps, _variantProps, _styleProps, htmlProps, elementProps] = splittedProps.value
2336
2408
  return h(
2337
2409
  props.as,
2338
2410
  {
2339
- class: classes.value,
2411
+ ...forwardedProps.value,
2340
2412
  ...elementProps,
2341
2413
  ...normalizeHTMLProps(htmlProps),
2414
+ class: classes.value,
2342
2415
  },
2343
2416
  slots.default && slots.default(),
2344
2417
  )
@@ -2466,7 +2539,7 @@ function generateVueJsxPattern(ctx) {
2466
2539
  // src/artifacts/vue-jsx/types.ts
2467
2540
  import { outdent as outdent37 } from "outdent";
2468
2541
  function generateVueJsxTypes(ctx) {
2469
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2542
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2470
2543
  return {
2471
2544
  jsxFactory: outdent37`
2472
2545
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2494,18 +2567,26 @@ JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2494
2567
 
2495
2568
  interface RecipeFn = { __type: any }
2496
2569
 
2570
+ interface JsxFactoryOptions<TProps extends Dict> {
2571
+ dataAttr?: boolean
2572
+ defaultProps?: TProps
2573
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
2574
+ }
2575
+
2576
+ export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
2577
+
2497
2578
  interface JsxFactory {
2498
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
2499
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
2579
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
2580
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2500
2581
  T,
2501
2582
  RecipeSelection<P>
2502
2583
  >
2503
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
2584
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): ${componentName}<T, P['__type']>
2504
2585
  }
2505
2586
 
2506
2587
  type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
2507
2588
 
2508
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2589
+ export type ${upperName} = JsxFactory & JsxElements
2509
2590
 
2510
2591
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2511
2592
  `
@@ -2515,7 +2596,7 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
2515
2596
  // src/artifacts/vue-jsx/types.string-literal.ts
2516
2597
  import { outdent as outdent38 } from "outdent";
2517
2598
  function generateVueJsxStringLiteralTypes(ctx) {
2518
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2599
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2519
2600
  return {
2520
2601
  jsxFactory: outdent38`
2521
2602
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2543,7 +2624,7 @@ interface JsxFactory {
2543
2624
 
2544
2625
  type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
2545
2626
 
2546
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2627
+ export type ${upperName} = JsxFactory & JsxElements
2547
2628
 
2548
2629
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2549
2630
  `
@@ -2687,7 +2768,7 @@ var selectors_d_ts_default = {
2687
2768
  };
2688
2769
 
2689
2770
  // src/artifacts/types/generated.ts
2690
- import { match as match9 } from "ts-pattern";
2771
+ import { match as match8 } from "ts-pattern";
2691
2772
  var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
2692
2773
  function getGeneratedTypes(ctx) {
2693
2774
  const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
@@ -2699,7 +2780,7 @@ function getGeneratedTypes(ctx) {
2699
2780
  composition: rewriteImports(composition_d_ts_default.content),
2700
2781
  selectors: rewriteImports(selectors_d_ts_default.content),
2701
2782
  system: rewriteImports(
2702
- 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()
2783
+ 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()
2703
2784
  )
2704
2785
  };
2705
2786
  }
@@ -3147,7 +3228,7 @@ var generateFlattenedCss = (ctx) => (options) => {
3147
3228
  // src/artifacts/css/parser-css.ts
3148
3229
  import { logger } from "@pandacss/logger";
3149
3230
  import { pipe, tap, tryCatch } from "lil-fp/func";
3150
- import { P, match as match10 } from "ts-pattern";
3231
+ import { P, match as match9 } from "ts-pattern";
3151
3232
  var generateParserCss = (ctx) => (result) => pipe(
3152
3233
  { ...ctx, sheet: ctx.createSheet(), result },
3153
3234
  tap(({ sheet, result: result2, patterns, recipes }) => {
@@ -3177,7 +3258,7 @@ var generateParserCss = (ctx) => (result) => pipe(
3177
3258
  const recipeConfig = recipes.getConfig(recipeName);
3178
3259
  if (!recipeConfig)
3179
3260
  continue;
3180
- match10(recipe).with({ type: "jsx-recipe" }, () => {
3261
+ match9(recipe).with({ type: "jsx-recipe" }, () => {
3181
3262
  recipe.data.forEach((data) => {
3182
3263
  const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3183
3264
  sheet.processStyleProps(filterProps(ctx, styleProps));
@@ -3196,7 +3277,7 @@ var generateParserCss = (ctx) => (result) => pipe(
3196
3277
  result2.pattern.forEach((patternSet, name) => {
3197
3278
  try {
3198
3279
  for (const pattern of patternSet) {
3199
- match10(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3280
+ match9(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
3200
3281
  pattern.data.forEach((data) => {
3201
3282
  const fnName = patterns.find(jsxName);
3202
3283
  const styleProps = patterns.transform(fnName, data);