@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.
- package/dist/index.js +210 -129
- package/dist/index.mjs +210 -129
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1125,6 +1125,7 @@ function generateRecipes(ctx) {
|
|
|
1125
1125
|
|
|
1126
1126
|
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1127
1127
|
__recipe__: false,
|
|
1128
|
+
__name__: '${baseName}',
|
|
1128
1129
|
raw: (props) => props,
|
|
1129
1130
|
variantKeys: ${baseName}VariantKeys,
|
|
1130
1131
|
variantMap: ${stringify2(variantKeyMap)},
|
|
@@ -1146,6 +1147,7 @@ function generateRecipes(ctx) {
|
|
|
1146
1147
|
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1147
1148
|
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1148
1149
|
__recipe__: true,
|
|
1150
|
+
__name__: '${baseName}',
|
|
1149
1151
|
raw: (props) => props,
|
|
1150
1152
|
variantKeys: ${baseName}VariantKeys,
|
|
1151
1153
|
variantMap: ${baseName}VariantMap,
|
|
@@ -1297,33 +1299,47 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1297
1299
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1298
1300
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1299
1301
|
|
|
1300
|
-
|
|
1302
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1303
|
+
|
|
1304
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1301
1305
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1302
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
|
+
|
|
1303
1315
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1304
|
-
const { as: Element = Dynamic, ...restProps } = props
|
|
1316
|
+
const { as: Element = Dynamic, children, ...restProps } = props
|
|
1317
|
+
|
|
1318
|
+
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1305
1319
|
|
|
1306
|
-
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1307
|
-
return splitProps(
|
|
1308
|
-
}, [
|
|
1320
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1321
|
+
return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1322
|
+
}, [combinedProps])
|
|
1309
1323
|
|
|
1310
1324
|
function recipeClass() {
|
|
1311
1325
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1312
1326
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1313
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
1327
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1314
1328
|
}
|
|
1315
1329
|
|
|
1316
1330
|
function cvaClass() {
|
|
1317
1331
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1318
1332
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
1319
|
-
return cx(css(cvaStyles, propStyles, cssStyles),
|
|
1333
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1320
1334
|
}
|
|
1321
1335
|
|
|
1322
1336
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1323
1337
|
|
|
1324
1338
|
return h(Element, {
|
|
1339
|
+
...forwardedProps,
|
|
1325
1340
|
...elementProps,
|
|
1326
1341
|
...normalizeHTMLProps(htmlProps),
|
|
1342
|
+
children,
|
|
1327
1343
|
ref,
|
|
1328
1344
|
className: classes()
|
|
1329
1345
|
})
|
|
@@ -1405,7 +1421,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1405
1421
|
// src/artifacts/preact-jsx/types.ts
|
|
1406
1422
|
var import_outdent16 = require("outdent");
|
|
1407
1423
|
function generatePreactJsxTypes(ctx) {
|
|
1408
|
-
const { factoryName,
|
|
1424
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1409
1425
|
return {
|
|
1410
1426
|
jsxFactory: import_outdent16.outdent`
|
|
1411
1427
|
import type { ${upperName} } from '../types/jsx'
|
|
@@ -1427,18 +1443,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1427
1443
|
|
|
1428
1444
|
interface RecipeFn = { __type: any }
|
|
1429
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
|
+
|
|
1430
1454
|
interface JsxFactory {
|
|
1431
|
-
|
|
1432
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
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}<
|
|
1433
1457
|
T,
|
|
1434
1458
|
RecipeSelection<P>
|
|
1435
1459
|
>
|
|
1436
|
-
<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']>
|
|
1437
1461
|
}
|
|
1438
1462
|
|
|
1439
1463
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1440
1464
|
|
|
1441
|
-
export type ${upperName} = JsxFactory
|
|
1465
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1442
1466
|
|
|
1443
1467
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1444
1468
|
`
|
|
@@ -1499,7 +1523,7 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1499
1523
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1500
1524
|
var import_outdent18 = require("outdent");
|
|
1501
1525
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1502
|
-
const { factoryName,
|
|
1526
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1503
1527
|
return {
|
|
1504
1528
|
jsxFactory: import_outdent18.outdent`
|
|
1505
1529
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1523,7 +1547,7 @@ interface JsxFactory {
|
|
|
1523
1547
|
|
|
1524
1548
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1525
1549
|
|
|
1526
|
-
export type ${upperName} = JsxFactory
|
|
1550
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1527
1551
|
|
|
1528
1552
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1529
1553
|
`
|
|
@@ -1541,32 +1565,46 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1541
1565
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1542
1566
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1543
1567
|
|
|
1544
|
-
|
|
1568
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1569
|
+
|
|
1570
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1545
1571
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1546
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
|
+
|
|
1547
1581
|
const ${componentName} = function ${componentName}(props) {
|
|
1548
|
-
const { as: Element = Dynamic, ...restProps } = props
|
|
1582
|
+
const { as: Element = Dynamic, children, className, ...restProps } = props
|
|
1549
1583
|
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1584
|
+
const combinedProps = Object.assign({}, defaultProps, restProps)
|
|
1585
|
+
|
|
1586
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
|
|
1587
|
+
splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1552
1588
|
|
|
1553
1589
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1554
1590
|
|
|
1555
1591
|
function recipeClass() {
|
|
1556
1592
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1557
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
1593
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1558
1594
|
}
|
|
1559
1595
|
|
|
1560
1596
|
function cvaClass() {
|
|
1561
1597
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
1562
|
-
return cx(css(cvaStyles, propStyles, cssStyles),
|
|
1598
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1563
1599
|
}
|
|
1564
1600
|
|
|
1565
1601
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1566
1602
|
|
|
1567
1603
|
return h(Element, {
|
|
1604
|
+
...forwardedProps,
|
|
1568
1605
|
...elementProps,
|
|
1569
1606
|
...normalizeHTMLProps(htmlProps),
|
|
1607
|
+
children,
|
|
1570
1608
|
class: classes(),
|
|
1571
1609
|
})
|
|
1572
1610
|
}
|
|
@@ -1647,7 +1685,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1647
1685
|
// src/artifacts/qwik-jsx/types.ts
|
|
1648
1686
|
var import_outdent21 = require("outdent");
|
|
1649
1687
|
function generateQwikJsxTypes(ctx) {
|
|
1650
|
-
const { factoryName,
|
|
1688
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1651
1689
|
return {
|
|
1652
1690
|
jsxFactory: import_outdent21.outdent`
|
|
1653
1691
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1672,18 +1710,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> ex
|
|
|
1672
1710
|
|
|
1673
1711
|
interface RecipeFn { __type: any }
|
|
1674
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
|
+
|
|
1675
1721
|
interface JsxFactory {
|
|
1676
|
-
|
|
1677
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
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}<
|
|
1678
1724
|
T,
|
|
1679
1725
|
RecipeSelection<P>
|
|
1680
1726
|
>
|
|
1681
|
-
<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']>
|
|
1682
1728
|
}
|
|
1683
1729
|
|
|
1684
1730
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1685
1731
|
|
|
1686
|
-
export type ${upperName} = JsxFactory
|
|
1732
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1687
1733
|
|
|
1688
1734
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1689
1735
|
`
|
|
@@ -1743,7 +1789,7 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1743
1789
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1744
1790
|
var import_outdent23 = require("outdent");
|
|
1745
1791
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1746
|
-
const { factoryName,
|
|
1792
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1747
1793
|
return {
|
|
1748
1794
|
jsxFactory: import_outdent23.outdent`
|
|
1749
1795
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1772,7 +1818,7 @@ interface JsxFactory {
|
|
|
1772
1818
|
|
|
1773
1819
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1774
1820
|
|
|
1775
|
-
export type ${upperName} = JsxFactory
|
|
1821
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1776
1822
|
|
|
1777
1823
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1778
1824
|
`
|
|
@@ -1781,7 +1827,6 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1781
1827
|
|
|
1782
1828
|
// src/artifacts/react-jsx/jsx.ts
|
|
1783
1829
|
var import_outdent24 = require("outdent");
|
|
1784
|
-
var import_ts_pattern6 = require("ts-pattern");
|
|
1785
1830
|
function generateReactJsxFactory(ctx) {
|
|
1786
1831
|
const { factoryName, componentName } = ctx.jsx;
|
|
1787
1832
|
return {
|
|
@@ -1789,70 +1834,50 @@ function generateReactJsxFactory(ctx) {
|
|
|
1789
1834
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1790
1835
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1791
1836
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1792
|
-
${ctx.
|
|
1837
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1793
1838
|
|
|
1794
|
-
|
|
1839
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1840
|
+
|
|
1841
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1795
1842
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1796
1843
|
|
|
1797
|
-
const
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}, [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
|
+
)
|
|
1805
1851
|
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1809
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.className)
|
|
1810
|
-
}
|
|
1852
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1853
|
+
const { as: Element = Dynamic, children, ...restProps } = props
|
|
1811
1854
|
|
|
1812
|
-
|
|
1813
|
-
const { css: cssStyles, ...propStyles } = styleProps
|
|
1814
|
-
const cvaStyles = cvaFn.raw(variantProps)
|
|
1815
|
-
return cx(css(cvaStyles, propStyles, cssStyles), elementProps.className)
|
|
1816
|
-
}`;
|
|
1817
|
-
}).with("minimal", () => {
|
|
1818
|
-
return import_outdent24.outdent`
|
|
1819
|
-
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1820
|
-
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1821
|
-
}, [restProps])
|
|
1822
|
-
|
|
1823
|
-
function recipeClass() {
|
|
1824
|
-
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1825
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, elementProps.css), elementProps.className)
|
|
1826
|
-
}
|
|
1855
|
+
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1827
1856
|
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
}`;
|
|
1832
|
-
}).with("none", () => {
|
|
1833
|
-
return import_outdent24.outdent`
|
|
1834
|
-
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1835
|
-
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1836
|
-
}, [restProps])
|
|
1837
|
-
|
|
1838
|
-
function recipeClass() {
|
|
1839
|
-
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1840
|
-
return cx(cvaFn(variantProps, false), elementProps.className)
|
|
1841
|
-
}
|
|
1857
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1858
|
+
return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1859
|
+
}, [combinedProps])
|
|
1842
1860
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
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
|
+
}
|
|
1848
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
|
+
}
|
|
1849
1872
|
|
|
1850
1873
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1851
1874
|
|
|
1852
1875
|
return createElement(Element, {
|
|
1853
1876
|
ref,
|
|
1877
|
+
...forwardedProps,
|
|
1854
1878
|
...elementProps,
|
|
1855
1879
|
...normalizeHTMLProps(htmlProps),
|
|
1880
|
+
children,
|
|
1856
1881
|
className: classes(),
|
|
1857
1882
|
})
|
|
1858
1883
|
})
|
|
@@ -1886,7 +1911,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1886
1911
|
|
|
1887
1912
|
// src/artifacts/react-jsx/pattern.ts
|
|
1888
1913
|
var import_outdent25 = require("outdent");
|
|
1889
|
-
var
|
|
1914
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
1890
1915
|
function generateReactJsxPattern(ctx) {
|
|
1891
1916
|
const { typeName, factoryName } = ctx.jsx;
|
|
1892
1917
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1900,7 +1925,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1900
1925
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1901
1926
|
|
|
1902
1927
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1903
|
-
${(0,
|
|
1928
|
+
${(0, import_ts_pattern6.match)(props.length).with(
|
|
1904
1929
|
0,
|
|
1905
1930
|
() => import_outdent25.outdent`
|
|
1906
1931
|
const styleProps = ${styleFnName}()
|
|
@@ -1933,7 +1958,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1933
1958
|
// src/artifacts/react-jsx/types.ts
|
|
1934
1959
|
var import_outdent26 = require("outdent");
|
|
1935
1960
|
function generateReactJsxTypes(ctx) {
|
|
1936
|
-
const { factoryName,
|
|
1961
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1937
1962
|
return {
|
|
1938
1963
|
jsxFactory: import_outdent26.outdent`
|
|
1939
1964
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1957,18 +1982,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1957
1982
|
|
|
1958
1983
|
interface RecipeFn { __type: any }
|
|
1959
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
|
+
|
|
1960
1993
|
interface JsxFactory {
|
|
1961
|
-
|
|
1962
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
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}<
|
|
1963
1996
|
T,
|
|
1964
1997
|
RecipeSelection<P>
|
|
1965
1998
|
>
|
|
1966
|
-
<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']>
|
|
1967
2000
|
}
|
|
1968
2001
|
|
|
1969
2002
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1970
2003
|
|
|
1971
|
-
export type ${upperName} = JsxFactory
|
|
2004
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1972
2005
|
|
|
1973
2006
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1974
2007
|
`
|
|
@@ -2029,7 +2062,7 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
2029
2062
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
2030
2063
|
var import_outdent28 = require("outdent");
|
|
2031
2064
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
2032
|
-
const { factoryName,
|
|
2065
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2033
2066
|
return {
|
|
2034
2067
|
jsxFactory: import_outdent28.outdent`
|
|
2035
2068
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2056,7 +2089,7 @@ interface JsxFactory {
|
|
|
2056
2089
|
|
|
2057
2090
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2058
2091
|
|
|
2059
|
-
export type ${upperName} = JsxFactory
|
|
2092
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2060
2093
|
|
|
2061
2094
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2062
2095
|
`
|
|
@@ -2070,21 +2103,33 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2070
2103
|
return {
|
|
2071
2104
|
js: import_outdent29.outdent`
|
|
2072
2105
|
import { Dynamic } from 'solid-js/web'
|
|
2073
|
-
import { mergeProps, splitProps } from 'solid-js'
|
|
2106
|
+
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2074
2107
|
import { createComponent } from 'solid-js/web'
|
|
2075
|
-
${ctx.file.import("css, cx, cva
|
|
2108
|
+
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2076
2109
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
2077
|
-
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
2078
|
-
|
|
2079
|
-
|
|
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 = {}) {
|
|
2080
2115
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2081
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
|
+
|
|
2082
2125
|
return function ${componentName}(props) {
|
|
2083
|
-
const mergedProps = mergeProps({ as: element }, props)
|
|
2126
|
+
const mergedProps = mergeProps({ as: element }, defaultProps, props)
|
|
2127
|
+
const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
|
|
2084
2128
|
|
|
2085
|
-
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2129
|
+
const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2086
2130
|
mergedProps,
|
|
2087
|
-
['as', 'class'],
|
|
2131
|
+
['as', 'class', 'className'],
|
|
2132
|
+
forwardedKeys(),
|
|
2088
2133
|
cvaFn.variantKeys,
|
|
2089
2134
|
allCssProperties,
|
|
2090
2135
|
normalizeHTMLProps.keys
|
|
@@ -2092,20 +2137,28 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2092
2137
|
|
|
2093
2138
|
function recipeClass() {
|
|
2094
2139
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2095
|
-
|
|
2140
|
+
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
2141
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2096
2142
|
}
|
|
2097
2143
|
|
|
2098
2144
|
function cvaClass() {
|
|
2099
2145
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2100
2146
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
2101
|
-
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class)
|
|
2147
|
+
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2102
2148
|
}
|
|
2103
2149
|
|
|
2104
2150
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2105
2151
|
|
|
2152
|
+
if (forwardedProps.className) {
|
|
2153
|
+
delete forwardedProps.className
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2106
2156
|
return createComponent(
|
|
2107
2157
|
Dynamic,
|
|
2108
2158
|
mergeProps(
|
|
2159
|
+
forwardedProps,
|
|
2160
|
+
elementProps,
|
|
2161
|
+
normalizeHTMLProps(htmlProps),
|
|
2109
2162
|
{
|
|
2110
2163
|
get component() {
|
|
2111
2164
|
return localProps.as
|
|
@@ -2114,8 +2167,6 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2114
2167
|
return classes()
|
|
2115
2168
|
}
|
|
2116
2169
|
},
|
|
2117
|
-
elementProps,
|
|
2118
|
-
normalizeHTMLProps(htmlProps)
|
|
2119
2170
|
)
|
|
2120
2171
|
)
|
|
2121
2172
|
}
|
|
@@ -2144,7 +2195,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2144
2195
|
|
|
2145
2196
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2146
2197
|
var import_outdent30 = require("outdent");
|
|
2147
|
-
var
|
|
2198
|
+
var import_ts_pattern7 = require("ts-pattern");
|
|
2148
2199
|
function generateSolidJsxPattern(ctx) {
|
|
2149
2200
|
const { typeName, factoryName } = ctx.jsx;
|
|
2150
2201
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2159,7 +2210,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2159
2210
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2160
2211
|
|
|
2161
2212
|
export function ${jsxName}(props) {
|
|
2162
|
-
${(0,
|
|
2213
|
+
${(0, import_ts_pattern7.match)(props.length).with(
|
|
2163
2214
|
0,
|
|
2164
2215
|
() => import_outdent30.outdent`
|
|
2165
2216
|
const styleProps = ${styleFnName}()
|
|
@@ -2192,7 +2243,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2192
2243
|
// src/artifacts/solid-jsx/types.ts
|
|
2193
2244
|
var import_outdent31 = require("outdent");
|
|
2194
2245
|
function generateSolidJsxTypes(ctx) {
|
|
2195
|
-
const { factoryName,
|
|
2246
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2196
2247
|
return {
|
|
2197
2248
|
jsxFactory: import_outdent31.outdent`
|
|
2198
2249
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2214,18 +2265,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
2214
2265
|
|
|
2215
2266
|
interface RecipeFn { __type: any }
|
|
2216
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
|
+
|
|
2217
2276
|
interface JsxFactory {
|
|
2218
|
-
|
|
2219
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
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}<
|
|
2220
2279
|
T,
|
|
2221
2280
|
RecipeSelection<P>
|
|
2222
2281
|
>
|
|
2223
|
-
<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']>
|
|
2224
2283
|
}
|
|
2225
2284
|
|
|
2226
2285
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2227
2286
|
|
|
2228
|
-
export type ${upperName} = JsxFactory
|
|
2287
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2229
2288
|
|
|
2230
2289
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2231
2290
|
`
|
|
@@ -2291,7 +2350,7 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
|
2291
2350
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2292
2351
|
var import_outdent33 = require("outdent");
|
|
2293
2352
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2294
|
-
const { factoryName,
|
|
2353
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2295
2354
|
return {
|
|
2296
2355
|
jsxFactory: import_outdent33.outdent`
|
|
2297
2356
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2315,7 +2374,7 @@ interface JsxFactory {
|
|
|
2315
2374
|
|
|
2316
2375
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2317
2376
|
|
|
2318
|
-
export type ${upperName} = JsxFactory
|
|
2377
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2319
2378
|
|
|
2320
2379
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2321
2380
|
`
|
|
@@ -2329,12 +2388,23 @@ function generateVueJsxFactory(ctx) {
|
|
|
2329
2388
|
return {
|
|
2330
2389
|
js: import_outdent34.outdent`
|
|
2331
2390
|
import { defineComponent, h, computed } from 'vue'
|
|
2332
|
-
${ctx.file.import("css, cx, cva
|
|
2391
|
+
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2333
2392
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2334
2393
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2335
2394
|
|
|
2336
|
-
|
|
2395
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2396
|
+
|
|
2397
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
2337
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
|
+
|
|
2338
2408
|
const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
|
|
2339
2409
|
|
|
2340
2410
|
return defineComponent({
|
|
@@ -2342,34 +2412,37 @@ function generateVueJsxFactory(ctx) {
|
|
|
2342
2412
|
inheritAttrs: false,
|
|
2343
2413
|
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2344
2414
|
setup(props, { slots, attrs }) {
|
|
2415
|
+
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2416
|
+
|
|
2345
2417
|
const splittedProps = computed(() => {
|
|
2346
|
-
return splitProps(
|
|
2418
|
+
return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
2347
2419
|
})
|
|
2348
2420
|
|
|
2349
2421
|
const recipeClass = computed(() => {
|
|
2350
|
-
const [variantProps, styleProps, _htmlProps,
|
|
2422
|
+
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2351
2423
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2352
2424
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
2353
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
2425
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2354
2426
|
})
|
|
2355
2427
|
|
|
2356
2428
|
const cvaClass = computed(() => {
|
|
2357
|
-
const [variantProps, styleProps, _htmlProps,
|
|
2429
|
+
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2358
2430
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2359
|
-
|
|
2431
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
2432
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2360
2433
|
})
|
|
2361
2434
|
|
|
2362
2435
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2363
2436
|
|
|
2364
2437
|
return () => {
|
|
2365
|
-
const [
|
|
2366
|
-
|
|
2438
|
+
const [forwardedProps, _variantProps, _styleProps, htmlProps, elementProps] = splittedProps.value
|
|
2367
2439
|
return h(
|
|
2368
2440
|
props.as,
|
|
2369
2441
|
{
|
|
2370
|
-
|
|
2442
|
+
...forwardedProps.value,
|
|
2371
2443
|
...elementProps,
|
|
2372
2444
|
...normalizeHTMLProps(htmlProps),
|
|
2445
|
+
class: classes.value,
|
|
2373
2446
|
},
|
|
2374
2447
|
slots.default && slots.default(),
|
|
2375
2448
|
)
|
|
@@ -2497,7 +2570,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2497
2570
|
// src/artifacts/vue-jsx/types.ts
|
|
2498
2571
|
var import_outdent37 = require("outdent");
|
|
2499
2572
|
function generateVueJsxTypes(ctx) {
|
|
2500
|
-
const { factoryName,
|
|
2573
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2501
2574
|
return {
|
|
2502
2575
|
jsxFactory: import_outdent37.outdent`
|
|
2503
2576
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2525,18 +2598,26 @@ JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
|
2525
2598
|
|
|
2526
2599
|
interface RecipeFn = { __type: any }
|
|
2527
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
|
+
|
|
2528
2609
|
interface JsxFactory {
|
|
2529
|
-
|
|
2530
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
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}<
|
|
2531
2612
|
T,
|
|
2532
2613
|
RecipeSelection<P>
|
|
2533
2614
|
>
|
|
2534
|
-
<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']>
|
|
2535
2616
|
}
|
|
2536
2617
|
|
|
2537
2618
|
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
|
|
2538
2619
|
|
|
2539
|
-
export type ${upperName} = JsxFactory
|
|
2620
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2540
2621
|
|
|
2541
2622
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2542
2623
|
`
|
|
@@ -2546,7 +2627,7 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
2546
2627
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2547
2628
|
var import_outdent38 = require("outdent");
|
|
2548
2629
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2549
|
-
const { factoryName,
|
|
2630
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2550
2631
|
return {
|
|
2551
2632
|
jsxFactory: import_outdent38.outdent`
|
|
2552
2633
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2574,7 +2655,7 @@ interface JsxFactory {
|
|
|
2574
2655
|
|
|
2575
2656
|
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
|
|
2576
2657
|
|
|
2577
|
-
export type ${upperName} = JsxFactory
|
|
2658
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2578
2659
|
|
|
2579
2660
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2580
2661
|
`
|
|
@@ -2718,7 +2799,7 @@ var selectors_d_ts_default = {
|
|
|
2718
2799
|
};
|
|
2719
2800
|
|
|
2720
2801
|
// src/artifacts/types/generated.ts
|
|
2721
|
-
var
|
|
2802
|
+
var import_ts_pattern8 = require("ts-pattern");
|
|
2722
2803
|
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2723
2804
|
function getGeneratedTypes(ctx) {
|
|
2724
2805
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
@@ -2730,7 +2811,7 @@ function getGeneratedTypes(ctx) {
|
|
|
2730
2811
|
composition: rewriteImports(composition_d_ts_default.content),
|
|
2731
2812
|
selectors: rewriteImports(selectors_d_ts_default.content),
|
|
2732
2813
|
system: rewriteImports(
|
|
2733
|
-
(0,
|
|
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()
|
|
2734
2815
|
)
|
|
2735
2816
|
};
|
|
2736
2817
|
}
|
|
@@ -3178,7 +3259,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3178
3259
|
// src/artifacts/css/parser-css.ts
|
|
3179
3260
|
var import_logger2 = require("@pandacss/logger");
|
|
3180
3261
|
var import_func = require("lil-fp/func");
|
|
3181
|
-
var
|
|
3262
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
3182
3263
|
var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
3183
3264
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3184
3265
|
(0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3208,7 +3289,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3208
3289
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3209
3290
|
if (!recipeConfig)
|
|
3210
3291
|
continue;
|
|
3211
|
-
(0,
|
|
3292
|
+
(0, import_ts_pattern9.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3212
3293
|
recipe.data.forEach((data) => {
|
|
3213
3294
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3214
3295
|
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3227,7 +3308,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3227
3308
|
result2.pattern.forEach((patternSet, name) => {
|
|
3228
3309
|
try {
|
|
3229
3310
|
for (const pattern of patternSet) {
|
|
3230
|
-
(0,
|
|
3311
|
+
(0, import_ts_pattern9.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern9.P.string }, ({ name: jsxName }) => {
|
|
3231
3312
|
pattern.data.forEach((data) => {
|
|
3232
3313
|
const fnName = patterns.find(jsxName);
|
|
3233
3314
|
const styleProps = patterns.transform(fnName, data);
|