@pandacss/generator 0.0.0-dev-20230602184758 → 0.0.0-dev-20230603163843
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 +234 -81
- package/dist/index.mjs +234 -81
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -128,7 +128,7 @@ var import_lil_fp3 = require("lil-fp");
|
|
|
128
128
|
|
|
129
129
|
// src/artifacts/index.ts
|
|
130
130
|
var import_shared4 = require("@pandacss/shared");
|
|
131
|
-
var
|
|
131
|
+
var import_outdent29 = __toESM(require("outdent"));
|
|
132
132
|
|
|
133
133
|
// src/artifacts/css/global-css.ts
|
|
134
134
|
var generateGlobalCss = (ctx) => {
|
|
@@ -846,6 +846,7 @@ transform`)}
|
|
|
846
846
|
var import_shared2 = require("@pandacss/shared");
|
|
847
847
|
var import_outdent8 = require("outdent");
|
|
848
848
|
var stringify3 = (value) => JSON.stringify(value, null, 2);
|
|
849
|
+
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
849
850
|
function generateRecipes(ctx) {
|
|
850
851
|
const {
|
|
851
852
|
recipes,
|
|
@@ -908,21 +909,34 @@ function generateRecipes(ctx) {
|
|
|
908
909
|
${ctx.file.import("splitProps", "../helpers")}
|
|
909
910
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
910
911
|
|
|
911
|
-
|
|
912
|
+
const ${name}Fn = createRecipe('${name}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
|
|
912
913
|
compoundVariants ?? []
|
|
913
914
|
)})
|
|
914
915
|
|
|
915
|
-
${name}.variants = ${stringify3(variantKeyMap)}
|
|
916
|
-
|
|
917
916
|
const variantKeys = ${stringify3(Object.keys(variantKeyMap))}
|
|
918
|
-
|
|
917
|
+
|
|
918
|
+
function splitVariantProps(props) {
|
|
919
|
+
return splitProps(props, variantKeys)
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export const ${name} = Object.assign(${name}Fn, {
|
|
923
|
+
__recipe__: true,
|
|
924
|
+
variantKeys,
|
|
925
|
+
variantMap: ${stringify3(variantKeyMap)},
|
|
926
|
+
splitVariantProps,
|
|
927
|
+
})
|
|
919
928
|
`,
|
|
920
929
|
dts: import_outdent8.outdent`
|
|
921
930
|
import type { ConditionalValue } from '../types'
|
|
922
931
|
import type { Pretty } from '../types/helpers'
|
|
923
932
|
|
|
924
933
|
type ${upperName}Variant = {
|
|
925
|
-
${Object.keys(variantKeyMap).map((key) =>
|
|
934
|
+
${Object.keys(variantKeyMap).map((key) => {
|
|
935
|
+
const values = variantKeyMap[key];
|
|
936
|
+
if (values.every(isBooleanValue))
|
|
937
|
+
return `${key}: boolean`;
|
|
938
|
+
return `${key}: ${(0, import_shared2.unionType)(values)}`;
|
|
939
|
+
}).join("\n")}
|
|
926
940
|
}
|
|
927
941
|
|
|
928
942
|
type ${upperName}VariantMap = {
|
|
@@ -934,8 +948,10 @@ function generateRecipes(ctx) {
|
|
|
934
948
|
}
|
|
935
949
|
|
|
936
950
|
interface ${upperName}Recipe {
|
|
937
|
-
|
|
938
|
-
|
|
951
|
+
__type: ${upperName}VariantProps
|
|
952
|
+
(props?: ${upperName}VariantProps): string
|
|
953
|
+
variantMap: ${upperName}VariantMap
|
|
954
|
+
variantKeys: Array<keyof ${upperName}Variant>
|
|
939
955
|
splitVariantProps<Props extends ${upperName}VariantProps>(props: Props): [${upperName}VariantProps, Pretty<Omit<Props, keyof ${upperName}VariantProps>>]
|
|
940
956
|
}
|
|
941
957
|
|
|
@@ -999,7 +1015,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
999
1015
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1000
1016
|
|
|
1001
1017
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1002
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1018
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1003
1019
|
|
|
1004
1020
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1005
1021
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -1008,13 +1024,21 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1008
1024
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1009
1025
|
}, [restProps])
|
|
1010
1026
|
|
|
1011
|
-
function
|
|
1027
|
+
function recipeClass() {
|
|
1028
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1029
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1030
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
function cvaClass() {
|
|
1012
1034
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1013
1035
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1014
1036
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1015
|
-
return cx(css(styles), elementProps.className)
|
|
1037
|
+
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1016
1038
|
}
|
|
1017
1039
|
|
|
1040
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1041
|
+
|
|
1018
1042
|
return h(Element, {
|
|
1019
1043
|
...elementProps,
|
|
1020
1044
|
...normalizeHTMLProps(htmlProps),
|
|
@@ -1104,9 +1128,9 @@ import type { ${upperName} } from '../types/jsx'
|
|
|
1104
1128
|
export declare const ${factoryName}: ${upperName}
|
|
1105
1129
|
`,
|
|
1106
1130
|
jsxType: import_outdent12.outdent`
|
|
1107
|
-
import type {
|
|
1108
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1109
|
-
import type { RecipeDefinition,
|
|
1131
|
+
import type { ComponentProps, JSX } from 'preact'
|
|
1132
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1133
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1110
1134
|
|
|
1111
1135
|
type ElementType = keyof JSX.IntrinsicElements
|
|
1112
1136
|
|
|
@@ -1117,9 +1141,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1117
1141
|
displayName?: string
|
|
1118
1142
|
}
|
|
1119
1143
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1144
|
+
type RecipeFn = { __type: any }
|
|
1145
|
+
|
|
1146
|
+
interface JsxFactory {
|
|
1147
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1148
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1149
|
+
T,
|
|
1150
|
+
RecipeSelection<P>
|
|
1151
|
+
>
|
|
1152
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1156
|
+
|
|
1157
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1123
1158
|
|
|
1124
1159
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1125
1160
|
`
|
|
@@ -1138,7 +1173,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1138
1173
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1139
1174
|
|
|
1140
1175
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1141
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1176
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1142
1177
|
|
|
1143
1178
|
const ${componentName} = function ${componentName}(props) {
|
|
1144
1179
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -1146,18 +1181,25 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1146
1181
|
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1147
1182
|
splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1148
1183
|
|
|
1184
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1149
1185
|
|
|
1150
|
-
function
|
|
1151
|
-
const
|
|
1186
|
+
function recipeClass() {
|
|
1187
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1188
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.class)
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function cvaClass() {
|
|
1152
1192
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1153
1193
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1154
|
-
return cx(css(styles), elementProps.
|
|
1194
|
+
return cx(css(styles), elementProps.class)
|
|
1155
1195
|
}
|
|
1156
1196
|
|
|
1197
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1198
|
+
|
|
1157
1199
|
return h(Element, {
|
|
1158
1200
|
...elementProps,
|
|
1159
1201
|
...normalizeHTMLProps(htmlProps),
|
|
1160
|
-
|
|
1202
|
+
class: classes(),
|
|
1161
1203
|
})
|
|
1162
1204
|
}
|
|
1163
1205
|
|
|
@@ -1247,8 +1289,8 @@ export declare const ${factoryName}: ${upperName}
|
|
|
1247
1289
|
`,
|
|
1248
1290
|
jsxType: import_outdent15.outdent`
|
|
1249
1291
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1250
|
-
import type {
|
|
1251
|
-
import type { RecipeDefinition,
|
|
1292
|
+
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1293
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1252
1294
|
|
|
1253
1295
|
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
1254
1296
|
|
|
@@ -1278,9 +1320,20 @@ type Assign<T, U> = {
|
|
|
1278
1320
|
|
|
1279
1321
|
export type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionComponent<Assign<ComponentProps<T>, _Assign<JsxStyleProps, P>>>
|
|
1280
1322
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1323
|
+
type RecipeFn = { __type: any }
|
|
1324
|
+
|
|
1325
|
+
interface JsxFactory {
|
|
1326
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1327
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1328
|
+
T,
|
|
1329
|
+
RecipeSelection<P>
|
|
1330
|
+
>
|
|
1331
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1335
|
+
|
|
1336
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1284
1337
|
|
|
1285
1338
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1286
1339
|
`
|
|
@@ -1299,7 +1352,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1299
1352
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1300
1353
|
|
|
1301
1354
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1302
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1355
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1303
1356
|
|
|
1304
1357
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1305
1358
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -1307,14 +1360,22 @@ function generateReactJsxFactory(ctx) {
|
|
|
1307
1360
|
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1308
1361
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1309
1362
|
}, [restProps])
|
|
1310
|
-
|
|
1311
|
-
function
|
|
1363
|
+
|
|
1364
|
+
function recipeClass() {
|
|
1365
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1366
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1367
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function cvaClass() {
|
|
1312
1371
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1313
1372
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1314
1373
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1315
1374
|
return cx(css(styles), elementProps.className)
|
|
1316
1375
|
}
|
|
1317
1376
|
|
|
1377
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1378
|
+
|
|
1318
1379
|
return createElement(Element, {
|
|
1319
1380
|
ref,
|
|
1320
1381
|
...elementProps,
|
|
@@ -1404,9 +1465,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
1404
1465
|
export declare const ${factoryName}: ${upperName}
|
|
1405
1466
|
`,
|
|
1406
1467
|
jsxType: import_outdent18.outdent`
|
|
1407
|
-
import type {
|
|
1408
|
-
import type { JsxStyleProps, JsxHTMLProps
|
|
1409
|
-
import type { RecipeDefinition,
|
|
1468
|
+
import type { ComponentProps, ElementType } from 'react'
|
|
1469
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1470
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1410
1471
|
|
|
1411
1472
|
type Dict = Record<string, unknown>
|
|
1412
1473
|
|
|
@@ -1415,9 +1476,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1415
1476
|
displayName?: string
|
|
1416
1477
|
}
|
|
1417
1478
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1479
|
+
type RecipeFn = { __type: any }
|
|
1480
|
+
|
|
1481
|
+
interface JsxFactory {
|
|
1482
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1483
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1484
|
+
T,
|
|
1485
|
+
RecipeSelection<P>
|
|
1486
|
+
>
|
|
1487
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1491
|
+
|
|
1492
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1421
1493
|
|
|
1422
1494
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1423
1495
|
`
|
|
@@ -1450,14 +1522,22 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1450
1522
|
allCssProperties,
|
|
1451
1523
|
normalizeHTMLProps.keys
|
|
1452
1524
|
)
|
|
1453
|
-
|
|
1454
|
-
|
|
1525
|
+
|
|
1526
|
+
function recipeClass() {
|
|
1527
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1528
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1529
|
+
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
function cvaClass() {
|
|
1455
1533
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1456
1534
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1457
1535
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1458
1536
|
return cx(css(styles), localProps.class)
|
|
1459
1537
|
}
|
|
1460
1538
|
|
|
1539
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1540
|
+
|
|
1461
1541
|
return createComponent(
|
|
1462
1542
|
Dynamic,
|
|
1463
1543
|
mergeProps(
|
|
@@ -1553,9 +1633,9 @@ import type { ${upperName} } from '../types/jsx'
|
|
|
1553
1633
|
export declare const ${factoryName}: ${upperName}
|
|
1554
1634
|
`,
|
|
1555
1635
|
jsxType: import_outdent21.outdent`
|
|
1556
|
-
import type {
|
|
1557
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1558
|
-
import type { RecipeDefinition,
|
|
1636
|
+
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1637
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1638
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1559
1639
|
|
|
1560
1640
|
type Dict = Record<string, unknown>
|
|
1561
1641
|
|
|
@@ -1566,9 +1646,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1566
1646
|
displayName?: string
|
|
1567
1647
|
}
|
|
1568
1648
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1649
|
+
type RecipeFn = { __type: any }
|
|
1650
|
+
|
|
1651
|
+
interface JsxFactory {
|
|
1652
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1653
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1654
|
+
T,
|
|
1655
|
+
RecipeSelection<P>
|
|
1656
|
+
>
|
|
1657
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1661
|
+
|
|
1662
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1572
1663
|
|
|
1573
1664
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1574
1665
|
`
|
|
@@ -1587,7 +1678,7 @@ function generateVueJsxFactory(ctx) {
|
|
|
1587
1678
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1588
1679
|
|
|
1589
1680
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1590
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1681
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1591
1682
|
|
|
1592
1683
|
return defineComponent({
|
|
1593
1684
|
name: \`${factoryName}.\${Dynamic}\`,
|
|
@@ -1597,17 +1688,26 @@ function generateVueJsxFactory(ctx) {
|
|
|
1597
1688
|
const splittedProps = computed(() => {
|
|
1598
1689
|
return splitProps(attrs, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1599
1690
|
})
|
|
1600
|
-
|
|
1601
|
-
const
|
|
1691
|
+
|
|
1692
|
+
const recipeClass = computed(() => {
|
|
1693
|
+
const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
|
|
1694
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1695
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1696
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1697
|
+
})
|
|
1698
|
+
|
|
1699
|
+
const cvaClass = computed(() => {
|
|
1602
1700
|
const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
|
|
1603
1701
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
return cx(css(styles), elementProps.className)
|
|
1702
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1703
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1607
1704
|
})
|
|
1705
|
+
|
|
1706
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1608
1707
|
|
|
1609
1708
|
return () => {
|
|
1610
1709
|
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
1710
|
+
|
|
1611
1711
|
return h(
|
|
1612
1712
|
props.as,
|
|
1613
1713
|
{
|
|
@@ -1644,19 +1744,61 @@ function generateVueJsxFactory(ctx) {
|
|
|
1644
1744
|
};
|
|
1645
1745
|
}
|
|
1646
1746
|
|
|
1647
|
-
// src/artifacts/vue-jsx/
|
|
1747
|
+
// src/artifacts/vue-jsx/pattern.ts
|
|
1648
1748
|
var import_outdent23 = require("outdent");
|
|
1749
|
+
function generateVueJsxPattern(ctx) {
|
|
1750
|
+
const { typeName, factoryName } = ctx.jsx;
|
|
1751
|
+
return ctx.patterns.details.map((pattern) => {
|
|
1752
|
+
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
1753
|
+
const { description, jsxElement = "div" } = pattern.config;
|
|
1754
|
+
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
1755
|
+
return {
|
|
1756
|
+
name: dashName,
|
|
1757
|
+
js: import_outdent23.outdent`
|
|
1758
|
+
import { defineComponent, h, computed } from 'vue'
|
|
1759
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1760
|
+
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1761
|
+
|
|
1762
|
+
export const ${jsxName} = defineComponent({
|
|
1763
|
+
name: '${jsxName}',
|
|
1764
|
+
inheritAttrs: false,
|
|
1765
|
+
props: [${propList}],
|
|
1766
|
+
setup(props, { attrs, slots }) {
|
|
1767
|
+
const styleProps = computed(() => ${styleFnName}(props))
|
|
1768
|
+
return () => {
|
|
1769
|
+
const computedProps = { ...styleProps.value, ...attrs }
|
|
1770
|
+
return h(${factoryName}.${jsxElement}, computedProps, slots)
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
})
|
|
1774
|
+
`,
|
|
1775
|
+
dts: import_outdent23.outdent`
|
|
1776
|
+
import { FunctionalComponent } from 'vue'
|
|
1777
|
+
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1778
|
+
import { ${typeName} } from '../types/jsx'
|
|
1779
|
+
|
|
1780
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1781
|
+
|
|
1782
|
+
${description ? `/** ${description} */` : ""}
|
|
1783
|
+
export declare const ${jsxName}: FunctionalComponent<${upperName}Props>
|
|
1784
|
+
`
|
|
1785
|
+
};
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
// src/artifacts/vue-jsx/types.ts
|
|
1790
|
+
var import_outdent24 = require("outdent");
|
|
1649
1791
|
function generateVueJsxTypes(ctx) {
|
|
1650
1792
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1651
1793
|
return {
|
|
1652
|
-
jsxFactory:
|
|
1794
|
+
jsxFactory: import_outdent24.outdent`
|
|
1653
1795
|
import { ${upperName} } from '../types/jsx'
|
|
1654
1796
|
export declare const ${factoryName}: ${upperName}
|
|
1655
1797
|
`,
|
|
1656
|
-
jsxType:
|
|
1798
|
+
jsxType: import_outdent24.outdent`
|
|
1657
1799
|
import type { Component, FunctionalComponent } from 'vue'
|
|
1658
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1659
|
-
import type { RecipeDefinition,
|
|
1800
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1801
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1660
1802
|
|
|
1661
1803
|
type IntrinsicElement =
|
|
1662
1804
|
| 'a'
|
|
@@ -1789,9 +1931,20 @@ type IntrinsicElement =
|
|
|
1789
1931
|
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
1790
1932
|
>
|
|
1791
1933
|
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1934
|
+
type RecipeFn = { __type: any }
|
|
1935
|
+
|
|
1936
|
+
interface JsxFactory {
|
|
1937
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1938
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1939
|
+
T,
|
|
1940
|
+
RecipeSelection<P>
|
|
1941
|
+
>
|
|
1942
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1946
|
+
|
|
1947
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1795
1948
|
|
|
1796
1949
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1797
1950
|
`
|
|
@@ -1827,7 +1980,7 @@ var patternMap = {
|
|
|
1827
1980
|
react: generateReactJsxPattern,
|
|
1828
1981
|
solid: generateSolidJsxPattern,
|
|
1829
1982
|
preact: generatePreactJsxPattern,
|
|
1830
|
-
vue:
|
|
1983
|
+
vue: generateVueJsxPattern,
|
|
1831
1984
|
qwik: generateQwikJsxPattern
|
|
1832
1985
|
};
|
|
1833
1986
|
function generateJsxPatterns(ctx) {
|
|
@@ -1893,7 +2046,7 @@ var composition_d_ts_default = {
|
|
|
1893
2046
|
|
|
1894
2047
|
// src/artifacts/generated/recipe.d.ts.json
|
|
1895
2048
|
var recipe_d_ts_default = {
|
|
1896
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n
|
|
2049
|
+
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<Omit<Props, keyof RecipeVariantRecord>>]\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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 type 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\nexport type RecipeConfig<T> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\n /**\n * The name of the recipe.\n */\n name: 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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
|
|
1897
2050
|
};
|
|
1898
2051
|
|
|
1899
2052
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -1925,9 +2078,9 @@ function getGeneratedTypes() {
|
|
|
1925
2078
|
}
|
|
1926
2079
|
|
|
1927
2080
|
// src/artifacts/types/main.ts
|
|
1928
|
-
var
|
|
2081
|
+
var import_outdent25 = require("outdent");
|
|
1929
2082
|
var generateTypesEntry = () => ({
|
|
1930
|
-
global:
|
|
2083
|
+
global: import_outdent25.outdent`
|
|
1931
2084
|
import { AnyRecipeConfig, RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1932
2085
|
import { Parts } from './parts'
|
|
1933
2086
|
import { AnyPatternConfig, PatternConfig } from './pattern'
|
|
@@ -1944,19 +2097,19 @@ var generateTypesEntry = () => ({
|
|
|
1944
2097
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>;
|
|
1945
2098
|
}
|
|
1946
2099
|
`,
|
|
1947
|
-
index:
|
|
2100
|
+
index: import_outdent25.outdent`
|
|
1948
2101
|
import './global'
|
|
1949
2102
|
export { ConditionalValue } from './conditions'
|
|
1950
2103
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1951
2104
|
|
|
1952
2105
|
`,
|
|
1953
|
-
helpers:
|
|
2106
|
+
helpers: import_outdent25.outdent`
|
|
1954
2107
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
1955
2108
|
`
|
|
1956
2109
|
});
|
|
1957
2110
|
|
|
1958
2111
|
// src/artifacts/types/prop-types.ts
|
|
1959
|
-
var
|
|
2112
|
+
var import_outdent26 = require("outdent");
|
|
1960
2113
|
function generatePropTypes(ctx) {
|
|
1961
2114
|
const {
|
|
1962
2115
|
config: { strictTokens },
|
|
@@ -1964,7 +2117,7 @@ function generatePropTypes(ctx) {
|
|
|
1964
2117
|
} = ctx;
|
|
1965
2118
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
1966
2119
|
const result = [
|
|
1967
|
-
|
|
2120
|
+
import_outdent26.outdent`
|
|
1968
2121
|
import type { ConditionalValue } from './conditions';
|
|
1969
2122
|
import type { CssProperties } from './system-types'
|
|
1970
2123
|
import type { Tokens } from '../tokens'
|
|
@@ -1987,7 +2140,7 @@ function generatePropTypes(ctx) {
|
|
|
1987
2140
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1988
2141
|
});
|
|
1989
2142
|
result.push("}");
|
|
1990
|
-
return
|
|
2143
|
+
return import_outdent26.outdent`
|
|
1991
2144
|
${result.join("\n")}
|
|
1992
2145
|
|
|
1993
2146
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2000,10 +2153,10 @@ function generatePropTypes(ctx) {
|
|
|
2000
2153
|
|
|
2001
2154
|
// src/artifacts/types/style-props.ts
|
|
2002
2155
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
2003
|
-
var
|
|
2156
|
+
var import_outdent27 = __toESM(require("outdent"));
|
|
2004
2157
|
function generateStyleProps(ctx) {
|
|
2005
2158
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()));
|
|
2006
|
-
return
|
|
2159
|
+
return import_outdent27.default`
|
|
2007
2160
|
import { ConditionalValue } from './conditions'
|
|
2008
2161
|
import { PropertyValue } from './prop-type'
|
|
2009
2162
|
import { Token } from '../tokens'
|
|
@@ -2020,7 +2173,7 @@ function generateStyleProps(ctx) {
|
|
|
2020
2173
|
|
|
2021
2174
|
// src/artifacts/types/token-types.ts
|
|
2022
2175
|
var import_shared3 = require("@pandacss/shared");
|
|
2023
|
-
var
|
|
2176
|
+
var import_outdent28 = require("outdent");
|
|
2024
2177
|
var import_pluralize = __toESM(require("pluralize"));
|
|
2025
2178
|
var categories = [
|
|
2026
2179
|
"zIndex",
|
|
@@ -2065,7 +2218,7 @@ function generateTokenTypes(ctx) {
|
|
|
2065
2218
|
result.add("} & { [token: string]: never }");
|
|
2066
2219
|
set.add(Array.from(result).join("\n"));
|
|
2067
2220
|
set.add(`export type TokenCategory = ${(0, import_shared3.unionType)(categories)}`);
|
|
2068
|
-
return
|
|
2221
|
+
return import_outdent28.outdent.string(Array.from(set).join("\n\n"));
|
|
2069
2222
|
}
|
|
2070
2223
|
|
|
2071
2224
|
// src/artifacts/index.ts
|
|
@@ -2160,8 +2313,8 @@ function setupRecipes(ctx) {
|
|
|
2160
2313
|
return;
|
|
2161
2314
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2162
2315
|
const index = {
|
|
2163
|
-
js:
|
|
2164
|
-
dts:
|
|
2316
|
+
js: import_outdent29.default.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2317
|
+
dts: import_outdent29.default.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2165
2318
|
};
|
|
2166
2319
|
return {
|
|
2167
2320
|
dir: ctx.paths.recipe,
|
|
@@ -2178,8 +2331,8 @@ function setupPatterns(ctx) {
|
|
|
2178
2331
|
if (!files)
|
|
2179
2332
|
return;
|
|
2180
2333
|
const index = {
|
|
2181
|
-
js:
|
|
2182
|
-
dts:
|
|
2334
|
+
js: import_outdent29.default.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2335
|
+
dts: import_outdent29.default.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2183
2336
|
};
|
|
2184
2337
|
return {
|
|
2185
2338
|
dir: ctx.paths.pattern,
|
|
@@ -2199,13 +2352,13 @@ function setupJsx(ctx) {
|
|
|
2199
2352
|
const factory = generateJsxFactory(ctx);
|
|
2200
2353
|
const patterns = generateJsxPatterns(ctx);
|
|
2201
2354
|
const index = {
|
|
2202
|
-
js:
|
|
2355
|
+
js: import_outdent29.default`
|
|
2203
2356
|
${ctx.file.export("./factory")}
|
|
2204
|
-
${
|
|
2357
|
+
${import_outdent29.default.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
2205
2358
|
`,
|
|
2206
|
-
dts:
|
|
2359
|
+
dts: import_outdent29.default`
|
|
2207
2360
|
export * from './factory'
|
|
2208
|
-
${
|
|
2361
|
+
${import_outdent29.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
2209
2362
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
2210
2363
|
`
|
|
2211
2364
|
};
|
|
@@ -2224,12 +2377,12 @@ function setupJsx(ctx) {
|
|
|
2224
2377
|
}
|
|
2225
2378
|
function setupCssIndex(ctx) {
|
|
2226
2379
|
const index = {
|
|
2227
|
-
js:
|
|
2380
|
+
js: import_outdent29.default`
|
|
2228
2381
|
${ctx.file.export("./css")}
|
|
2229
2382
|
${ctx.file.export("./cx")}
|
|
2230
2383
|
${ctx.file.export("./cva")}
|
|
2231
2384
|
`,
|
|
2232
|
-
dts:
|
|
2385
|
+
dts: import_outdent29.default`
|
|
2233
2386
|
export * from './css'
|
|
2234
2387
|
export * from './cx'
|
|
2235
2388
|
export * from './cva'
|
package/dist/index.mjs
CHANGED
|
@@ -97,7 +97,7 @@ import { Obj as Obj3, pipe as pipe4 } from "lil-fp";
|
|
|
97
97
|
|
|
98
98
|
// src/artifacts/index.ts
|
|
99
99
|
import { isObject } from "@pandacss/shared";
|
|
100
|
-
import
|
|
100
|
+
import outdent29 from "outdent";
|
|
101
101
|
|
|
102
102
|
// src/artifacts/css/global-css.ts
|
|
103
103
|
var generateGlobalCss = (ctx) => {
|
|
@@ -815,6 +815,7 @@ transform`)}
|
|
|
815
815
|
import { unionType as unionType2 } from "@pandacss/shared";
|
|
816
816
|
import { outdent as outdent8 } from "outdent";
|
|
817
817
|
var stringify3 = (value) => JSON.stringify(value, null, 2);
|
|
818
|
+
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
818
819
|
function generateRecipes(ctx) {
|
|
819
820
|
const {
|
|
820
821
|
recipes,
|
|
@@ -877,21 +878,34 @@ function generateRecipes(ctx) {
|
|
|
877
878
|
${ctx.file.import("splitProps", "../helpers")}
|
|
878
879
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
879
880
|
|
|
880
|
-
|
|
881
|
+
const ${name}Fn = createRecipe('${name}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
|
|
881
882
|
compoundVariants ?? []
|
|
882
883
|
)})
|
|
883
884
|
|
|
884
|
-
${name}.variants = ${stringify3(variantKeyMap)}
|
|
885
|
-
|
|
886
885
|
const variantKeys = ${stringify3(Object.keys(variantKeyMap))}
|
|
887
|
-
|
|
886
|
+
|
|
887
|
+
function splitVariantProps(props) {
|
|
888
|
+
return splitProps(props, variantKeys)
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
export const ${name} = Object.assign(${name}Fn, {
|
|
892
|
+
__recipe__: true,
|
|
893
|
+
variantKeys,
|
|
894
|
+
variantMap: ${stringify3(variantKeyMap)},
|
|
895
|
+
splitVariantProps,
|
|
896
|
+
})
|
|
888
897
|
`,
|
|
889
898
|
dts: outdent8`
|
|
890
899
|
import type { ConditionalValue } from '../types'
|
|
891
900
|
import type { Pretty } from '../types/helpers'
|
|
892
901
|
|
|
893
902
|
type ${upperName}Variant = {
|
|
894
|
-
${Object.keys(variantKeyMap).map((key) =>
|
|
903
|
+
${Object.keys(variantKeyMap).map((key) => {
|
|
904
|
+
const values = variantKeyMap[key];
|
|
905
|
+
if (values.every(isBooleanValue))
|
|
906
|
+
return `${key}: boolean`;
|
|
907
|
+
return `${key}: ${unionType2(values)}`;
|
|
908
|
+
}).join("\n")}
|
|
895
909
|
}
|
|
896
910
|
|
|
897
911
|
type ${upperName}VariantMap = {
|
|
@@ -903,8 +917,10 @@ function generateRecipes(ctx) {
|
|
|
903
917
|
}
|
|
904
918
|
|
|
905
919
|
interface ${upperName}Recipe {
|
|
906
|
-
|
|
907
|
-
|
|
920
|
+
__type: ${upperName}VariantProps
|
|
921
|
+
(props?: ${upperName}VariantProps): string
|
|
922
|
+
variantMap: ${upperName}VariantMap
|
|
923
|
+
variantKeys: Array<keyof ${upperName}Variant>
|
|
908
924
|
splitVariantProps<Props extends ${upperName}VariantProps>(props: Props): [${upperName}VariantProps, Pretty<Omit<Props, keyof ${upperName}VariantProps>>]
|
|
909
925
|
}
|
|
910
926
|
|
|
@@ -968,7 +984,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
968
984
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
969
985
|
|
|
970
986
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
971
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
987
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
972
988
|
|
|
973
989
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
974
990
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -977,13 +993,21 @@ function generatePreactJsxFactory(ctx) {
|
|
|
977
993
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
978
994
|
}, [restProps])
|
|
979
995
|
|
|
980
|
-
function
|
|
996
|
+
function recipeClass() {
|
|
997
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
998
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
999
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function cvaClass() {
|
|
981
1003
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
982
1004
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
983
1005
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
984
|
-
return cx(css(styles), elementProps.className)
|
|
1006
|
+
return cx(css(styles), elementProps.className, elementProps.class)
|
|
985
1007
|
}
|
|
986
1008
|
|
|
1009
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1010
|
+
|
|
987
1011
|
return h(Element, {
|
|
988
1012
|
...elementProps,
|
|
989
1013
|
...normalizeHTMLProps(htmlProps),
|
|
@@ -1073,9 +1097,9 @@ import type { ${upperName} } from '../types/jsx'
|
|
|
1073
1097
|
export declare const ${factoryName}: ${upperName}
|
|
1074
1098
|
`,
|
|
1075
1099
|
jsxType: outdent12`
|
|
1076
|
-
import type {
|
|
1077
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1078
|
-
import type { RecipeDefinition,
|
|
1100
|
+
import type { ComponentProps, JSX } from 'preact'
|
|
1101
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1102
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1079
1103
|
|
|
1080
1104
|
type ElementType = keyof JSX.IntrinsicElements
|
|
1081
1105
|
|
|
@@ -1086,9 +1110,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1086
1110
|
displayName?: string
|
|
1087
1111
|
}
|
|
1088
1112
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1113
|
+
type RecipeFn = { __type: any }
|
|
1114
|
+
|
|
1115
|
+
interface JsxFactory {
|
|
1116
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1117
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1118
|
+
T,
|
|
1119
|
+
RecipeSelection<P>
|
|
1120
|
+
>
|
|
1121
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1125
|
+
|
|
1126
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1092
1127
|
|
|
1093
1128
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1094
1129
|
`
|
|
@@ -1107,7 +1142,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1107
1142
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1108
1143
|
|
|
1109
1144
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1110
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1145
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1111
1146
|
|
|
1112
1147
|
const ${componentName} = function ${componentName}(props) {
|
|
1113
1148
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -1115,18 +1150,25 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1115
1150
|
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1116
1151
|
splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1117
1152
|
|
|
1153
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1118
1154
|
|
|
1119
|
-
function
|
|
1120
|
-
const
|
|
1155
|
+
function recipeClass() {
|
|
1156
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1157
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.class)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function cvaClass() {
|
|
1121
1161
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1122
1162
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1123
|
-
return cx(css(styles), elementProps.
|
|
1163
|
+
return cx(css(styles), elementProps.class)
|
|
1124
1164
|
}
|
|
1125
1165
|
|
|
1166
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1167
|
+
|
|
1126
1168
|
return h(Element, {
|
|
1127
1169
|
...elementProps,
|
|
1128
1170
|
...normalizeHTMLProps(htmlProps),
|
|
1129
|
-
|
|
1171
|
+
class: classes(),
|
|
1130
1172
|
})
|
|
1131
1173
|
}
|
|
1132
1174
|
|
|
@@ -1216,8 +1258,8 @@ export declare const ${factoryName}: ${upperName}
|
|
|
1216
1258
|
`,
|
|
1217
1259
|
jsxType: outdent15`
|
|
1218
1260
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1219
|
-
import type {
|
|
1220
|
-
import type { RecipeDefinition,
|
|
1261
|
+
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1262
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1221
1263
|
|
|
1222
1264
|
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
1223
1265
|
|
|
@@ -1247,9 +1289,20 @@ type Assign<T, U> = {
|
|
|
1247
1289
|
|
|
1248
1290
|
export type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionComponent<Assign<ComponentProps<T>, _Assign<JsxStyleProps, P>>>
|
|
1249
1291
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1292
|
+
type RecipeFn = { __type: any }
|
|
1293
|
+
|
|
1294
|
+
interface JsxFactory {
|
|
1295
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1296
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1297
|
+
T,
|
|
1298
|
+
RecipeSelection<P>
|
|
1299
|
+
>
|
|
1300
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1304
|
+
|
|
1305
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1253
1306
|
|
|
1254
1307
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1255
1308
|
`
|
|
@@ -1268,7 +1321,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1268
1321
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1269
1322
|
|
|
1270
1323
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1271
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1324
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1272
1325
|
|
|
1273
1326
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1274
1327
|
const { as: Element = Dynamic, ...restProps } = props
|
|
@@ -1276,14 +1329,22 @@ function generateReactJsxFactory(ctx) {
|
|
|
1276
1329
|
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1277
1330
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1278
1331
|
}, [restProps])
|
|
1279
|
-
|
|
1280
|
-
function
|
|
1332
|
+
|
|
1333
|
+
function recipeClass() {
|
|
1334
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1335
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1336
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function cvaClass() {
|
|
1281
1340
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1282
1341
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1283
1342
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1284
1343
|
return cx(css(styles), elementProps.className)
|
|
1285
1344
|
}
|
|
1286
1345
|
|
|
1346
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1347
|
+
|
|
1287
1348
|
return createElement(Element, {
|
|
1288
1349
|
ref,
|
|
1289
1350
|
...elementProps,
|
|
@@ -1373,9 +1434,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
1373
1434
|
export declare const ${factoryName}: ${upperName}
|
|
1374
1435
|
`,
|
|
1375
1436
|
jsxType: outdent18`
|
|
1376
|
-
import type {
|
|
1377
|
-
import type { JsxStyleProps, JsxHTMLProps
|
|
1378
|
-
import type { RecipeDefinition,
|
|
1437
|
+
import type { ComponentProps, ElementType } from 'react'
|
|
1438
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1439
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1379
1440
|
|
|
1380
1441
|
type Dict = Record<string, unknown>
|
|
1381
1442
|
|
|
@@ -1384,9 +1445,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1384
1445
|
displayName?: string
|
|
1385
1446
|
}
|
|
1386
1447
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1448
|
+
type RecipeFn = { __type: any }
|
|
1449
|
+
|
|
1450
|
+
interface JsxFactory {
|
|
1451
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1452
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1453
|
+
T,
|
|
1454
|
+
RecipeSelection<P>
|
|
1455
|
+
>
|
|
1456
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1460
|
+
|
|
1461
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1390
1462
|
|
|
1391
1463
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1392
1464
|
`
|
|
@@ -1419,14 +1491,22 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1419
1491
|
allCssProperties,
|
|
1420
1492
|
normalizeHTMLProps.keys
|
|
1421
1493
|
)
|
|
1422
|
-
|
|
1423
|
-
|
|
1494
|
+
|
|
1495
|
+
function recipeClass() {
|
|
1496
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1497
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1498
|
+
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
function cvaClass() {
|
|
1424
1502
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1425
1503
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1426
1504
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1427
1505
|
return cx(css(styles), localProps.class)
|
|
1428
1506
|
}
|
|
1429
1507
|
|
|
1508
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1509
|
+
|
|
1430
1510
|
return createComponent(
|
|
1431
1511
|
Dynamic,
|
|
1432
1512
|
mergeProps(
|
|
@@ -1522,9 +1602,9 @@ import type { ${upperName} } from '../types/jsx'
|
|
|
1522
1602
|
export declare const ${factoryName}: ${upperName}
|
|
1523
1603
|
`,
|
|
1524
1604
|
jsxType: outdent21`
|
|
1525
|
-
import type {
|
|
1526
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1527
|
-
import type { RecipeDefinition,
|
|
1605
|
+
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1606
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1607
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1528
1608
|
|
|
1529
1609
|
type Dict = Record<string, unknown>
|
|
1530
1610
|
|
|
@@ -1535,9 +1615,20 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1535
1615
|
displayName?: string
|
|
1536
1616
|
}
|
|
1537
1617
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1618
|
+
type RecipeFn = { __type: any }
|
|
1619
|
+
|
|
1620
|
+
interface JsxFactory {
|
|
1621
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1622
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1623
|
+
T,
|
|
1624
|
+
RecipeSelection<P>
|
|
1625
|
+
>
|
|
1626
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1630
|
+
|
|
1631
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1541
1632
|
|
|
1542
1633
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1543
1634
|
`
|
|
@@ -1556,7 +1647,7 @@ function generateVueJsxFactory(ctx) {
|
|
|
1556
1647
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1557
1648
|
|
|
1558
1649
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1559
|
-
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1650
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1560
1651
|
|
|
1561
1652
|
return defineComponent({
|
|
1562
1653
|
name: \`${factoryName}.\${Dynamic}\`,
|
|
@@ -1566,17 +1657,26 @@ function generateVueJsxFactory(ctx) {
|
|
|
1566
1657
|
const splittedProps = computed(() => {
|
|
1567
1658
|
return splitProps(attrs, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1568
1659
|
})
|
|
1569
|
-
|
|
1570
|
-
const
|
|
1660
|
+
|
|
1661
|
+
const recipeClass = computed(() => {
|
|
1571
1662
|
const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
|
|
1572
1663
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
return cx(css(styles), elementProps.className)
|
|
1664
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1665
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1576
1666
|
})
|
|
1667
|
+
|
|
1668
|
+
const cvaClass = computed(() => {
|
|
1669
|
+
const [variantProps, styleProps, _htmlProps, elementProps] = splittedProps.value
|
|
1670
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1671
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1672
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1673
|
+
})
|
|
1674
|
+
|
|
1675
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1577
1676
|
|
|
1578
1677
|
return () => {
|
|
1579
1678
|
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
1679
|
+
|
|
1580
1680
|
return h(
|
|
1581
1681
|
props.as,
|
|
1582
1682
|
{
|
|
@@ -1613,19 +1713,61 @@ function generateVueJsxFactory(ctx) {
|
|
|
1613
1713
|
};
|
|
1614
1714
|
}
|
|
1615
1715
|
|
|
1616
|
-
// src/artifacts/vue-jsx/
|
|
1716
|
+
// src/artifacts/vue-jsx/pattern.ts
|
|
1617
1717
|
import { outdent as outdent23 } from "outdent";
|
|
1718
|
+
function generateVueJsxPattern(ctx) {
|
|
1719
|
+
const { typeName, factoryName } = ctx.jsx;
|
|
1720
|
+
return ctx.patterns.details.map((pattern) => {
|
|
1721
|
+
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
1722
|
+
const { description, jsxElement = "div" } = pattern.config;
|
|
1723
|
+
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
1724
|
+
return {
|
|
1725
|
+
name: dashName,
|
|
1726
|
+
js: outdent23`
|
|
1727
|
+
import { defineComponent, h, computed } from 'vue'
|
|
1728
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1729
|
+
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1730
|
+
|
|
1731
|
+
export const ${jsxName} = defineComponent({
|
|
1732
|
+
name: '${jsxName}',
|
|
1733
|
+
inheritAttrs: false,
|
|
1734
|
+
props: [${propList}],
|
|
1735
|
+
setup(props, { attrs, slots }) {
|
|
1736
|
+
const styleProps = computed(() => ${styleFnName}(props))
|
|
1737
|
+
return () => {
|
|
1738
|
+
const computedProps = { ...styleProps.value, ...attrs }
|
|
1739
|
+
return h(${factoryName}.${jsxElement}, computedProps, slots)
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
})
|
|
1743
|
+
`,
|
|
1744
|
+
dts: outdent23`
|
|
1745
|
+
import { FunctionalComponent } from 'vue'
|
|
1746
|
+
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1747
|
+
import { ${typeName} } from '../types/jsx'
|
|
1748
|
+
|
|
1749
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1750
|
+
|
|
1751
|
+
${description ? `/** ${description} */` : ""}
|
|
1752
|
+
export declare const ${jsxName}: FunctionalComponent<${upperName}Props>
|
|
1753
|
+
`
|
|
1754
|
+
};
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
// src/artifacts/vue-jsx/types.ts
|
|
1759
|
+
import { outdent as outdent24 } from "outdent";
|
|
1618
1760
|
function generateVueJsxTypes(ctx) {
|
|
1619
1761
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1620
1762
|
return {
|
|
1621
|
-
jsxFactory:
|
|
1763
|
+
jsxFactory: outdent24`
|
|
1622
1764
|
import { ${upperName} } from '../types/jsx'
|
|
1623
1765
|
export declare const ${factoryName}: ${upperName}
|
|
1624
1766
|
`,
|
|
1625
|
-
jsxType:
|
|
1767
|
+
jsxType: outdent24`
|
|
1626
1768
|
import type { Component, FunctionalComponent } from 'vue'
|
|
1627
|
-
import type { JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1628
|
-
import type { RecipeDefinition,
|
|
1769
|
+
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1770
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1629
1771
|
|
|
1630
1772
|
type IntrinsicElement =
|
|
1631
1773
|
| 'a'
|
|
@@ -1758,9 +1900,20 @@ type IntrinsicElement =
|
|
|
1758
1900
|
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
1759
1901
|
>
|
|
1760
1902
|
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1903
|
+
type RecipeFn = { __type: any }
|
|
1904
|
+
|
|
1905
|
+
interface JsxFactory {
|
|
1906
|
+
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1907
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1908
|
+
T,
|
|
1909
|
+
RecipeSelection<P>
|
|
1910
|
+
>
|
|
1911
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1915
|
+
|
|
1916
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1764
1917
|
|
|
1765
1918
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1766
1919
|
`
|
|
@@ -1796,7 +1949,7 @@ var patternMap = {
|
|
|
1796
1949
|
react: generateReactJsxPattern,
|
|
1797
1950
|
solid: generateSolidJsxPattern,
|
|
1798
1951
|
preact: generatePreactJsxPattern,
|
|
1799
|
-
vue:
|
|
1952
|
+
vue: generateVueJsxPattern,
|
|
1800
1953
|
qwik: generateQwikJsxPattern
|
|
1801
1954
|
};
|
|
1802
1955
|
function generateJsxPatterns(ctx) {
|
|
@@ -1862,7 +2015,7 @@ var composition_d_ts_default = {
|
|
|
1862
2015
|
|
|
1863
2016
|
// src/artifacts/generated/recipe.d.ts.json
|
|
1864
2017
|
var recipe_d_ts_default = {
|
|
1865
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n
|
|
2018
|
+
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<string, Record<string, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = {\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<Omit<Props, keyof RecipeVariantRecord>>]\n}\n\nexport type RecipeCompoundSelection<\n T extends RecipeVariantRecord,\n Key extends Exclude<keyof T, 'css'> = Exclude<keyof T, 'css'>,\n> = {\n [K in Key]?: 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 type 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\nexport type RecipeConfig<T> = RecipeDefinition<T extends RecipeVariantRecord ? T : RecipeVariantRecord> & {\n /**\n * The name of the recipe.\n */\n name: 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}\nexport type AnyRecipeConfig = RecipeConfig<RecipeVariantRecord>\n"
|
|
1866
2019
|
};
|
|
1867
2020
|
|
|
1868
2021
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -1894,9 +2047,9 @@ function getGeneratedTypes() {
|
|
|
1894
2047
|
}
|
|
1895
2048
|
|
|
1896
2049
|
// src/artifacts/types/main.ts
|
|
1897
|
-
import { outdent as
|
|
2050
|
+
import { outdent as outdent25 } from "outdent";
|
|
1898
2051
|
var generateTypesEntry = () => ({
|
|
1899
|
-
global:
|
|
2052
|
+
global: outdent25`
|
|
1900
2053
|
import { AnyRecipeConfig, RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1901
2054
|
import { Parts } from './parts'
|
|
1902
2055
|
import { AnyPatternConfig, PatternConfig } from './pattern'
|
|
@@ -1913,19 +2066,19 @@ var generateTypesEntry = () => ({
|
|
|
1913
2066
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>;
|
|
1914
2067
|
}
|
|
1915
2068
|
`,
|
|
1916
|
-
index:
|
|
2069
|
+
index: outdent25`
|
|
1917
2070
|
import './global'
|
|
1918
2071
|
export { ConditionalValue } from './conditions'
|
|
1919
2072
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1920
2073
|
|
|
1921
2074
|
`,
|
|
1922
|
-
helpers:
|
|
2075
|
+
helpers: outdent25`
|
|
1923
2076
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
1924
2077
|
`
|
|
1925
2078
|
});
|
|
1926
2079
|
|
|
1927
2080
|
// src/artifacts/types/prop-types.ts
|
|
1928
|
-
import { outdent as
|
|
2081
|
+
import { outdent as outdent26 } from "outdent";
|
|
1929
2082
|
function generatePropTypes(ctx) {
|
|
1930
2083
|
const {
|
|
1931
2084
|
config: { strictTokens },
|
|
@@ -1933,7 +2086,7 @@ function generatePropTypes(ctx) {
|
|
|
1933
2086
|
} = ctx;
|
|
1934
2087
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
1935
2088
|
const result = [
|
|
1936
|
-
|
|
2089
|
+
outdent26`
|
|
1937
2090
|
import type { ConditionalValue } from './conditions';
|
|
1938
2091
|
import type { CssProperties } from './system-types'
|
|
1939
2092
|
import type { Tokens } from '../tokens'
|
|
@@ -1956,7 +2109,7 @@ function generatePropTypes(ctx) {
|
|
|
1956
2109
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1957
2110
|
});
|
|
1958
2111
|
result.push("}");
|
|
1959
|
-
return
|
|
2112
|
+
return outdent26`
|
|
1960
2113
|
${result.join("\n")}
|
|
1961
2114
|
|
|
1962
2115
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -1969,10 +2122,10 @@ function generatePropTypes(ctx) {
|
|
|
1969
2122
|
|
|
1970
2123
|
// src/artifacts/types/style-props.ts
|
|
1971
2124
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
1972
|
-
import
|
|
2125
|
+
import outdent27 from "outdent";
|
|
1973
2126
|
function generateStyleProps(ctx) {
|
|
1974
2127
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
1975
|
-
return
|
|
2128
|
+
return outdent27`
|
|
1976
2129
|
import { ConditionalValue } from './conditions'
|
|
1977
2130
|
import { PropertyValue } from './prop-type'
|
|
1978
2131
|
import { Token } from '../tokens'
|
|
@@ -1989,7 +2142,7 @@ function generateStyleProps(ctx) {
|
|
|
1989
2142
|
|
|
1990
2143
|
// src/artifacts/types/token-types.ts
|
|
1991
2144
|
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
1992
|
-
import { outdent as
|
|
2145
|
+
import { outdent as outdent28 } from "outdent";
|
|
1993
2146
|
import pluralize from "pluralize";
|
|
1994
2147
|
var categories = [
|
|
1995
2148
|
"zIndex",
|
|
@@ -2034,7 +2187,7 @@ function generateTokenTypes(ctx) {
|
|
|
2034
2187
|
result.add("} & { [token: string]: never }");
|
|
2035
2188
|
set.add(Array.from(result).join("\n"));
|
|
2036
2189
|
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
2037
|
-
return
|
|
2190
|
+
return outdent28.string(Array.from(set).join("\n\n"));
|
|
2038
2191
|
}
|
|
2039
2192
|
|
|
2040
2193
|
// src/artifacts/index.ts
|
|
@@ -2129,8 +2282,8 @@ function setupRecipes(ctx) {
|
|
|
2129
2282
|
return;
|
|
2130
2283
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2131
2284
|
const index = {
|
|
2132
|
-
js:
|
|
2133
|
-
dts:
|
|
2285
|
+
js: outdent29.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2286
|
+
dts: outdent29.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2134
2287
|
};
|
|
2135
2288
|
return {
|
|
2136
2289
|
dir: ctx.paths.recipe,
|
|
@@ -2147,8 +2300,8 @@ function setupPatterns(ctx) {
|
|
|
2147
2300
|
if (!files)
|
|
2148
2301
|
return;
|
|
2149
2302
|
const index = {
|
|
2150
|
-
js:
|
|
2151
|
-
dts:
|
|
2303
|
+
js: outdent29.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2304
|
+
dts: outdent29.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2152
2305
|
};
|
|
2153
2306
|
return {
|
|
2154
2307
|
dir: ctx.paths.pattern,
|
|
@@ -2168,13 +2321,13 @@ function setupJsx(ctx) {
|
|
|
2168
2321
|
const factory = generateJsxFactory(ctx);
|
|
2169
2322
|
const patterns = generateJsxPatterns(ctx);
|
|
2170
2323
|
const index = {
|
|
2171
|
-
js:
|
|
2324
|
+
js: outdent29`
|
|
2172
2325
|
${ctx.file.export("./factory")}
|
|
2173
|
-
${
|
|
2326
|
+
${outdent29.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
2174
2327
|
`,
|
|
2175
|
-
dts:
|
|
2328
|
+
dts: outdent29`
|
|
2176
2329
|
export * from './factory'
|
|
2177
|
-
${
|
|
2330
|
+
${outdent29.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
2178
2331
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
2179
2332
|
`
|
|
2180
2333
|
};
|
|
@@ -2193,12 +2346,12 @@ function setupJsx(ctx) {
|
|
|
2193
2346
|
}
|
|
2194
2347
|
function setupCssIndex(ctx) {
|
|
2195
2348
|
const index = {
|
|
2196
|
-
js:
|
|
2349
|
+
js: outdent29`
|
|
2197
2350
|
${ctx.file.export("./css")}
|
|
2198
2351
|
${ctx.file.export("./cx")}
|
|
2199
2352
|
${ctx.file.export("./cva")}
|
|
2200
2353
|
`,
|
|
2201
|
-
dts:
|
|
2354
|
+
dts: outdent29`
|
|
2202
2355
|
export * from './css'
|
|
2203
2356
|
export * from './cx'
|
|
2204
2357
|
export * from './cva'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230603163843",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"pluralize": "8.0.0",
|
|
21
21
|
"postcss": "8.4.24",
|
|
22
22
|
"ts-pattern": "4.3.0",
|
|
23
|
-
"@pandacss/core": "0.0.0-dev-
|
|
24
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
25
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
26
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
27
|
-
"@pandacss/types": "0.0.0-dev-
|
|
28
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
23
|
+
"@pandacss/core": "0.0.0-dev-20230603163843",
|
|
24
|
+
"@pandacss/logger": "0.0.0-dev-20230603163843",
|
|
25
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230603163843",
|
|
26
|
+
"@pandacss/shared": "0.0.0-dev-20230603163843",
|
|
27
|
+
"@pandacss/types": "0.0.0-dev-20230603163843",
|
|
28
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230603163843"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.29",
|
|
32
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
32
|
+
"@pandacss/fixture": "0.0.0-dev-20230603163843"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"prebuild": "tsx scripts/prebuild.ts",
|