@pandacss/generator 0.15.2 → 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.
package/dist/index.js CHANGED
@@ -1054,7 +1054,15 @@ function generateRecipes(ctx) {
1054
1054
  ${ctx.file.import("compact, createCss, withoutSpace", "../helpers")}
1055
1055
 
1056
1056
  export const createRecipe = (name, defaultVariants, compoundVariants) => {
1057
- return (variants) => {
1057
+ const getRecipeStyles = (variants) => {
1058
+ return {
1059
+ [name]: '__ignore__',
1060
+ ...defaultVariants,
1061
+ ...compact(variants),
1062
+ };
1063
+ };
1064
+
1065
+ const recipeFn = (variants, withCompoundVariants = true) => {
1058
1066
  const transform = (prop, value) => {
1059
1067
  assertCompoundVariant(name, compoundVariants, variants, prop)
1060
1068
 
@@ -1074,16 +1082,21 @@ function generateRecipes(ctx) {
1074
1082
  }
1075
1083
  })
1076
1084
 
1077
- const recipeStyles = {
1078
- [name]: '__ignore__',
1079
- ...defaultVariants,
1080
- ...compact(variants),
1081
- }
1085
+ const recipeStyles = getRecipeStyles(variants)
1082
1086
 
1083
- const compoundVariantStyles = getCompoundVariantCss(compoundVariants, recipeStyles)
1087
+ if (withCompoundVariants) {
1088
+ const compoundVariantStyles = getCompoundVariantCss(compoundVariants, recipeStyles)
1089
+ return cx(recipeCss(recipeStyles), css(compoundVariantStyles))
1090
+ }
1084
1091
 
1085
- return cx(recipeCss(recipeStyles), css(compoundVariantStyles))
1092
+ return recipeCss(recipeStyles)
1086
1093
  }
1094
+
1095
+ return Object.assign(recipeFn, {
1096
+ __getCompoundVariantCss__: (variants) => {
1097
+ return getCompoundVariantCss(compoundVariants, getRecipeStyles(variants));
1098
+ },
1099
+ })
1087
1100
  }
1088
1101
  `
1089
1102
  };
@@ -1112,6 +1125,7 @@ function generateRecipes(ctx) {
1112
1125
 
1113
1126
  export const ${baseName} = Object.assign(${baseName}Fn, {
1114
1127
  __recipe__: false,
1128
+ __name__: '${baseName}',
1115
1129
  raw: (props) => props,
1116
1130
  variantKeys: ${baseName}VariantKeys,
1117
1131
  variantMap: ${stringify2(variantKeyMap)},
@@ -1133,6 +1147,7 @@ function generateRecipes(ctx) {
1133
1147
  const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
1134
1148
  export const ${baseName} = Object.assign(${baseName}Fn, {
1135
1149
  __recipe__: true,
1150
+ __name__: '${baseName}',
1136
1151
  raw: (props) => props,
1137
1152
  variantKeys: ${baseName}VariantKeys,
1138
1153
  variantMap: ${baseName}VariantMap,
@@ -1280,38 +1295,51 @@ function generatePreactJsxFactory(ctx) {
1280
1295
  import { h } from 'preact'
1281
1296
  import { forwardRef } from 'preact/compat'
1282
1297
  import { useMemo } from 'preact/hooks'
1283
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
1298
+ ${ctx.file.import("css, cx, cva", "../css/index")}
1284
1299
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1285
1300
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1286
1301
 
1287
- function styledFn(Dynamic, configOrCva = {}) {
1302
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1303
+
1304
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1288
1305
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1289
1306
 
1307
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1308
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1309
+
1310
+ const defaultProps = Object.assign(
1311
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1312
+ options.defaultProps,
1313
+ )
1314
+
1290
1315
  const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1291
- const { as: Element = Dynamic, ...restProps } = props
1316
+ const { as: Element = Dynamic, children, ...restProps } = props
1317
+
1318
+ const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1292
1319
 
1293
- const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1294
- return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1295
- }, [restProps])
1320
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1321
+ return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1322
+ }, [combinedProps])
1296
1323
 
1297
1324
  function recipeClass() {
1298
1325
  const { css: cssStyles, ...propStyles } = styleProps
1299
- const styles = assignCss(propStyles, cssStyles)
1300
- return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
1326
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1327
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1301
1328
  }
1302
1329
 
1303
1330
  function cvaClass() {
1304
1331
  const { css: cssStyles, ...propStyles } = styleProps
1305
1332
  const cvaStyles = cvaFn.raw(variantProps)
1306
- const styles = assignCss(cvaStyles, propStyles, cssStyles)
1307
- return cx(css(styles), elementProps.className, elementProps.class)
1333
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1308
1334
  }
1309
1335
 
1310
1336
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1311
1337
 
1312
1338
  return h(Element, {
1339
+ ...forwardedProps,
1313
1340
  ...elementProps,
1314
1341
  ...normalizeHTMLProps(htmlProps),
1342
+ children,
1315
1343
  ref,
1316
1344
  className: classes()
1317
1345
  })
@@ -1393,7 +1421,7 @@ function generatePreactJsxPattern(ctx) {
1393
1421
  // src/artifacts/preact-jsx/types.ts
1394
1422
  var import_outdent16 = require("outdent");
1395
1423
  function generatePreactJsxTypes(ctx) {
1396
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1424
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1397
1425
  return {
1398
1426
  jsxFactory: import_outdent16.outdent`
1399
1427
  import type { ${upperName} } from '../types/jsx'
@@ -1415,18 +1443,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1415
1443
 
1416
1444
  interface RecipeFn = { __type: any }
1417
1445
 
1446
+ interface JsxFactoryOptions<TProps extends Dict> {
1447
+ dataAttr?: boolean
1448
+ defaultProps?: TProps
1449
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1450
+ }
1451
+
1452
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1453
+
1418
1454
  interface JsxFactory {
1419
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1420
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1455
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1456
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1421
1457
  T,
1422
1458
  RecipeSelection<P>
1423
1459
  >
1424
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1460
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1425
1461
  }
1426
1462
 
1427
1463
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1428
1464
 
1429
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1465
+ export type ${upperName} = JsxFactory & JsxElements
1430
1466
 
1431
1467
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1432
1468
  `
@@ -1487,7 +1523,7 @@ function generatePreactJsxStringLiteralFactory(ctx) {
1487
1523
  // src/artifacts/preact-jsx/types.string-literal.ts
1488
1524
  var import_outdent18 = require("outdent");
1489
1525
  function generatePreactJsxStringLiteralTypes(ctx) {
1490
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1526
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1491
1527
  return {
1492
1528
  jsxFactory: import_outdent18.outdent`
1493
1529
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1511,7 +1547,7 @@ interface JsxFactory {
1511
1547
 
1512
1548
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
1513
1549
 
1514
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1550
+ export type ${upperName} = JsxFactory & JsxElements
1515
1551
 
1516
1552
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
1517
1553
  `
@@ -1525,37 +1561,50 @@ function generateQwikJsxFactory(ctx) {
1525
1561
  return {
1526
1562
  js: import_outdent19.outdent`
1527
1563
  import { h } from '@builder.io/qwik'
1528
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
1564
+ ${ctx.file.import("css, cx, cva", "../css/index")}
1529
1565
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1530
1566
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1531
1567
 
1532
- function styledFn(Dynamic, configOrCva = {}) {
1568
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1569
+
1570
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1533
1571
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1534
1572
 
1573
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1574
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1575
+
1576
+ const defaultProps = Object.assign(
1577
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1578
+ options.defaultProps,
1579
+ )
1580
+
1535
1581
  const ${componentName} = function ${componentName}(props) {
1536
- const { as: Element = Dynamic, ...restProps } = props
1582
+ const { as: Element = Dynamic, children, className, ...restProps } = props
1537
1583
 
1538
- const [variantProps, styleProps, htmlProps, elementProps] =
1539
- splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1584
+ const combinedProps = Object.assign({}, defaultProps, restProps)
1585
+
1586
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
1587
+ splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1540
1588
 
1541
1589
  const { css: cssStyles, ...propStyles } = styleProps
1542
1590
 
1543
1591
  function recipeClass() {
1544
- const styles = assignCss(propStyles, cssStyles)
1545
- return cx(cvaFn(variantProps), css(styles), elementProps.class)
1592
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1593
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1546
1594
  }
1547
1595
 
1548
1596
  function cvaClass() {
1549
1597
  const cvaStyles = cvaFn.raw(variantProps)
1550
- const styles = assignCss(cvaStyles, propStyles, cssStyles)
1551
- return cx(css(styles), elementProps.class)
1598
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
1552
1599
  }
1553
1600
 
1554
1601
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1555
1602
 
1556
1603
  return h(Element, {
1604
+ ...forwardedProps,
1557
1605
  ...elementProps,
1558
1606
  ...normalizeHTMLProps(htmlProps),
1607
+ children,
1559
1608
  class: classes(),
1560
1609
  })
1561
1610
  }
@@ -1636,7 +1685,7 @@ function generateQwikJsxPattern(ctx) {
1636
1685
  // src/artifacts/qwik-jsx/types.ts
1637
1686
  var import_outdent21 = require("outdent");
1638
1687
  function generateQwikJsxTypes(ctx) {
1639
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1688
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1640
1689
  return {
1641
1690
  jsxFactory: import_outdent21.outdent`
1642
1691
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1661,18 +1710,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> ex
1661
1710
 
1662
1711
  interface RecipeFn { __type: any }
1663
1712
 
1713
+ interface JsxFactoryOptions<TProps extends Dict> {
1714
+ dataAttr?: boolean
1715
+ defaultProps?: TProps
1716
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1717
+ }
1718
+
1719
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1720
+
1664
1721
  interface JsxFactory {
1665
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1666
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1722
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1723
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1667
1724
  T,
1668
1725
  RecipeSelection<P>
1669
1726
  >
1670
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1727
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1671
1728
  }
1672
1729
 
1673
1730
  type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
1674
1731
 
1675
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1732
+ export type ${upperName} = JsxFactory & JsxElements
1676
1733
 
1677
1734
  export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
1678
1735
  `
@@ -1732,7 +1789,7 @@ function generateQwikJsxStringLiteralFactory(ctx) {
1732
1789
  // src/artifacts/qwik-jsx/types.string-literal.ts
1733
1790
  var import_outdent23 = require("outdent");
1734
1791
  function generateQwikJsxStringLiteralTypes(ctx) {
1735
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1792
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1736
1793
  return {
1737
1794
  jsxFactory: import_outdent23.outdent`
1738
1795
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1761,7 +1818,7 @@ interface JsxFactory {
1761
1818
 
1762
1819
  type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
1763
1820
 
1764
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
1821
+ export type ${upperName} = JsxFactory & JsxElements
1765
1822
 
1766
1823
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
1767
1824
  `
@@ -1770,79 +1827,57 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
1770
1827
 
1771
1828
  // src/artifacts/react-jsx/jsx.ts
1772
1829
  var import_outdent24 = require("outdent");
1773
- var import_ts_pattern6 = require("ts-pattern");
1774
1830
  function generateReactJsxFactory(ctx) {
1775
1831
  const { factoryName, componentName } = ctx.jsx;
1776
1832
  return {
1777
1833
  js: import_outdent24.outdent`
1778
1834
  import { createElement, forwardRef, useMemo } from 'react'
1779
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
1835
+ ${ctx.file.import("css, cx, cva", "../css/index")}
1780
1836
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1781
- ${ctx.jsx.styleProps === "all" ? ctx.file.import("isCssProperty", "./is-valid-prop") : ""}
1837
+ ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1782
1838
 
1783
- function styledFn(Dynamic, configOrCva = {}) {
1839
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
1840
+
1841
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
1784
1842
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1785
1843
 
1786
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1787
- const { as: Element = Dynamic, ...restProps } = props
1788
-
1789
- ${(0, import_ts_pattern6.match)(ctx.jsx.styleProps).with("all", () => {
1790
- return import_outdent24.outdent`
1791
- const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1792
- return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1793
- }, [restProps])
1844
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1845
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
1846
+
1847
+ const defaultProps = Object.assign(
1848
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1849
+ options.defaultProps,
1850
+ )
1794
1851
 
1795
- function recipeClass() {
1796
- const { css: cssStyles, ...propStyles } = styleProps
1797
- const styles = assignCss(propStyles, cssStyles)
1798
- return cx(cvaFn(variantProps), css(styles), elementProps.className)
1799
- }
1852
+ const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1853
+ const { as: Element = Dynamic, children, ...restProps } = props
1800
1854
 
1801
- function cvaClass() {
1802
- const { css: cssStyles, ...propStyles } = styleProps
1803
- const cvaStyles = cvaFn.raw(variantProps)
1804
- const styles = assignCss(cvaStyles, propStyles, cssStyles)
1805
- return cx(css(styles), elementProps.className)
1806
- }`;
1807
- }).with("minimal", () => {
1808
- return import_outdent24.outdent`
1809
- const [variantProps, htmlProps, elementProps] = useMemo(() => {
1810
- return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
1811
- }, [restProps])
1812
-
1813
- function recipeClass() {
1814
- return cx(cvaFn(variantProps), css(assignCss(elementProps.css)), elementProps.className)
1815
- }
1855
+ const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
1816
1856
 
1817
- function cvaClass() {
1818
- const cvaStyles = cvaFn.raw(variantProps)
1819
- const styles = assignCss(cvaStyles, elementProps.css)
1820
- return cx(css(styles), elementProps.className)
1821
- }`;
1822
- }).with("none", () => {
1823
- return import_outdent24.outdent`
1824
- const [variantProps, htmlProps, elementProps] = useMemo(() => {
1825
- return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
1826
- }, [restProps])
1827
-
1828
- function recipeClass() {
1829
- return cx(cvaFn(variantProps), elementProps.className)
1830
- }
1857
+ const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
1858
+ return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
1859
+ }, [combinedProps])
1831
1860
 
1832
- function cvaClass() {
1833
- const cvaStyles = cvaFn.raw(variantProps)
1834
- const styles = assignCss(cvaStyles)
1835
- return cx(css(styles), elementProps.className)
1836
- }`;
1837
- }).run()}
1861
+ function recipeClass() {
1862
+ const { css: cssStyles, ...propStyles } = styleProps
1863
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
1864
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
1865
+ }
1838
1866
 
1867
+ function cvaClass() {
1868
+ const { css: cssStyles, ...propStyles } = styleProps
1869
+ const cvaStyles = cvaFn.raw(variantProps)
1870
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
1871
+ }
1839
1872
 
1840
1873
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
1841
1874
 
1842
1875
  return createElement(Element, {
1843
1876
  ref,
1877
+ ...forwardedProps,
1844
1878
  ...elementProps,
1845
1879
  ...normalizeHTMLProps(htmlProps),
1880
+ children,
1846
1881
  className: classes(),
1847
1882
  })
1848
1883
  })
@@ -1876,7 +1911,7 @@ function generateReactJsxFactory(ctx) {
1876
1911
 
1877
1912
  // src/artifacts/react-jsx/pattern.ts
1878
1913
  var import_outdent25 = require("outdent");
1879
- var import_ts_pattern7 = require("ts-pattern");
1914
+ var import_ts_pattern6 = require("ts-pattern");
1880
1915
  function generateReactJsxPattern(ctx) {
1881
1916
  const { typeName, factoryName } = ctx.jsx;
1882
1917
  return ctx.patterns.details.map((pattern) => {
@@ -1890,7 +1925,7 @@ function generateReactJsxPattern(ctx) {
1890
1925
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1891
1926
 
1892
1927
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1893
- ${(0, import_ts_pattern7.match)(props.length).with(
1928
+ ${(0, import_ts_pattern6.match)(props.length).with(
1894
1929
  0,
1895
1930
  () => import_outdent25.outdent`
1896
1931
  const styleProps = ${styleFnName}()
@@ -1923,7 +1958,7 @@ function generateReactJsxPattern(ctx) {
1923
1958
  // src/artifacts/react-jsx/types.ts
1924
1959
  var import_outdent26 = require("outdent");
1925
1960
  function generateReactJsxTypes(ctx) {
1926
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
1961
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1927
1962
  return {
1928
1963
  jsxFactory: import_outdent26.outdent`
1929
1964
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -1947,18 +1982,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1947
1982
 
1948
1983
  interface RecipeFn { __type: any }
1949
1984
 
1985
+ interface JsxFactoryOptions<TProps extends Dict> {
1986
+ dataAttr?: boolean
1987
+ defaultProps?: TProps
1988
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
1989
+ }
1990
+
1991
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
1992
+
1950
1993
  interface JsxFactory {
1951
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
1952
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
1994
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
1995
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
1953
1996
  T,
1954
1997
  RecipeSelection<P>
1955
1998
  >
1956
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
1999
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
1957
2000
  }
1958
2001
 
1959
2002
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
1960
2003
 
1961
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2004
+ export type ${upperName} = JsxFactory & JsxElements
1962
2005
 
1963
2006
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
1964
2007
  `
@@ -2019,7 +2062,7 @@ function generateReactJsxStringLiteralFactory(ctx) {
2019
2062
  // src/artifacts/react-jsx/types.string-literal.ts
2020
2063
  var import_outdent28 = require("outdent");
2021
2064
  function generateReactJsxStringLiteralTypes(ctx) {
2022
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2065
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2023
2066
  return {
2024
2067
  jsxFactory: import_outdent28.outdent`
2025
2068
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2046,7 +2089,7 @@ interface JsxFactory {
2046
2089
 
2047
2090
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2048
2091
 
2049
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2092
+ export type ${upperName} = JsxFactory & JsxElements
2050
2093
 
2051
2094
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2052
2095
  `
@@ -2060,21 +2103,33 @@ function generateSolidJsxFactory(ctx) {
2060
2103
  return {
2061
2104
  js: import_outdent29.outdent`
2062
2105
  import { Dynamic } from 'solid-js/web'
2063
- import { mergeProps, splitProps } from 'solid-js'
2106
+ import { createMemo, mergeProps, splitProps } from 'solid-js'
2064
2107
  import { createComponent } from 'solid-js/web'
2065
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
2108
+ ${ctx.file.import("css, cx, cva", "../css/index")}
2066
2109
  ${ctx.file.import("normalizeHTMLProps", "../helpers")}
2067
- ${ctx.file.import("allCssProperties", "./is-valid-prop")}
2068
-
2069
- function styledFn(element, configOrCva = {}) {
2110
+ ${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
2111
+
2112
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2113
+
2114
+ function styledFn(element, configOrCva = {}, options = {}) {
2070
2115
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2071
2116
 
2117
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2118
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2119
+
2120
+ const defaultProps = Object.assign(
2121
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2122
+ options.defaultProps,
2123
+ )
2124
+
2072
2125
  return function ${componentName}(props) {
2073
- const mergedProps = mergeProps({ as: element }, props)
2126
+ const mergedProps = mergeProps({ as: element }, defaultProps, props)
2127
+ const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
2074
2128
 
2075
- const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2129
+ const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
2076
2130
  mergedProps,
2077
- ['as', 'class'],
2131
+ ['as', 'class', 'className'],
2132
+ forwardedKeys(),
2078
2133
  cvaFn.variantKeys,
2079
2134
  allCssProperties,
2080
2135
  normalizeHTMLProps.keys
@@ -2082,22 +2137,28 @@ function generateSolidJsxFactory(ctx) {
2082
2137
 
2083
2138
  function recipeClass() {
2084
2139
  const { css: cssStyles, ...propStyles } = styleProps
2085
- const styles = assignCss(propStyles, cssStyles)
2086
- return cx(cvaFn(variantProps), css(styles), localProps.class)
2140
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2141
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
2087
2142
  }
2088
2143
 
2089
2144
  function cvaClass() {
2090
2145
  const { css: cssStyles, ...propStyles } = styleProps
2091
2146
  const cvaStyles = cvaFn.raw(variantProps)
2092
- const styles = assignCss(cvaStyles, propStyles, cssStyles)
2093
- return cx(css(styles), localProps.class)
2147
+ return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
2094
2148
  }
2095
2149
 
2096
2150
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
2097
2151
 
2152
+ if (forwardedProps.className) {
2153
+ delete forwardedProps.className
2154
+ }
2155
+
2098
2156
  return createComponent(
2099
2157
  Dynamic,
2100
2158
  mergeProps(
2159
+ forwardedProps,
2160
+ elementProps,
2161
+ normalizeHTMLProps(htmlProps),
2101
2162
  {
2102
2163
  get component() {
2103
2164
  return localProps.as
@@ -2106,8 +2167,6 @@ function generateSolidJsxFactory(ctx) {
2106
2167
  return classes()
2107
2168
  }
2108
2169
  },
2109
- elementProps,
2110
- normalizeHTMLProps(htmlProps)
2111
2170
  )
2112
2171
  )
2113
2172
  }
@@ -2136,7 +2195,7 @@ function generateSolidJsxFactory(ctx) {
2136
2195
 
2137
2196
  // src/artifacts/solid-jsx/pattern.ts
2138
2197
  var import_outdent30 = require("outdent");
2139
- var import_ts_pattern8 = require("ts-pattern");
2198
+ var import_ts_pattern7 = require("ts-pattern");
2140
2199
  function generateSolidJsxPattern(ctx) {
2141
2200
  const { typeName, factoryName } = ctx.jsx;
2142
2201
  return ctx.patterns.details.map((pattern) => {
@@ -2151,7 +2210,7 @@ function generateSolidJsxPattern(ctx) {
2151
2210
  ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2152
2211
 
2153
2212
  export function ${jsxName}(props) {
2154
- ${(0, import_ts_pattern8.match)(props.length).with(
2213
+ ${(0, import_ts_pattern7.match)(props.length).with(
2155
2214
  0,
2156
2215
  () => import_outdent30.outdent`
2157
2216
  const styleProps = ${styleFnName}()
@@ -2184,7 +2243,7 @@ function generateSolidJsxPattern(ctx) {
2184
2243
  // src/artifacts/solid-jsx/types.ts
2185
2244
  var import_outdent31 = require("outdent");
2186
2245
  function generateSolidJsxTypes(ctx) {
2187
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2246
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2188
2247
  return {
2189
2248
  jsxFactory: import_outdent31.outdent`
2190
2249
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2206,18 +2265,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2206
2265
 
2207
2266
  interface RecipeFn { __type: any }
2208
2267
 
2268
+ interface JsxFactoryOptions<TProps extends Dict> {
2269
+ dataAttr?: boolean
2270
+ defaultProps?: TProps
2271
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
2272
+ }
2273
+
2274
+ export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
2275
+
2209
2276
  interface JsxFactory {
2210
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
2211
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
2277
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
2278
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2212
2279
  T,
2213
2280
  RecipeSelection<P>
2214
2281
  >
2215
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
2282
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
2216
2283
  }
2217
2284
 
2218
2285
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
2219
2286
 
2220
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2287
+ export type ${upperName} = JsxFactory & JsxElements
2221
2288
 
2222
2289
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2223
2290
  `
@@ -2283,7 +2350,7 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2283
2350
  // src/artifacts/solid-jsx/types.string-literal.ts
2284
2351
  var import_outdent33 = require("outdent");
2285
2352
  function generateSolidJsxStringLiteralTypes(ctx) {
2286
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2353
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2287
2354
  return {
2288
2355
  jsxFactory: import_outdent33.outdent`
2289
2356
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2307,7 +2374,7 @@ interface JsxFactory {
2307
2374
 
2308
2375
  type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
2309
2376
 
2310
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2377
+ export type ${upperName} = JsxFactory & JsxElements
2311
2378
 
2312
2379
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2313
2380
  `
@@ -2321,12 +2388,23 @@ function generateVueJsxFactory(ctx) {
2321
2388
  return {
2322
2389
  js: import_outdent34.outdent`
2323
2390
  import { defineComponent, h, computed } from 'vue'
2324
- ${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
2391
+ ${ctx.file.import("css, cx, cva", "../css/index")}
2325
2392
  ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
2326
2393
  ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2327
2394
 
2328
- function styledFn(Dynamic, configOrCva = {}) {
2395
+ const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
2396
+
2397
+ function styledFn(Dynamic, configOrCva = {}, options = {}) {
2329
2398
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2399
+
2400
+ const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2401
+ const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
2402
+
2403
+ const defaultProps = Object.assign(
2404
+ options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2405
+ options.defaultProps,
2406
+ )
2407
+
2330
2408
  const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
2331
2409
 
2332
2410
  return defineComponent({
@@ -2334,35 +2412,37 @@ function generateVueJsxFactory(ctx) {
2334
2412
  inheritAttrs: false,
2335
2413
  props: { as: { type: [String, Object], default: Dynamic } },
2336
2414
  setup(props, { slots, attrs }) {
2415
+ const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
2416
+
2337
2417
  const splittedProps = computed(() => {
2338
- return splitProps(attrs, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2418
+ return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
2339
2419
  })
2340
2420
 
2341
2421
  const recipeClass = computed(() => {
2342
- const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
2422
+ const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2343
2423
  const { css: cssStyles, ...propStyles } = styleProps
2344
- const styles = assignCss(propStyles, cssStyles)
2345
- return cx(cvaFn(variantProps), css(styles), elementProps.className)
2424
+ const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
2425
+ return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
2346
2426
  })
2347
2427
 
2348
2428
  const cvaClass = computed(() => {
2349
- const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
2429
+ const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
2350
2430
  const { css: cssStyles, ...propStyles } = styleProps
2351
- const styles = assignCss(propStyles, cssStyles)
2352
- return cx(cvaFn(variantProps), css(styles), elementProps.className)
2431
+ const cvaStyles = cvaFn.raw(variantProps)
2432
+ return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
2353
2433
  })
2354
2434
 
2355
2435
  const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
2356
2436
 
2357
2437
  return () => {
2358
- const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
2359
-
2438
+ const [forwardedProps, _variantProps, _styleProps, htmlProps, elementProps] = splittedProps.value
2360
2439
  return h(
2361
2440
  props.as,
2362
2441
  {
2363
- class: classes.value,
2442
+ ...forwardedProps.value,
2364
2443
  ...elementProps,
2365
2444
  ...normalizeHTMLProps(htmlProps),
2445
+ class: classes.value,
2366
2446
  },
2367
2447
  slots.default && slots.default(),
2368
2448
  )
@@ -2372,17 +2452,12 @@ function generateVueJsxFactory(ctx) {
2372
2452
  }
2373
2453
 
2374
2454
  function createJsxFactory() {
2375
- const cache = new Map()
2376
-
2377
2455
  return new Proxy(styledFn, {
2378
2456
  apply(_, __, args) {
2379
2457
  return styledFn(...args)
2380
2458
  },
2381
2459
  get(_, el) {
2382
- if (!cache.has(el)) {
2383
- cache.set(el, styledFn(el))
2384
- }
2385
- return cache.get(el)
2460
+ return styledFn(el)
2386
2461
  },
2387
2462
  })
2388
2463
  }
@@ -2495,7 +2570,7 @@ function generateVueJsxPattern(ctx) {
2495
2570
  // src/artifacts/vue-jsx/types.ts
2496
2571
  var import_outdent37 = require("outdent");
2497
2572
  function generateVueJsxTypes(ctx) {
2498
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2573
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2499
2574
  return {
2500
2575
  jsxFactory: import_outdent37.outdent`
2501
2576
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2523,18 +2598,26 @@ JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
2523
2598
 
2524
2599
  interface RecipeFn = { __type: any }
2525
2600
 
2601
+ interface JsxFactoryOptions<TProps extends Dict> {
2602
+ dataAttr?: boolean
2603
+ defaultProps?: TProps
2604
+ shouldForwardProp?(prop: string, variantKeys: string[]): boolean
2605
+ }
2606
+
2607
+ export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
2608
+
2526
2609
  interface JsxFactory {
2527
- ${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
2528
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
2610
+ <T extends ElementType>(component: T): ${componentName}<T, {}>
2611
+ <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
2529
2612
  T,
2530
2613
  RecipeSelection<P>
2531
2614
  >
2532
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
2615
+ <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): ${componentName}<T, P['__type']>
2533
2616
  }
2534
2617
 
2535
2618
  type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
2536
2619
 
2537
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2620
+ export type ${upperName} = JsxFactory & JsxElements
2538
2621
 
2539
2622
  export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
2540
2623
  `
@@ -2544,7 +2627,7 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
2544
2627
  // src/artifacts/vue-jsx/types.string-literal.ts
2545
2628
  var import_outdent38 = require("outdent");
2546
2629
  function generateVueJsxStringLiteralTypes(ctx) {
2547
- const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
2630
+ const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2548
2631
  return {
2549
2632
  jsxFactory: import_outdent38.outdent`
2550
2633
  ${ctx.file.importType(upperName, "../types/jsx")}
@@ -2572,7 +2655,7 @@ interface JsxFactory {
2572
2655
 
2573
2656
  type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
2574
2657
 
2575
- export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
2658
+ export type ${upperName} = JsxFactory & JsxElements
2576
2659
 
2577
2660
  export type ${typeName}<T extends ElementType> = ComponentProps<T>
2578
2661
  `
@@ -2697,7 +2780,7 @@ var composition_d_ts_default = {
2697
2780
 
2698
2781
  // src/artifacts/generated/recipe.d.ts.json
2699
2782
  var recipe_d_ts_default = {
2700
- content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | RecipeVariantRecord\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>,\n RecipeConfigMeta {}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>>\n extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | SlotRecipeVariantRecord<S>\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<SlotRecipeCompoundVariant<S, T>>\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
2783
+ content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>,\n RecipeConfigMeta {}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>>\n extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
2701
2784
  };
2702
2785
 
2703
2786
  // src/artifacts/generated/pattern.d.ts.json
@@ -2716,7 +2799,7 @@ var selectors_d_ts_default = {
2716
2799
  };
2717
2800
 
2718
2801
  // src/artifacts/types/generated.ts
2719
- var import_ts_pattern9 = require("ts-pattern");
2802
+ var import_ts_pattern8 = require("ts-pattern");
2720
2803
  var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
2721
2804
  function getGeneratedTypes(ctx) {
2722
2805
  const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
@@ -2728,7 +2811,7 @@ function getGeneratedTypes(ctx) {
2728
2811
  composition: rewriteImports(composition_d_ts_default.content),
2729
2812
  selectors: rewriteImports(selectors_d_ts_default.content),
2730
2813
  system: rewriteImports(
2731
- (0, import_ts_pattern9.match)(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()
2814
+ (0, import_ts_pattern8.match)(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()
2732
2815
  )
2733
2816
  };
2734
2817
  }
@@ -3176,7 +3259,7 @@ var generateFlattenedCss = (ctx) => (options) => {
3176
3259
  // src/artifacts/css/parser-css.ts
3177
3260
  var import_logger2 = require("@pandacss/logger");
3178
3261
  var import_func = require("lil-fp/func");
3179
- var import_ts_pattern10 = require("ts-pattern");
3262
+ var import_ts_pattern9 = require("ts-pattern");
3180
3263
  var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
3181
3264
  { ...ctx, sheet: ctx.createSheet(), result },
3182
3265
  (0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
@@ -3206,7 +3289,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
3206
3289
  const recipeConfig = recipes.getConfig(recipeName);
3207
3290
  if (!recipeConfig)
3208
3291
  continue;
3209
- (0, import_ts_pattern10.match)(recipe).with({ type: "jsx-recipe" }, () => {
3292
+ (0, import_ts_pattern9.match)(recipe).with({ type: "jsx-recipe" }, () => {
3210
3293
  recipe.data.forEach((data) => {
3211
3294
  const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
3212
3295
  sheet.processStyleProps(filterProps(ctx, styleProps));
@@ -3225,7 +3308,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
3225
3308
  result2.pattern.forEach((patternSet, name) => {
3226
3309
  try {
3227
3310
  for (const pattern of patternSet) {
3228
- (0, import_ts_pattern10.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern10.P.string }, ({ name: jsxName }) => {
3311
+ (0, import_ts_pattern9.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern9.P.string }, ({ name: jsxName }) => {
3229
3312
  pattern.data.forEach((data) => {
3230
3313
  const fnName = patterns.find(jsxName);
3231
3314
  const styleProps = patterns.transform(fnName, data);
@@ -3430,6 +3513,7 @@ var getPatternEngine = (config) => {
3430
3513
  };
3431
3514
  });
3432
3515
  return {
3516
+ keys: Object.keys(patterns),
3433
3517
  getConfig: (name) => patterns[name],
3434
3518
  transform: (name, data) => {
3435
3519
  return patterns[name]?.transform?.(data, helpers2) ?? {};
@@ -3509,11 +3593,11 @@ var defaults = (conf) => ({
3509
3593
  }
3510
3594
  }
3511
3595
  });
3512
- var getImportMap = (outdir) => ({
3513
- css: [outdir, "css"],
3514
- recipe: [outdir, "recipes"],
3515
- pattern: [outdir, "patterns"],
3516
- jsx: [outdir, "jsx"]
3596
+ var getImportMap = (outdir, configImportMap) => ({
3597
+ css: configImportMap?.css ? [configImportMap.css] : [outdir, "css"],
3598
+ recipe: configImportMap?.recipes ? [configImportMap.recipes] : [outdir, "recipes"],
3599
+ pattern: configImportMap?.patterns ? [configImportMap.patterns] : [outdir, "patterns"],
3600
+ jsx: configImportMap?.jsx ? [configImportMap.jsx] : [outdir, "jsx"]
3517
3601
  });
3518
3602
  var createGenerator = (conf) => {
3519
3603
  const ctx = getEngine(defaults(conf));
@@ -3529,13 +3613,16 @@ var createGenerator = (conf) => {
3529
3613
  getParserCss: generateParserCss(ctx),
3530
3614
  messages: getMessages(ctx),
3531
3615
  parserOptions: {
3532
- importMap: getImportMap(config.outdir.replace(relativeBaseUrl, "")),
3616
+ importMap: getImportMap(config.outdir.replace(relativeBaseUrl, ""), config.importMap),
3533
3617
  jsx: {
3618
+ framework: jsx.framework,
3534
3619
  factory: jsx.factoryName,
3535
3620
  styleProps: jsx.styleProps,
3536
3621
  isStyleProp: isValidProperty,
3537
3622
  nodes: [...patterns.details, ...recipes.details]
3538
3623
  },
3624
+ patternKeys: patterns.keys,
3625
+ recipeKeys: recipes.keys,
3539
3626
  getRecipesByJsxName: recipes.filter,
3540
3627
  getPatternsByJsxName: patterns.filter,
3541
3628
  compilerOptions,