@pandacss/generator 0.15.3 → 0.15.5
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 +227 -144
- package/dist/index.mjs +227 -144
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -173,7 +173,7 @@ var generateGlobalCss = (ctx) => {
|
|
|
173
173
|
});
|
|
174
174
|
sheet.processGlobalCss(globalCss);
|
|
175
175
|
const output = sheet.toCss({ optimize });
|
|
176
|
-
ctx.hooks.callHook("generator:css", "global.css", output);
|
|
176
|
+
void ctx.hooks.callHook("generator:css", "global.css", output);
|
|
177
177
|
return output;
|
|
178
178
|
};
|
|
179
179
|
|
|
@@ -198,7 +198,7 @@ function generateKeyframeCss(ctx) {
|
|
|
198
198
|
nodes: root.nodes
|
|
199
199
|
});
|
|
200
200
|
const output = rule.toString();
|
|
201
|
-
ctx.hooks.callHook("generator:css", "keyframes.css", output);
|
|
201
|
+
void ctx.hooks.callHook("generator:css", "keyframes.css", output);
|
|
202
202
|
return output;
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -412,7 +412,7 @@ function generateResetCss(ctx, scope = "") {
|
|
|
412
412
|
outline: auto;
|
|
413
413
|
}
|
|
414
414
|
}`;
|
|
415
|
-
ctx.hooks.callHook("generator:css", "reset.css", output);
|
|
415
|
+
void ctx.hooks.callHook("generator:css", "reset.css", output);
|
|
416
416
|
return output;
|
|
417
417
|
}
|
|
418
418
|
|
|
@@ -451,7 +451,7 @@ var generateStaticCss = (ctx) => {
|
|
|
451
451
|
});
|
|
452
452
|
});
|
|
453
453
|
const output = sheet.toCss({ optimize });
|
|
454
|
-
ctx.hooks.callHook("generator:css", "static.css", output);
|
|
454
|
+
void ctx.hooks.callHook("generator:css", "static.css", output);
|
|
455
455
|
return output;
|
|
456
456
|
};
|
|
457
457
|
|
|
@@ -492,7 +492,7 @@ function generateTokenCss(ctx) {
|
|
|
492
492
|
${(0, import_core3.prettifyCss)(cleanupSelectors(css2, root))}
|
|
493
493
|
}
|
|
494
494
|
`;
|
|
495
|
-
ctx.hooks.callHook("generator:css", "tokens.css", output);
|
|
495
|
+
void ctx.hooks.callHook("generator:css", "tokens.css", output);
|
|
496
496
|
return output;
|
|
497
497
|
}
|
|
498
498
|
function getDeepestRule(root, selectors) {
|
|
@@ -1115,7 +1115,7 @@ function generateRecipes(ctx) {
|
|
|
1115
1115
|
const ${baseName}CompoundVariants = ${stringify2(compoundVariants ?? [])}
|
|
1116
1116
|
|
|
1117
1117
|
const ${baseName}SlotNames = ${stringify2(config2.slots.map((slot) => [slot, `${config2.className}__${slot}`]))}
|
|
1118
|
-
const ${baseName}SlotFns = ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
|
|
1118
|
+
const ${baseName}SlotFns = /* @__PURE__ */ ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
|
|
1119
1119
|
|
|
1120
1120
|
const ${baseName}Fn = (props = {}) => {
|
|
1121
1121
|
return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn(props)]))
|
|
@@ -1123,8 +1123,9 @@ function generateRecipes(ctx) {
|
|
|
1123
1123
|
|
|
1124
1124
|
const ${baseName}VariantKeys = ${stringify2(Object.keys(variantKeyMap))}
|
|
1125
1125
|
|
|
1126
|
-
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1126
|
+
export const ${baseName} = /* @__PURE__ */ 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)},
|
|
@@ -1138,14 +1139,17 @@ function generateRecipes(ctx) {
|
|
|
1138
1139
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1139
1140
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1140
1141
|
|
|
1141
|
-
const ${baseName}Fn = createRecipe('${config2.className}', ${stringify2(
|
|
1142
|
-
|
|
1143
|
-
)})
|
|
1142
|
+
const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
|
|
1143
|
+
defaultVariants ?? {}
|
|
1144
|
+
)}, ${stringify2(compoundVariants ?? [])})
|
|
1144
1145
|
|
|
1145
1146
|
const ${baseName}VariantMap = ${stringify2(variantKeyMap)}
|
|
1147
|
+
|
|
1146
1148
|
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1147
|
-
|
|
1149
|
+
|
|
1150
|
+
export const ${baseName} = /* @__PURE__ */ Object.assign(${baseName}Fn, {
|
|
1148
1151
|
__recipe__: true,
|
|
1152
|
+
__name__: '${baseName}',
|
|
1149
1153
|
raw: (props) => props,
|
|
1150
1154
|
variantKeys: ${baseName}VariantKeys,
|
|
1151
1155
|
variantMap: ${baseName}VariantMap,
|
|
@@ -1297,33 +1301,47 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1297
1301
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1298
1302
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1299
1303
|
|
|
1300
|
-
|
|
1304
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1305
|
+
|
|
1306
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1301
1307
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1302
1308
|
|
|
1309
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
1310
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
1311
|
+
|
|
1312
|
+
const defaultProps = Object.assign(
|
|
1313
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
1314
|
+
options.defaultProps,
|
|
1315
|
+
)
|
|
1316
|
+
|
|
1303
1317
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1304
|
-
const { as: Element = Dynamic, ...restProps } = props
|
|
1318
|
+
const { as: Element = Dynamic, children, ...restProps } = props
|
|
1319
|
+
|
|
1320
|
+
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1305
1321
|
|
|
1306
|
-
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1307
|
-
return splitProps(
|
|
1308
|
-
}, [
|
|
1322
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1323
|
+
return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1324
|
+
}, [combinedProps])
|
|
1309
1325
|
|
|
1310
1326
|
function recipeClass() {
|
|
1311
1327
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1312
1328
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1313
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
1329
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1314
1330
|
}
|
|
1315
1331
|
|
|
1316
1332
|
function cvaClass() {
|
|
1317
1333
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1318
1334
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
1319
|
-
return cx(css(cvaStyles, propStyles, cssStyles),
|
|
1335
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1320
1336
|
}
|
|
1321
1337
|
|
|
1322
1338
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1323
1339
|
|
|
1324
1340
|
return h(Element, {
|
|
1341
|
+
...forwardedProps,
|
|
1325
1342
|
...elementProps,
|
|
1326
1343
|
...normalizeHTMLProps(htmlProps),
|
|
1344
|
+
children,
|
|
1327
1345
|
ref,
|
|
1328
1346
|
className: classes()
|
|
1329
1347
|
})
|
|
@@ -1405,7 +1423,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1405
1423
|
// src/artifacts/preact-jsx/types.ts
|
|
1406
1424
|
var import_outdent16 = require("outdent");
|
|
1407
1425
|
function generatePreactJsxTypes(ctx) {
|
|
1408
|
-
const { factoryName,
|
|
1426
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1409
1427
|
return {
|
|
1410
1428
|
jsxFactory: import_outdent16.outdent`
|
|
1411
1429
|
import type { ${upperName} } from '../types/jsx'
|
|
@@ -1425,20 +1443,28 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1425
1443
|
displayName?: string
|
|
1426
1444
|
}
|
|
1427
1445
|
|
|
1428
|
-
interface RecipeFn
|
|
1446
|
+
interface RecipeFn { __type: any }
|
|
1447
|
+
|
|
1448
|
+
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1449
|
+
dataAttr?: boolean
|
|
1450
|
+
defaultProps?: TProps
|
|
1451
|
+
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1429
1455
|
|
|
1430
1456
|
interface JsxFactory {
|
|
1431
|
-
|
|
1432
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
1457
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1458
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
|
|
1433
1459
|
T,
|
|
1434
1460
|
RecipeSelection<P>
|
|
1435
1461
|
>
|
|
1436
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1462
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
|
|
1437
1463
|
}
|
|
1438
1464
|
|
|
1439
1465
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1440
1466
|
|
|
1441
|
-
export type ${upperName} = JsxFactory
|
|
1467
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1442
1468
|
|
|
1443
1469
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1444
1470
|
`
|
|
@@ -1499,7 +1525,7 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1499
1525
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1500
1526
|
var import_outdent18 = require("outdent");
|
|
1501
1527
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1502
|
-
const { factoryName,
|
|
1528
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1503
1529
|
return {
|
|
1504
1530
|
jsxFactory: import_outdent18.outdent`
|
|
1505
1531
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1523,7 +1549,7 @@ interface JsxFactory {
|
|
|
1523
1549
|
|
|
1524
1550
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1525
1551
|
|
|
1526
|
-
export type ${upperName} = JsxFactory
|
|
1552
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1527
1553
|
|
|
1528
1554
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1529
1555
|
`
|
|
@@ -1541,32 +1567,46 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1541
1567
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1542
1568
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1543
1569
|
|
|
1544
|
-
|
|
1570
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1571
|
+
|
|
1572
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1545
1573
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1546
1574
|
|
|
1575
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
1576
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
1577
|
+
|
|
1578
|
+
const defaultProps = Object.assign(
|
|
1579
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
1580
|
+
options.defaultProps,
|
|
1581
|
+
)
|
|
1582
|
+
|
|
1547
1583
|
const ${componentName} = function ${componentName}(props) {
|
|
1548
|
-
const { as: Element = Dynamic, ...restProps } = props
|
|
1584
|
+
const { as: Element = Dynamic, children, className, ...restProps } = props
|
|
1549
1585
|
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1586
|
+
const combinedProps = Object.assign({}, defaultProps, restProps)
|
|
1587
|
+
|
|
1588
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
|
|
1589
|
+
splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1552
1590
|
|
|
1553
1591
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1554
1592
|
|
|
1555
1593
|
function recipeClass() {
|
|
1556
1594
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1557
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
1595
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1558
1596
|
}
|
|
1559
1597
|
|
|
1560
1598
|
function cvaClass() {
|
|
1561
1599
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
1562
|
-
return cx(css(cvaStyles, propStyles, cssStyles),
|
|
1600
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1563
1601
|
}
|
|
1564
1602
|
|
|
1565
1603
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1566
1604
|
|
|
1567
1605
|
return h(Element, {
|
|
1606
|
+
...forwardedProps,
|
|
1568
1607
|
...elementProps,
|
|
1569
1608
|
...normalizeHTMLProps(htmlProps),
|
|
1609
|
+
children,
|
|
1570
1610
|
class: classes(),
|
|
1571
1611
|
})
|
|
1572
1612
|
}
|
|
@@ -1647,7 +1687,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1647
1687
|
// src/artifacts/qwik-jsx/types.ts
|
|
1648
1688
|
var import_outdent21 = require("outdent");
|
|
1649
1689
|
function generateQwikJsxTypes(ctx) {
|
|
1650
|
-
const { factoryName,
|
|
1690
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1651
1691
|
return {
|
|
1652
1692
|
jsxFactory: import_outdent21.outdent`
|
|
1653
1693
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1672,18 +1712,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> ex
|
|
|
1672
1712
|
|
|
1673
1713
|
interface RecipeFn { __type: any }
|
|
1674
1714
|
|
|
1715
|
+
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1716
|
+
dataAttr?: boolean
|
|
1717
|
+
defaultProps?: TProps
|
|
1718
|
+
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1722
|
+
|
|
1675
1723
|
interface JsxFactory {
|
|
1676
|
-
|
|
1677
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
1724
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1725
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
|
|
1678
1726
|
T,
|
|
1679
1727
|
RecipeSelection<P>
|
|
1680
1728
|
>
|
|
1681
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1729
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
|
|
1682
1730
|
}
|
|
1683
1731
|
|
|
1684
1732
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1685
1733
|
|
|
1686
|
-
export type ${upperName} = JsxFactory
|
|
1734
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1687
1735
|
|
|
1688
1736
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1689
1737
|
`
|
|
@@ -1743,7 +1791,7 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1743
1791
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1744
1792
|
var import_outdent23 = require("outdent");
|
|
1745
1793
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1746
|
-
const { factoryName,
|
|
1794
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1747
1795
|
return {
|
|
1748
1796
|
jsxFactory: import_outdent23.outdent`
|
|
1749
1797
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1772,7 +1820,7 @@ interface JsxFactory {
|
|
|
1772
1820
|
|
|
1773
1821
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1774
1822
|
|
|
1775
|
-
export type ${upperName} = JsxFactory
|
|
1823
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1776
1824
|
|
|
1777
1825
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1778
1826
|
`
|
|
@@ -1781,7 +1829,6 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1781
1829
|
|
|
1782
1830
|
// src/artifacts/react-jsx/jsx.ts
|
|
1783
1831
|
var import_outdent24 = require("outdent");
|
|
1784
|
-
var import_ts_pattern6 = require("ts-pattern");
|
|
1785
1832
|
function generateReactJsxFactory(ctx) {
|
|
1786
1833
|
const { factoryName, componentName } = ctx.jsx;
|
|
1787
1834
|
return {
|
|
@@ -1789,70 +1836,50 @@ function generateReactJsxFactory(ctx) {
|
|
|
1789
1836
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1790
1837
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1791
1838
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1792
|
-
${ctx.
|
|
1839
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1793
1840
|
|
|
1794
|
-
|
|
1841
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1842
|
+
|
|
1843
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1795
1844
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1796
1845
|
|
|
1797
|
-
const
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}, [restProps])
|
|
1846
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
1847
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
1848
|
+
|
|
1849
|
+
const defaultProps = Object.assign(
|
|
1850
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
1851
|
+
options.defaultProps,
|
|
1852
|
+
)
|
|
1805
1853
|
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1809
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), elementProps.className)
|
|
1810
|
-
}
|
|
1854
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1855
|
+
const { as: Element = Dynamic, children, ...restProps } = props
|
|
1811
1856
|
|
|
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
|
-
}
|
|
1857
|
+
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1827
1858
|
|
|
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
|
-
}
|
|
1859
|
+
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1860
|
+
return splitProps(combinedProps, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1861
|
+
}, [combinedProps])
|
|
1842
1862
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1863
|
+
function recipeClass() {
|
|
1864
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1865
|
+
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
1866
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
|
|
1867
|
+
}
|
|
1848
1868
|
|
|
1869
|
+
function cvaClass() {
|
|
1870
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1871
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1872
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
|
|
1873
|
+
}
|
|
1849
1874
|
|
|
1850
1875
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1851
1876
|
|
|
1852
1877
|
return createElement(Element, {
|
|
1853
1878
|
ref,
|
|
1879
|
+
...forwardedProps,
|
|
1854
1880
|
...elementProps,
|
|
1855
1881
|
...normalizeHTMLProps(htmlProps),
|
|
1882
|
+
children,
|
|
1856
1883
|
className: classes(),
|
|
1857
1884
|
})
|
|
1858
1885
|
})
|
|
@@ -1886,7 +1913,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1886
1913
|
|
|
1887
1914
|
// src/artifacts/react-jsx/pattern.ts
|
|
1888
1915
|
var import_outdent25 = require("outdent");
|
|
1889
|
-
var
|
|
1916
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
1890
1917
|
function generateReactJsxPattern(ctx) {
|
|
1891
1918
|
const { typeName, factoryName } = ctx.jsx;
|
|
1892
1919
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1900,7 +1927,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1900
1927
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1901
1928
|
|
|
1902
1929
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1903
|
-
${(0,
|
|
1930
|
+
${(0, import_ts_pattern6.match)(props.length).with(
|
|
1904
1931
|
0,
|
|
1905
1932
|
() => import_outdent25.outdent`
|
|
1906
1933
|
const styleProps = ${styleFnName}()
|
|
@@ -1933,7 +1960,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1933
1960
|
// src/artifacts/react-jsx/types.ts
|
|
1934
1961
|
var import_outdent26 = require("outdent");
|
|
1935
1962
|
function generateReactJsxTypes(ctx) {
|
|
1936
|
-
const { factoryName,
|
|
1963
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1937
1964
|
return {
|
|
1938
1965
|
jsxFactory: import_outdent26.outdent`
|
|
1939
1966
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -1957,18 +1984,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1957
1984
|
|
|
1958
1985
|
interface RecipeFn { __type: any }
|
|
1959
1986
|
|
|
1987
|
+
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1988
|
+
dataAttr?: boolean
|
|
1989
|
+
defaultProps?: TProps
|
|
1990
|
+
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1994
|
+
|
|
1960
1995
|
interface JsxFactory {
|
|
1961
|
-
|
|
1962
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
1996
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1997
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
|
|
1963
1998
|
T,
|
|
1964
1999
|
RecipeSelection<P>
|
|
1965
2000
|
>
|
|
1966
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2001
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
|
|
1967
2002
|
}
|
|
1968
2003
|
|
|
1969
2004
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1970
2005
|
|
|
1971
|
-
export type ${upperName} = JsxFactory
|
|
2006
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1972
2007
|
|
|
1973
2008
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1974
2009
|
`
|
|
@@ -2029,7 +2064,7 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
2029
2064
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
2030
2065
|
var import_outdent28 = require("outdent");
|
|
2031
2066
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
2032
|
-
const { factoryName,
|
|
2067
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2033
2068
|
return {
|
|
2034
2069
|
jsxFactory: import_outdent28.outdent`
|
|
2035
2070
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2056,7 +2091,7 @@ interface JsxFactory {
|
|
|
2056
2091
|
|
|
2057
2092
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2058
2093
|
|
|
2059
|
-
export type ${upperName} = JsxFactory
|
|
2094
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2060
2095
|
|
|
2061
2096
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2062
2097
|
`
|
|
@@ -2070,21 +2105,33 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2070
2105
|
return {
|
|
2071
2106
|
js: import_outdent29.outdent`
|
|
2072
2107
|
import { Dynamic } from 'solid-js/web'
|
|
2073
|
-
import { mergeProps, splitProps } from 'solid-js'
|
|
2108
|
+
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2074
2109
|
import { createComponent } from 'solid-js/web'
|
|
2075
|
-
${ctx.file.import("css, cx, cva
|
|
2110
|
+
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2076
2111
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
2077
|
-
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
2078
|
-
|
|
2079
|
-
|
|
2112
|
+
${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
|
|
2113
|
+
|
|
2114
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2115
|
+
|
|
2116
|
+
function styledFn(element, configOrCva = {}, options = {}) {
|
|
2080
2117
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2081
2118
|
|
|
2119
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
2120
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
2121
|
+
|
|
2122
|
+
const defaultProps = Object.assign(
|
|
2123
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
2124
|
+
options.defaultProps,
|
|
2125
|
+
)
|
|
2126
|
+
|
|
2082
2127
|
return function ${componentName}(props) {
|
|
2083
|
-
const mergedProps = mergeProps({ as: element }, props)
|
|
2128
|
+
const mergedProps = mergeProps({ as: element }, defaultProps, props)
|
|
2129
|
+
const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
|
|
2084
2130
|
|
|
2085
|
-
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2131
|
+
const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2086
2132
|
mergedProps,
|
|
2087
|
-
['as', 'class'],
|
|
2133
|
+
['as', 'class', 'className'],
|
|
2134
|
+
forwardedKeys(),
|
|
2088
2135
|
cvaFn.variantKeys,
|
|
2089
2136
|
allCssProperties,
|
|
2090
2137
|
normalizeHTMLProps.keys
|
|
@@ -2092,20 +2139,28 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2092
2139
|
|
|
2093
2140
|
function recipeClass() {
|
|
2094
2141
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2095
|
-
|
|
2142
|
+
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
2143
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2096
2144
|
}
|
|
2097
2145
|
|
|
2098
2146
|
function cvaClass() {
|
|
2099
2147
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2100
2148
|
const cvaStyles = cvaFn.raw(variantProps)
|
|
2101
|
-
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class)
|
|
2149
|
+
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2102
2150
|
}
|
|
2103
2151
|
|
|
2104
2152
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2105
2153
|
|
|
2154
|
+
if (forwardedProps.className) {
|
|
2155
|
+
delete forwardedProps.className
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2106
2158
|
return createComponent(
|
|
2107
2159
|
Dynamic,
|
|
2108
2160
|
mergeProps(
|
|
2161
|
+
forwardedProps,
|
|
2162
|
+
elementProps,
|
|
2163
|
+
normalizeHTMLProps(htmlProps),
|
|
2109
2164
|
{
|
|
2110
2165
|
get component() {
|
|
2111
2166
|
return localProps.as
|
|
@@ -2114,8 +2169,6 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2114
2169
|
return classes()
|
|
2115
2170
|
}
|
|
2116
2171
|
},
|
|
2117
|
-
elementProps,
|
|
2118
|
-
normalizeHTMLProps(htmlProps)
|
|
2119
2172
|
)
|
|
2120
2173
|
)
|
|
2121
2174
|
}
|
|
@@ -2144,7 +2197,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2144
2197
|
|
|
2145
2198
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2146
2199
|
var import_outdent30 = require("outdent");
|
|
2147
|
-
var
|
|
2200
|
+
var import_ts_pattern7 = require("ts-pattern");
|
|
2148
2201
|
function generateSolidJsxPattern(ctx) {
|
|
2149
2202
|
const { typeName, factoryName } = ctx.jsx;
|
|
2150
2203
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2159,7 +2212,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2159
2212
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2160
2213
|
|
|
2161
2214
|
export function ${jsxName}(props) {
|
|
2162
|
-
${(0,
|
|
2215
|
+
${(0, import_ts_pattern7.match)(props.length).with(
|
|
2163
2216
|
0,
|
|
2164
2217
|
() => import_outdent30.outdent`
|
|
2165
2218
|
const styleProps = ${styleFnName}()
|
|
@@ -2192,7 +2245,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2192
2245
|
// src/artifacts/solid-jsx/types.ts
|
|
2193
2246
|
var import_outdent31 = require("outdent");
|
|
2194
2247
|
function generateSolidJsxTypes(ctx) {
|
|
2195
|
-
const { factoryName,
|
|
2248
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2196
2249
|
return {
|
|
2197
2250
|
jsxFactory: import_outdent31.outdent`
|
|
2198
2251
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2214,18 +2267,26 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
2214
2267
|
|
|
2215
2268
|
interface RecipeFn { __type: any }
|
|
2216
2269
|
|
|
2270
|
+
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2271
|
+
dataAttr?: boolean
|
|
2272
|
+
defaultProps?: TProps
|
|
2273
|
+
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
2277
|
+
|
|
2217
2278
|
interface JsxFactory {
|
|
2218
|
-
|
|
2219
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
2279
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2280
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
|
|
2220
2281
|
T,
|
|
2221
2282
|
RecipeSelection<P>
|
|
2222
2283
|
>
|
|
2223
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2284
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): ${componentName}<T, P['__type']>
|
|
2224
2285
|
}
|
|
2225
2286
|
|
|
2226
2287
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2227
2288
|
|
|
2228
|
-
export type ${upperName} = JsxFactory
|
|
2289
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2229
2290
|
|
|
2230
2291
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2231
2292
|
`
|
|
@@ -2291,7 +2352,7 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
|
2291
2352
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2292
2353
|
var import_outdent33 = require("outdent");
|
|
2293
2354
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2294
|
-
const { factoryName,
|
|
2355
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2295
2356
|
return {
|
|
2296
2357
|
jsxFactory: import_outdent33.outdent`
|
|
2297
2358
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2315,7 +2376,7 @@ interface JsxFactory {
|
|
|
2315
2376
|
|
|
2316
2377
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2317
2378
|
|
|
2318
|
-
export type ${upperName} = JsxFactory
|
|
2379
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2319
2380
|
|
|
2320
2381
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2321
2382
|
`
|
|
@@ -2329,12 +2390,23 @@ function generateVueJsxFactory(ctx) {
|
|
|
2329
2390
|
return {
|
|
2330
2391
|
js: import_outdent34.outdent`
|
|
2331
2392
|
import { defineComponent, h, computed } from 'vue'
|
|
2332
|
-
${ctx.file.import("css, cx, cva
|
|
2393
|
+
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2333
2394
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2334
2395
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2335
2396
|
|
|
2336
|
-
|
|
2397
|
+
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2398
|
+
|
|
2399
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
2337
2400
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2401
|
+
|
|
2402
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
2403
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
2404
|
+
|
|
2405
|
+
const defaultProps = Object.assign(
|
|
2406
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
2407
|
+
options.defaultProps,
|
|
2408
|
+
)
|
|
2409
|
+
|
|
2338
2410
|
const name = (typeof Dynamic === 'string' ? Dynamic : Dynamic.displayName || Dynamic.name) || 'Component'
|
|
2339
2411
|
|
|
2340
2412
|
return defineComponent({
|
|
@@ -2342,34 +2414,37 @@ function generateVueJsxFactory(ctx) {
|
|
|
2342
2414
|
inheritAttrs: false,
|
|
2343
2415
|
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2344
2416
|
setup(props, { slots, attrs }) {
|
|
2417
|
+
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2418
|
+
|
|
2345
2419
|
const splittedProps = computed(() => {
|
|
2346
|
-
return splitProps(
|
|
2420
|
+
return splitProps(combinedProps.value, shouldForwardProp, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
2347
2421
|
})
|
|
2348
2422
|
|
|
2349
2423
|
const recipeClass = computed(() => {
|
|
2350
|
-
const [variantProps, styleProps, _htmlProps,
|
|
2424
|
+
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2351
2425
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2352
2426
|
const compoundVariantStyles = cvaFn.__getCompoundVariantCss__?.(variantProps);
|
|
2353
|
-
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles),
|
|
2427
|
+
return cx(cvaFn(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2354
2428
|
})
|
|
2355
2429
|
|
|
2356
2430
|
const cvaClass = computed(() => {
|
|
2357
|
-
const [variantProps, styleProps, _htmlProps,
|
|
2431
|
+
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2358
2432
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2359
|
-
|
|
2433
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
2434
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2360
2435
|
})
|
|
2361
2436
|
|
|
2362
2437
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2363
2438
|
|
|
2364
2439
|
return () => {
|
|
2365
|
-
const [
|
|
2366
|
-
|
|
2440
|
+
const [forwardedProps, _variantProps, _styleProps, htmlProps, elementProps] = splittedProps.value
|
|
2367
2441
|
return h(
|
|
2368
2442
|
props.as,
|
|
2369
2443
|
{
|
|
2370
|
-
|
|
2444
|
+
...forwardedProps,
|
|
2371
2445
|
...elementProps,
|
|
2372
2446
|
...normalizeHTMLProps(htmlProps),
|
|
2447
|
+
class: classes.value,
|
|
2373
2448
|
},
|
|
2374
2449
|
slots.default && slots.default(),
|
|
2375
2450
|
)
|
|
@@ -2497,7 +2572,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2497
2572
|
// src/artifacts/vue-jsx/types.ts
|
|
2498
2573
|
var import_outdent37 = require("outdent");
|
|
2499
2574
|
function generateVueJsxTypes(ctx) {
|
|
2500
|
-
const { factoryName,
|
|
2575
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2501
2576
|
return {
|
|
2502
2577
|
jsxFactory: import_outdent37.outdent`
|
|
2503
2578
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2523,20 +2598,28 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
|
2523
2598
|
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2524
2599
|
> {}
|
|
2525
2600
|
|
|
2526
|
-
interface RecipeFn
|
|
2601
|
+
interface RecipeFn { __type: any }
|
|
2602
|
+
|
|
2603
|
+
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2604
|
+
dataAttr?: boolean
|
|
2605
|
+
defaultProps?: TProps
|
|
2606
|
+
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
|
|
2527
2610
|
|
|
2528
2611
|
interface JsxFactory {
|
|
2529
|
-
|
|
2530
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P
|
|
2612
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2613
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): ${componentName}<
|
|
2531
2614
|
T,
|
|
2532
2615
|
RecipeSelection<P>
|
|
2533
2616
|
>
|
|
2534
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2617
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): ${componentName}<T, P['__type']>
|
|
2535
2618
|
}
|
|
2536
2619
|
|
|
2537
2620
|
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
|
|
2538
2621
|
|
|
2539
|
-
export type ${upperName} = JsxFactory
|
|
2622
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2540
2623
|
|
|
2541
2624
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2542
2625
|
`
|
|
@@ -2546,7 +2629,7 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
2546
2629
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2547
2630
|
var import_outdent38 = require("outdent");
|
|
2548
2631
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2549
|
-
const { factoryName,
|
|
2632
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2550
2633
|
return {
|
|
2551
2634
|
jsxFactory: import_outdent38.outdent`
|
|
2552
2635
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
@@ -2574,7 +2657,7 @@ interface JsxFactory {
|
|
|
2574
2657
|
|
|
2575
2658
|
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
|
|
2576
2659
|
|
|
2577
|
-
export type ${upperName} = JsxFactory
|
|
2660
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2578
2661
|
|
|
2579
2662
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2580
2663
|
`
|
|
@@ -2718,7 +2801,7 @@ var selectors_d_ts_default = {
|
|
|
2718
2801
|
};
|
|
2719
2802
|
|
|
2720
2803
|
// src/artifacts/types/generated.ts
|
|
2721
|
-
var
|
|
2804
|
+
var import_ts_pattern8 = require("ts-pattern");
|
|
2722
2805
|
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2723
2806
|
function getGeneratedTypes(ctx) {
|
|
2724
2807
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
@@ -2730,7 +2813,7 @@ function getGeneratedTypes(ctx) {
|
|
|
2730
2813
|
composition: rewriteImports(composition_d_ts_default.content),
|
|
2731
2814
|
selectors: rewriteImports(selectors_d_ts_default.content),
|
|
2732
2815
|
system: rewriteImports(
|
|
2733
|
-
(0,
|
|
2816
|
+
(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
2817
|
)
|
|
2735
2818
|
};
|
|
2736
2819
|
}
|
|
@@ -3171,14 +3254,14 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3171
3254
|
});
|
|
3172
3255
|
sheet.append(...files);
|
|
3173
3256
|
const output = sheet.toCss({ optimize: true, minify });
|
|
3174
|
-
ctx.hooks.callHook("generator:css", "styles.css", output);
|
|
3257
|
+
void ctx.hooks.callHook("generator:css", "styles.css", output);
|
|
3175
3258
|
return output;
|
|
3176
3259
|
};
|
|
3177
3260
|
|
|
3178
3261
|
// src/artifacts/css/parser-css.ts
|
|
3179
3262
|
var import_logger2 = require("@pandacss/logger");
|
|
3180
3263
|
var import_func = require("lil-fp/func");
|
|
3181
|
-
var
|
|
3264
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
3182
3265
|
var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
3183
3266
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3184
3267
|
(0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3208,7 +3291,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3208
3291
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3209
3292
|
if (!recipeConfig)
|
|
3210
3293
|
continue;
|
|
3211
|
-
(0,
|
|
3294
|
+
(0, import_ts_pattern9.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3212
3295
|
recipe.data.forEach((data) => {
|
|
3213
3296
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3214
3297
|
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3227,7 +3310,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3227
3310
|
result2.pattern.forEach((patternSet, name) => {
|
|
3228
3311
|
try {
|
|
3229
3312
|
for (const pattern of patternSet) {
|
|
3230
|
-
(0,
|
|
3313
|
+
(0, import_ts_pattern9.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern9.P.string }, ({ name: jsxName }) => {
|
|
3231
3314
|
pattern.data.forEach((data) => {
|
|
3232
3315
|
const fnName = patterns.find(jsxName);
|
|
3233
3316
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -3248,7 +3331,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3248
3331
|
(0, import_func.tryCatch)(
|
|
3249
3332
|
({ sheet, result: result2, config: { minify, optimize } }) => {
|
|
3250
3333
|
const css2 = !result2.isEmpty() ? sheet.toCss({ minify, optimize }) : void 0;
|
|
3251
|
-
ctx.hooks.callHook("parser:css", result2.filePath ?? "", css2);
|
|
3334
|
+
void ctx.hooks.callHook("parser:css", result2.filePath ?? "", css2);
|
|
3252
3335
|
return css2;
|
|
3253
3336
|
},
|
|
3254
3337
|
(err) => {
|