@pandacss/generator 0.0.0-dev-20230210130407 → 0.0.0-dev-20230211113952
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.d.ts +2 -2
- package/dist/index.js +259 -21
- package/dist/index.mjs +259 -21
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare const getEngine: (conf: LoadConfigResult) => {
|
|
|
71
71
|
upperName: string;
|
|
72
72
|
typeName: string;
|
|
73
73
|
componentName: string;
|
|
74
|
-
framework: "solid" | "react" | "preact" | undefined;
|
|
74
|
+
framework: "solid" | "react" | "preact" | "vue" | undefined;
|
|
75
75
|
};
|
|
76
76
|
paths: {
|
|
77
77
|
get: (file?: string | undefined) => string[];
|
|
@@ -151,7 +151,7 @@ declare const createGenerator: (conf: LoadConfigResult) => {
|
|
|
151
151
|
upperName: string;
|
|
152
152
|
typeName: string;
|
|
153
153
|
componentName: string;
|
|
154
|
-
framework: "solid" | "react" | "preact" | undefined;
|
|
154
|
+
framework: "solid" | "react" | "preact" | "vue" | undefined;
|
|
155
155
|
};
|
|
156
156
|
recipes: {
|
|
157
157
|
nodes: {
|
package/dist/index.js
CHANGED
|
@@ -127,7 +127,7 @@ var getMessages = (ctx) => ({
|
|
|
127
127
|
var import_lil_fp4 = require("lil-fp");
|
|
128
128
|
|
|
129
129
|
// src/artifacts/index.ts
|
|
130
|
-
var
|
|
130
|
+
var import_outdent28 = __toESM(require("outdent"));
|
|
131
131
|
|
|
132
132
|
// src/artifacts/css/keyframe-css.ts
|
|
133
133
|
var import_core = require("@pandacss/core");
|
|
@@ -1357,11 +1357,246 @@ export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & J
|
|
|
1357
1357
|
};
|
|
1358
1358
|
}
|
|
1359
1359
|
|
|
1360
|
+
// src/artifacts/vue-jsx/jsx.ts
|
|
1361
|
+
var import_outdent22 = require("outdent");
|
|
1362
|
+
function generateVueJsxFactory(ctx) {
|
|
1363
|
+
const { factoryName } = ctx.jsx;
|
|
1364
|
+
return {
|
|
1365
|
+
js: import_outdent22.outdent`
|
|
1366
|
+
import { defineComponent, h, computed } from 'vue'
|
|
1367
|
+
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1368
|
+
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1369
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1370
|
+
|
|
1371
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
1372
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1373
|
+
|
|
1374
|
+
return defineComponent({
|
|
1375
|
+
name: \`${factoryName}.\${Dynamic}\`,
|
|
1376
|
+
inheritAttrs: false,
|
|
1377
|
+
props: { as: { type: [String, Object], default: Dynamic } },
|
|
1378
|
+
setup(props, { slots, attrs }) {
|
|
1379
|
+
const splittedProps = computed(() => {
|
|
1380
|
+
return splitProps(attrs, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
1381
|
+
})
|
|
1382
|
+
|
|
1383
|
+
const classes = computed(() => {
|
|
1384
|
+
const [styleProps, variantProps, _htmlProps, elementProps] = splittedProps.value
|
|
1385
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1386
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1387
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1388
|
+
return cx(css(styles), elementProps.className)
|
|
1389
|
+
})
|
|
1390
|
+
|
|
1391
|
+
return () => {
|
|
1392
|
+
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
1393
|
+
return h(
|
|
1394
|
+
props.as,
|
|
1395
|
+
{
|
|
1396
|
+
class: classes.value,
|
|
1397
|
+
...elementProps,
|
|
1398
|
+
...normalizeHTMLProps(htmlProps),
|
|
1399
|
+
},
|
|
1400
|
+
slots.default && slots.default(),
|
|
1401
|
+
)
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
})
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
function createJsxFactory() {
|
|
1408
|
+
const cache = new Map()
|
|
1409
|
+
|
|
1410
|
+
return new Proxy(styled, {
|
|
1411
|
+
apply(_, __, args) {
|
|
1412
|
+
return styled(...args)
|
|
1413
|
+
},
|
|
1414
|
+
get(_, el) {
|
|
1415
|
+
if (!cache.has(el)) {
|
|
1416
|
+
cache.set(el, styled(el))
|
|
1417
|
+
}
|
|
1418
|
+
return cache.get(el)
|
|
1419
|
+
},
|
|
1420
|
+
})
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
export const ${factoryName} = createJsxFactory()
|
|
1424
|
+
|
|
1425
|
+
`
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// src/artifacts/vue-jsx/types.ts
|
|
1430
|
+
var import_outdent23 = require("outdent");
|
|
1431
|
+
function generateVueJsxTypes(ctx) {
|
|
1432
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1433
|
+
return {
|
|
1434
|
+
jsxFactory: import_outdent23.outdent`
|
|
1435
|
+
import { ${upperName} } from '../types/jsx'
|
|
1436
|
+
export declare const ${factoryName}: ${upperName}
|
|
1437
|
+
`,
|
|
1438
|
+
jsxType: import_outdent23.outdent`
|
|
1439
|
+
import type { Component, FunctionalComponent } from 'vue'
|
|
1440
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
1441
|
+
import type { RecipeDefinition, RecipeRuntimeFn, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1442
|
+
|
|
1443
|
+
type IntrinsicElement =
|
|
1444
|
+
| 'a'
|
|
1445
|
+
| 'abbr'
|
|
1446
|
+
| 'address'
|
|
1447
|
+
| 'area'
|
|
1448
|
+
| 'article'
|
|
1449
|
+
| 'aside'
|
|
1450
|
+
| 'audio'
|
|
1451
|
+
| 'b'
|
|
1452
|
+
| 'base'
|
|
1453
|
+
| 'bdi'
|
|
1454
|
+
| 'bdo'
|
|
1455
|
+
| 'blockquote'
|
|
1456
|
+
| 'body'
|
|
1457
|
+
| 'br'
|
|
1458
|
+
| 'button'
|
|
1459
|
+
| 'canvas'
|
|
1460
|
+
| 'caption'
|
|
1461
|
+
| 'cite'
|
|
1462
|
+
| 'code'
|
|
1463
|
+
| 'col'
|
|
1464
|
+
| 'colgroup'
|
|
1465
|
+
| 'data'
|
|
1466
|
+
| 'datalist'
|
|
1467
|
+
| 'dd'
|
|
1468
|
+
| 'del'
|
|
1469
|
+
| 'details'
|
|
1470
|
+
| 'dfn'
|
|
1471
|
+
| 'dialog'
|
|
1472
|
+
| 'div'
|
|
1473
|
+
| 'dl'
|
|
1474
|
+
| 'dt'
|
|
1475
|
+
| 'em'
|
|
1476
|
+
| 'embed'
|
|
1477
|
+
| 'fieldset'
|
|
1478
|
+
| 'figcaption'
|
|
1479
|
+
| 'figure'
|
|
1480
|
+
| 'footer'
|
|
1481
|
+
| 'form'
|
|
1482
|
+
| 'h1'
|
|
1483
|
+
| 'h2'
|
|
1484
|
+
| 'h3'
|
|
1485
|
+
| 'h4'
|
|
1486
|
+
| 'h5'
|
|
1487
|
+
| 'h6'
|
|
1488
|
+
| 'head'
|
|
1489
|
+
| 'header'
|
|
1490
|
+
| 'hgroup'
|
|
1491
|
+
| 'hr'
|
|
1492
|
+
| 'html'
|
|
1493
|
+
| 'i'
|
|
1494
|
+
| 'iframe'
|
|
1495
|
+
| 'img'
|
|
1496
|
+
| 'input'
|
|
1497
|
+
| 'ins'
|
|
1498
|
+
| 'kbd'
|
|
1499
|
+
| 'label'
|
|
1500
|
+
| 'legend'
|
|
1501
|
+
| 'li'
|
|
1502
|
+
| 'link'
|
|
1503
|
+
| 'main'
|
|
1504
|
+
| 'map'
|
|
1505
|
+
| 'mark'
|
|
1506
|
+
| 'math'
|
|
1507
|
+
| 'menu'
|
|
1508
|
+
| 'menuitem'
|
|
1509
|
+
| 'meta'
|
|
1510
|
+
| 'meter'
|
|
1511
|
+
| 'nav'
|
|
1512
|
+
| 'noscript'
|
|
1513
|
+
| 'object'
|
|
1514
|
+
| 'ol'
|
|
1515
|
+
| 'optgroup'
|
|
1516
|
+
| 'option'
|
|
1517
|
+
| 'output'
|
|
1518
|
+
| 'p'
|
|
1519
|
+
| 'param'
|
|
1520
|
+
| 'picture'
|
|
1521
|
+
| 'pre'
|
|
1522
|
+
| 'progress'
|
|
1523
|
+
| 'q'
|
|
1524
|
+
| 'rb'
|
|
1525
|
+
| 'rp'
|
|
1526
|
+
| 'rt'
|
|
1527
|
+
| 'rtc'
|
|
1528
|
+
| 'ruby'
|
|
1529
|
+
| 's'
|
|
1530
|
+
| 'samp'
|
|
1531
|
+
| 'script'
|
|
1532
|
+
| 'section'
|
|
1533
|
+
| 'select'
|
|
1534
|
+
| 'slot'
|
|
1535
|
+
| 'small'
|
|
1536
|
+
| 'source'
|
|
1537
|
+
| 'span'
|
|
1538
|
+
| 'strong'
|
|
1539
|
+
| 'style'
|
|
1540
|
+
| 'sub'
|
|
1541
|
+
| 'summary'
|
|
1542
|
+
| 'sup'
|
|
1543
|
+
| 'svg'
|
|
1544
|
+
| 'table'
|
|
1545
|
+
| 'tbody'
|
|
1546
|
+
| 'td'
|
|
1547
|
+
| 'template'
|
|
1548
|
+
| 'textarea'
|
|
1549
|
+
| 'tfoot'
|
|
1550
|
+
| 'th'
|
|
1551
|
+
| 'thead'
|
|
1552
|
+
| 'time'
|
|
1553
|
+
| 'title'
|
|
1554
|
+
| 'tr'
|
|
1555
|
+
| 'track'
|
|
1556
|
+
| 'u'
|
|
1557
|
+
| 'ul'
|
|
1558
|
+
| 'var'
|
|
1559
|
+
| 'video'
|
|
1560
|
+
| 'wbr'
|
|
1561
|
+
|
|
1562
|
+
type ElementType = IntrinsicElement | Vue.Component
|
|
1563
|
+
|
|
1564
|
+
type ComponentProps<T extends ElementType> = T extends Vue.Component<infer Props>
|
|
1565
|
+
? Props
|
|
1566
|
+
: T extends keyof JSX.IntrinsicElements
|
|
1567
|
+
? JSX.IntrinsicElements[T]
|
|
1568
|
+
: never
|
|
1569
|
+
|
|
1570
|
+
type HTMLProps = {
|
|
1571
|
+
htmlSize?: string | number
|
|
1572
|
+
htmlWidth?: string | number
|
|
1573
|
+
htmlHeight?: string | number
|
|
1574
|
+
htmlTranslate?: 'yes' | 'no' | undefined
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
1578
|
+
|
|
1579
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
1580
|
+
|
|
1581
|
+
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
1582
|
+
Props<ComponentProps<T>, P> & JsxStyleProps
|
|
1583
|
+
>
|
|
1584
|
+
|
|
1585
|
+
export type ${upperName} = {
|
|
1586
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
1587
|
+
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1588
|
+
|
|
1589
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
1590
|
+
`
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1360
1594
|
// src/artifacts/jsx.ts
|
|
1361
1595
|
var typesMap = {
|
|
1362
1596
|
react: generateReactJsxTypes,
|
|
1363
1597
|
preact: generatePreactJsxTypes,
|
|
1364
|
-
solid: generateSolidJsxTypes
|
|
1598
|
+
solid: generateSolidJsxTypes,
|
|
1599
|
+
vue: generateVueJsxTypes
|
|
1365
1600
|
};
|
|
1366
1601
|
function generateJsxTypes(ctx) {
|
|
1367
1602
|
if (!ctx.jsx.framework)
|
|
@@ -1371,7 +1606,8 @@ function generateJsxTypes(ctx) {
|
|
|
1371
1606
|
var factoryMap = {
|
|
1372
1607
|
react: generateReactJsxFactory,
|
|
1373
1608
|
solid: generateSolidJsxFactory,
|
|
1374
|
-
preact: generatePreactJsxFactory
|
|
1609
|
+
preact: generatePreactJsxFactory,
|
|
1610
|
+
vue: generateVueJsxFactory
|
|
1375
1611
|
};
|
|
1376
1612
|
function generateJsxFactory(ctx) {
|
|
1377
1613
|
if (!ctx.jsx.framework)
|
|
@@ -1382,6 +1618,7 @@ var patternMap = {
|
|
|
1382
1618
|
react: generateReactJsxPattern,
|
|
1383
1619
|
solid: generateSolidJsxPattern,
|
|
1384
1620
|
preact: generatePreactJsxPattern
|
|
1621
|
+
// TODO: Vue
|
|
1385
1622
|
};
|
|
1386
1623
|
function generateJsxPatterns(ctx) {
|
|
1387
1624
|
if (ctx.patterns.isEmpty() && !ctx.jsx.framework)
|
|
@@ -1392,6 +1629,7 @@ var layoutGridMap = {
|
|
|
1392
1629
|
react: generateReactLayoutGrid,
|
|
1393
1630
|
preact: generatePreactLayoutGrid,
|
|
1394
1631
|
solid: generateSolidLayoutGrid
|
|
1632
|
+
// TODO: Vue
|
|
1395
1633
|
};
|
|
1396
1634
|
function generateLayoutGrid(ctx) {
|
|
1397
1635
|
if (!ctx.jsx.framework)
|
|
@@ -1476,9 +1714,9 @@ function getGeneratedTypes() {
|
|
|
1476
1714
|
}
|
|
1477
1715
|
|
|
1478
1716
|
// src/artifacts/types/main.ts
|
|
1479
|
-
var
|
|
1717
|
+
var import_outdent24 = require("outdent");
|
|
1480
1718
|
var generateTypesEntry = () => ({
|
|
1481
|
-
global:
|
|
1719
|
+
global: import_outdent24.outdent`
|
|
1482
1720
|
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1483
1721
|
import { GlobalStyleObject } from './system-types'
|
|
1484
1722
|
import { CompositionStyles } from './composition'
|
|
@@ -1490,7 +1728,7 @@ var generateTypesEntry = () => ({
|
|
|
1490
1728
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1491
1729
|
}
|
|
1492
1730
|
`,
|
|
1493
|
-
index:
|
|
1731
|
+
index: import_outdent24.outdent`
|
|
1494
1732
|
import './global'
|
|
1495
1733
|
export { ConditionalValue } from './conditions'
|
|
1496
1734
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
@@ -1500,7 +1738,7 @@ var generateTypesEntry = () => ({
|
|
|
1500
1738
|
});
|
|
1501
1739
|
|
|
1502
1740
|
// src/artifacts/types/prop-types.ts
|
|
1503
|
-
var
|
|
1741
|
+
var import_outdent25 = require("outdent");
|
|
1504
1742
|
function generatePropTypes(ctx) {
|
|
1505
1743
|
const {
|
|
1506
1744
|
config: { strictTokens },
|
|
@@ -1508,7 +1746,7 @@ function generatePropTypes(ctx) {
|
|
|
1508
1746
|
} = ctx;
|
|
1509
1747
|
const strictText = `${strictTokens ? "" : " | NativeValue<T>"}`;
|
|
1510
1748
|
const result = [
|
|
1511
|
-
|
|
1749
|
+
import_outdent25.outdent`
|
|
1512
1750
|
import type { ConditionalValue } from './conditions';
|
|
1513
1751
|
import type { Properties as CSSProperties } from './csstype'
|
|
1514
1752
|
import type { Tokens } from './token'
|
|
@@ -1531,7 +1769,7 @@ function generatePropTypes(ctx) {
|
|
|
1531
1769
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1532
1770
|
});
|
|
1533
1771
|
result.push("}");
|
|
1534
|
-
return
|
|
1772
|
+
return import_outdent25.outdent`
|
|
1535
1773
|
${result.join("\n")}
|
|
1536
1774
|
|
|
1537
1775
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -1544,10 +1782,10 @@ function generatePropTypes(ctx) {
|
|
|
1544
1782
|
|
|
1545
1783
|
// src/artifacts/types/style-props.ts
|
|
1546
1784
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
1547
|
-
var
|
|
1785
|
+
var import_outdent26 = __toESM(require("outdent"));
|
|
1548
1786
|
function generateStyleProps(ctx) {
|
|
1549
1787
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()));
|
|
1550
|
-
return
|
|
1788
|
+
return import_outdent26.default`
|
|
1551
1789
|
import { PropertyValue } from './prop-type'
|
|
1552
1790
|
import { Token } from './token'
|
|
1553
1791
|
|
|
@@ -1563,7 +1801,7 @@ function generateStyleProps(ctx) {
|
|
|
1563
1801
|
|
|
1564
1802
|
// src/artifacts/types/token-types.ts
|
|
1565
1803
|
var import_shared3 = require("@pandacss/shared");
|
|
1566
|
-
var
|
|
1804
|
+
var import_outdent27 = require("outdent");
|
|
1567
1805
|
var import_pluralize = __toESM(require("pluralize"));
|
|
1568
1806
|
function generateTokenTypes(ctx) {
|
|
1569
1807
|
const { tokens } = ctx;
|
|
@@ -1582,7 +1820,7 @@ function generateTokenTypes(ctx) {
|
|
|
1582
1820
|
}
|
|
1583
1821
|
result.add("} & { [token: string]: never }");
|
|
1584
1822
|
set.add(Array.from(result).join("\n"));
|
|
1585
|
-
return
|
|
1823
|
+
return import_outdent27.outdent.string(Array.from(set).join("\n\n"));
|
|
1586
1824
|
}
|
|
1587
1825
|
|
|
1588
1826
|
// src/artifacts/css/global-css.ts
|
|
@@ -1722,8 +1960,8 @@ function setupPatterns(ctx) {
|
|
|
1722
1960
|
if (!files)
|
|
1723
1961
|
return;
|
|
1724
1962
|
const index = {
|
|
1725
|
-
js:
|
|
1726
|
-
dts:
|
|
1963
|
+
js: import_outdent28.default.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
1964
|
+
dts: import_outdent28.default.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
1727
1965
|
};
|
|
1728
1966
|
return {
|
|
1729
1967
|
dir: ctx.paths.pattern,
|
|
@@ -1744,15 +1982,15 @@ function setupJsx(ctx) {
|
|
|
1744
1982
|
const patterns = generateJsxPatterns(ctx);
|
|
1745
1983
|
const layoutGrid2 = generateLayoutGrid(ctx);
|
|
1746
1984
|
const index = {
|
|
1747
|
-
js:
|
|
1985
|
+
js: import_outdent28.default`
|
|
1748
1986
|
${ctx.file.export("./factory")}
|
|
1749
1987
|
${ctx.file.export("./layout-grid")}
|
|
1750
|
-
${
|
|
1988
|
+
${import_outdent28.default.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
1751
1989
|
`,
|
|
1752
|
-
dts:
|
|
1990
|
+
dts: import_outdent28.default`
|
|
1753
1991
|
export * from './factory'
|
|
1754
1992
|
export * from './layout-grid'
|
|
1755
|
-
${
|
|
1993
|
+
${import_outdent28.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1756
1994
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
1757
1995
|
`
|
|
1758
1996
|
};
|
|
@@ -1773,12 +2011,12 @@ function setupJsx(ctx) {
|
|
|
1773
2011
|
}
|
|
1774
2012
|
function setupCssIndex(ctx) {
|
|
1775
2013
|
const index = {
|
|
1776
|
-
js:
|
|
2014
|
+
js: import_outdent28.default`
|
|
1777
2015
|
${ctx.file.export("./css")}
|
|
1778
2016
|
${ctx.file.export("./cx")}
|
|
1779
2017
|
${ctx.file.export("./cva")}
|
|
1780
2018
|
`,
|
|
1781
|
-
dts:
|
|
2019
|
+
dts: import_outdent28.default`
|
|
1782
2020
|
export * from './css'
|
|
1783
2021
|
export * from './cx'
|
|
1784
2022
|
export * from './cva'
|
package/dist/index.mjs
CHANGED
|
@@ -96,7 +96,7 @@ var getMessages = (ctx) => ({
|
|
|
96
96
|
import { Obj as Obj4, pipe as pipe5 } from "lil-fp";
|
|
97
97
|
|
|
98
98
|
// src/artifacts/index.ts
|
|
99
|
-
import
|
|
99
|
+
import outdent28 from "outdent";
|
|
100
100
|
|
|
101
101
|
// src/artifacts/css/keyframe-css.ts
|
|
102
102
|
import { toCss } from "@pandacss/core";
|
|
@@ -1326,11 +1326,246 @@ export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & J
|
|
|
1326
1326
|
};
|
|
1327
1327
|
}
|
|
1328
1328
|
|
|
1329
|
+
// src/artifacts/vue-jsx/jsx.ts
|
|
1330
|
+
import { outdent as outdent22 } from "outdent";
|
|
1331
|
+
function generateVueJsxFactory(ctx) {
|
|
1332
|
+
const { factoryName } = ctx.jsx;
|
|
1333
|
+
return {
|
|
1334
|
+
js: outdent22`
|
|
1335
|
+
import { defineComponent, h, computed } from 'vue'
|
|
1336
|
+
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1337
|
+
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1338
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1339
|
+
|
|
1340
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
1341
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1342
|
+
|
|
1343
|
+
return defineComponent({
|
|
1344
|
+
name: \`${factoryName}.\${Dynamic}\`,
|
|
1345
|
+
inheritAttrs: false,
|
|
1346
|
+
props: { as: { type: [String, Object], default: Dynamic } },
|
|
1347
|
+
setup(props, { slots, attrs }) {
|
|
1348
|
+
const splittedProps = computed(() => {
|
|
1349
|
+
return splitProps(attrs, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
1350
|
+
})
|
|
1351
|
+
|
|
1352
|
+
const classes = computed(() => {
|
|
1353
|
+
const [styleProps, variantProps, _htmlProps, elementProps] = splittedProps.value
|
|
1354
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1355
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1356
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1357
|
+
return cx(css(styles), elementProps.className)
|
|
1358
|
+
})
|
|
1359
|
+
|
|
1360
|
+
return () => {
|
|
1361
|
+
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
1362
|
+
return h(
|
|
1363
|
+
props.as,
|
|
1364
|
+
{
|
|
1365
|
+
class: classes.value,
|
|
1366
|
+
...elementProps,
|
|
1367
|
+
...normalizeHTMLProps(htmlProps),
|
|
1368
|
+
},
|
|
1369
|
+
slots.default && slots.default(),
|
|
1370
|
+
)
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
})
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function createJsxFactory() {
|
|
1377
|
+
const cache = new Map()
|
|
1378
|
+
|
|
1379
|
+
return new Proxy(styled, {
|
|
1380
|
+
apply(_, __, args) {
|
|
1381
|
+
return styled(...args)
|
|
1382
|
+
},
|
|
1383
|
+
get(_, el) {
|
|
1384
|
+
if (!cache.has(el)) {
|
|
1385
|
+
cache.set(el, styled(el))
|
|
1386
|
+
}
|
|
1387
|
+
return cache.get(el)
|
|
1388
|
+
},
|
|
1389
|
+
})
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
export const ${factoryName} = createJsxFactory()
|
|
1393
|
+
|
|
1394
|
+
`
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// src/artifacts/vue-jsx/types.ts
|
|
1399
|
+
import { outdent as outdent23 } from "outdent";
|
|
1400
|
+
function generateVueJsxTypes(ctx) {
|
|
1401
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1402
|
+
return {
|
|
1403
|
+
jsxFactory: outdent23`
|
|
1404
|
+
import { ${upperName} } from '../types/jsx'
|
|
1405
|
+
export declare const ${factoryName}: ${upperName}
|
|
1406
|
+
`,
|
|
1407
|
+
jsxType: outdent23`
|
|
1408
|
+
import type { Component, FunctionalComponent } from 'vue'
|
|
1409
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
1410
|
+
import type { RecipeDefinition, RecipeRuntimeFn, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
1411
|
+
|
|
1412
|
+
type IntrinsicElement =
|
|
1413
|
+
| 'a'
|
|
1414
|
+
| 'abbr'
|
|
1415
|
+
| 'address'
|
|
1416
|
+
| 'area'
|
|
1417
|
+
| 'article'
|
|
1418
|
+
| 'aside'
|
|
1419
|
+
| 'audio'
|
|
1420
|
+
| 'b'
|
|
1421
|
+
| 'base'
|
|
1422
|
+
| 'bdi'
|
|
1423
|
+
| 'bdo'
|
|
1424
|
+
| 'blockquote'
|
|
1425
|
+
| 'body'
|
|
1426
|
+
| 'br'
|
|
1427
|
+
| 'button'
|
|
1428
|
+
| 'canvas'
|
|
1429
|
+
| 'caption'
|
|
1430
|
+
| 'cite'
|
|
1431
|
+
| 'code'
|
|
1432
|
+
| 'col'
|
|
1433
|
+
| 'colgroup'
|
|
1434
|
+
| 'data'
|
|
1435
|
+
| 'datalist'
|
|
1436
|
+
| 'dd'
|
|
1437
|
+
| 'del'
|
|
1438
|
+
| 'details'
|
|
1439
|
+
| 'dfn'
|
|
1440
|
+
| 'dialog'
|
|
1441
|
+
| 'div'
|
|
1442
|
+
| 'dl'
|
|
1443
|
+
| 'dt'
|
|
1444
|
+
| 'em'
|
|
1445
|
+
| 'embed'
|
|
1446
|
+
| 'fieldset'
|
|
1447
|
+
| 'figcaption'
|
|
1448
|
+
| 'figure'
|
|
1449
|
+
| 'footer'
|
|
1450
|
+
| 'form'
|
|
1451
|
+
| 'h1'
|
|
1452
|
+
| 'h2'
|
|
1453
|
+
| 'h3'
|
|
1454
|
+
| 'h4'
|
|
1455
|
+
| 'h5'
|
|
1456
|
+
| 'h6'
|
|
1457
|
+
| 'head'
|
|
1458
|
+
| 'header'
|
|
1459
|
+
| 'hgroup'
|
|
1460
|
+
| 'hr'
|
|
1461
|
+
| 'html'
|
|
1462
|
+
| 'i'
|
|
1463
|
+
| 'iframe'
|
|
1464
|
+
| 'img'
|
|
1465
|
+
| 'input'
|
|
1466
|
+
| 'ins'
|
|
1467
|
+
| 'kbd'
|
|
1468
|
+
| 'label'
|
|
1469
|
+
| 'legend'
|
|
1470
|
+
| 'li'
|
|
1471
|
+
| 'link'
|
|
1472
|
+
| 'main'
|
|
1473
|
+
| 'map'
|
|
1474
|
+
| 'mark'
|
|
1475
|
+
| 'math'
|
|
1476
|
+
| 'menu'
|
|
1477
|
+
| 'menuitem'
|
|
1478
|
+
| 'meta'
|
|
1479
|
+
| 'meter'
|
|
1480
|
+
| 'nav'
|
|
1481
|
+
| 'noscript'
|
|
1482
|
+
| 'object'
|
|
1483
|
+
| 'ol'
|
|
1484
|
+
| 'optgroup'
|
|
1485
|
+
| 'option'
|
|
1486
|
+
| 'output'
|
|
1487
|
+
| 'p'
|
|
1488
|
+
| 'param'
|
|
1489
|
+
| 'picture'
|
|
1490
|
+
| 'pre'
|
|
1491
|
+
| 'progress'
|
|
1492
|
+
| 'q'
|
|
1493
|
+
| 'rb'
|
|
1494
|
+
| 'rp'
|
|
1495
|
+
| 'rt'
|
|
1496
|
+
| 'rtc'
|
|
1497
|
+
| 'ruby'
|
|
1498
|
+
| 's'
|
|
1499
|
+
| 'samp'
|
|
1500
|
+
| 'script'
|
|
1501
|
+
| 'section'
|
|
1502
|
+
| 'select'
|
|
1503
|
+
| 'slot'
|
|
1504
|
+
| 'small'
|
|
1505
|
+
| 'source'
|
|
1506
|
+
| 'span'
|
|
1507
|
+
| 'strong'
|
|
1508
|
+
| 'style'
|
|
1509
|
+
| 'sub'
|
|
1510
|
+
| 'summary'
|
|
1511
|
+
| 'sup'
|
|
1512
|
+
| 'svg'
|
|
1513
|
+
| 'table'
|
|
1514
|
+
| 'tbody'
|
|
1515
|
+
| 'td'
|
|
1516
|
+
| 'template'
|
|
1517
|
+
| 'textarea'
|
|
1518
|
+
| 'tfoot'
|
|
1519
|
+
| 'th'
|
|
1520
|
+
| 'thead'
|
|
1521
|
+
| 'time'
|
|
1522
|
+
| 'title'
|
|
1523
|
+
| 'tr'
|
|
1524
|
+
| 'track'
|
|
1525
|
+
| 'u'
|
|
1526
|
+
| 'ul'
|
|
1527
|
+
| 'var'
|
|
1528
|
+
| 'video'
|
|
1529
|
+
| 'wbr'
|
|
1530
|
+
|
|
1531
|
+
type ElementType = IntrinsicElement | Vue.Component
|
|
1532
|
+
|
|
1533
|
+
type ComponentProps<T extends ElementType> = T extends Vue.Component<infer Props>
|
|
1534
|
+
? Props
|
|
1535
|
+
: T extends keyof JSX.IntrinsicElements
|
|
1536
|
+
? JSX.IntrinsicElements[T]
|
|
1537
|
+
: never
|
|
1538
|
+
|
|
1539
|
+
type HTMLProps = {
|
|
1540
|
+
htmlSize?: string | number
|
|
1541
|
+
htmlWidth?: string | number
|
|
1542
|
+
htmlHeight?: string | number
|
|
1543
|
+
htmlTranslate?: 'yes' | 'no' | undefined
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
1547
|
+
|
|
1548
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
1549
|
+
|
|
1550
|
+
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
1551
|
+
Props<ComponentProps<T>, P> & JsxStyleProps
|
|
1552
|
+
>
|
|
1553
|
+
|
|
1554
|
+
export type ${upperName} = {
|
|
1555
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
1556
|
+
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1557
|
+
|
|
1558
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
1559
|
+
`
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1329
1563
|
// src/artifacts/jsx.ts
|
|
1330
1564
|
var typesMap = {
|
|
1331
1565
|
react: generateReactJsxTypes,
|
|
1332
1566
|
preact: generatePreactJsxTypes,
|
|
1333
|
-
solid: generateSolidJsxTypes
|
|
1567
|
+
solid: generateSolidJsxTypes,
|
|
1568
|
+
vue: generateVueJsxTypes
|
|
1334
1569
|
};
|
|
1335
1570
|
function generateJsxTypes(ctx) {
|
|
1336
1571
|
if (!ctx.jsx.framework)
|
|
@@ -1340,7 +1575,8 @@ function generateJsxTypes(ctx) {
|
|
|
1340
1575
|
var factoryMap = {
|
|
1341
1576
|
react: generateReactJsxFactory,
|
|
1342
1577
|
solid: generateSolidJsxFactory,
|
|
1343
|
-
preact: generatePreactJsxFactory
|
|
1578
|
+
preact: generatePreactJsxFactory,
|
|
1579
|
+
vue: generateVueJsxFactory
|
|
1344
1580
|
};
|
|
1345
1581
|
function generateJsxFactory(ctx) {
|
|
1346
1582
|
if (!ctx.jsx.framework)
|
|
@@ -1351,6 +1587,7 @@ var patternMap = {
|
|
|
1351
1587
|
react: generateReactJsxPattern,
|
|
1352
1588
|
solid: generateSolidJsxPattern,
|
|
1353
1589
|
preact: generatePreactJsxPattern
|
|
1590
|
+
// TODO: Vue
|
|
1354
1591
|
};
|
|
1355
1592
|
function generateJsxPatterns(ctx) {
|
|
1356
1593
|
if (ctx.patterns.isEmpty() && !ctx.jsx.framework)
|
|
@@ -1361,6 +1598,7 @@ var layoutGridMap = {
|
|
|
1361
1598
|
react: generateReactLayoutGrid,
|
|
1362
1599
|
preact: generatePreactLayoutGrid,
|
|
1363
1600
|
solid: generateSolidLayoutGrid
|
|
1601
|
+
// TODO: Vue
|
|
1364
1602
|
};
|
|
1365
1603
|
function generateLayoutGrid(ctx) {
|
|
1366
1604
|
if (!ctx.jsx.framework)
|
|
@@ -1445,9 +1683,9 @@ function getGeneratedTypes() {
|
|
|
1445
1683
|
}
|
|
1446
1684
|
|
|
1447
1685
|
// src/artifacts/types/main.ts
|
|
1448
|
-
import { outdent as
|
|
1686
|
+
import { outdent as outdent24 } from "outdent";
|
|
1449
1687
|
var generateTypesEntry = () => ({
|
|
1450
|
-
global:
|
|
1688
|
+
global: outdent24`
|
|
1451
1689
|
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1452
1690
|
import { GlobalStyleObject } from './system-types'
|
|
1453
1691
|
import { CompositionStyles } from './composition'
|
|
@@ -1459,7 +1697,7 @@ var generateTypesEntry = () => ({
|
|
|
1459
1697
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1460
1698
|
}
|
|
1461
1699
|
`,
|
|
1462
|
-
index:
|
|
1700
|
+
index: outdent24`
|
|
1463
1701
|
import './global'
|
|
1464
1702
|
export { ConditionalValue } from './conditions'
|
|
1465
1703
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
@@ -1469,7 +1707,7 @@ var generateTypesEntry = () => ({
|
|
|
1469
1707
|
});
|
|
1470
1708
|
|
|
1471
1709
|
// src/artifacts/types/prop-types.ts
|
|
1472
|
-
import { outdent as
|
|
1710
|
+
import { outdent as outdent25 } from "outdent";
|
|
1473
1711
|
function generatePropTypes(ctx) {
|
|
1474
1712
|
const {
|
|
1475
1713
|
config: { strictTokens },
|
|
@@ -1477,7 +1715,7 @@ function generatePropTypes(ctx) {
|
|
|
1477
1715
|
} = ctx;
|
|
1478
1716
|
const strictText = `${strictTokens ? "" : " | NativeValue<T>"}`;
|
|
1479
1717
|
const result = [
|
|
1480
|
-
|
|
1718
|
+
outdent25`
|
|
1481
1719
|
import type { ConditionalValue } from './conditions';
|
|
1482
1720
|
import type { Properties as CSSProperties } from './csstype'
|
|
1483
1721
|
import type { Tokens } from './token'
|
|
@@ -1500,7 +1738,7 @@ function generatePropTypes(ctx) {
|
|
|
1500
1738
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1501
1739
|
});
|
|
1502
1740
|
result.push("}");
|
|
1503
|
-
return
|
|
1741
|
+
return outdent25`
|
|
1504
1742
|
${result.join("\n")}
|
|
1505
1743
|
|
|
1506
1744
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -1513,10 +1751,10 @@ function generatePropTypes(ctx) {
|
|
|
1513
1751
|
|
|
1514
1752
|
// src/artifacts/types/style-props.ts
|
|
1515
1753
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
1516
|
-
import
|
|
1754
|
+
import outdent26 from "outdent";
|
|
1517
1755
|
function generateStyleProps(ctx) {
|
|
1518
1756
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
1519
|
-
return
|
|
1757
|
+
return outdent26`
|
|
1520
1758
|
import { PropertyValue } from './prop-type'
|
|
1521
1759
|
import { Token } from './token'
|
|
1522
1760
|
|
|
@@ -1532,7 +1770,7 @@ function generateStyleProps(ctx) {
|
|
|
1532
1770
|
|
|
1533
1771
|
// src/artifacts/types/token-types.ts
|
|
1534
1772
|
import { capitalize as capitalize2, unionType as unionType3 } from "@pandacss/shared";
|
|
1535
|
-
import { outdent as
|
|
1773
|
+
import { outdent as outdent27 } from "outdent";
|
|
1536
1774
|
import pluralize from "pluralize";
|
|
1537
1775
|
function generateTokenTypes(ctx) {
|
|
1538
1776
|
const { tokens } = ctx;
|
|
@@ -1551,7 +1789,7 @@ function generateTokenTypes(ctx) {
|
|
|
1551
1789
|
}
|
|
1552
1790
|
result.add("} & { [token: string]: never }");
|
|
1553
1791
|
set.add(Array.from(result).join("\n"));
|
|
1554
|
-
return
|
|
1792
|
+
return outdent27.string(Array.from(set).join("\n\n"));
|
|
1555
1793
|
}
|
|
1556
1794
|
|
|
1557
1795
|
// src/artifacts/css/global-css.ts
|
|
@@ -1691,8 +1929,8 @@ function setupPatterns(ctx) {
|
|
|
1691
1929
|
if (!files)
|
|
1692
1930
|
return;
|
|
1693
1931
|
const index = {
|
|
1694
|
-
js:
|
|
1695
|
-
dts:
|
|
1932
|
+
js: outdent28.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
1933
|
+
dts: outdent28.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
1696
1934
|
};
|
|
1697
1935
|
return {
|
|
1698
1936
|
dir: ctx.paths.pattern,
|
|
@@ -1713,15 +1951,15 @@ function setupJsx(ctx) {
|
|
|
1713
1951
|
const patterns = generateJsxPatterns(ctx);
|
|
1714
1952
|
const layoutGrid2 = generateLayoutGrid(ctx);
|
|
1715
1953
|
const index = {
|
|
1716
|
-
js:
|
|
1954
|
+
js: outdent28`
|
|
1717
1955
|
${ctx.file.export("./factory")}
|
|
1718
1956
|
${ctx.file.export("./layout-grid")}
|
|
1719
|
-
${
|
|
1957
|
+
${outdent28.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
1720
1958
|
`,
|
|
1721
|
-
dts:
|
|
1959
|
+
dts: outdent28`
|
|
1722
1960
|
export * from './factory'
|
|
1723
1961
|
export * from './layout-grid'
|
|
1724
|
-
${
|
|
1962
|
+
${outdent28.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1725
1963
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
1726
1964
|
`
|
|
1727
1965
|
};
|
|
@@ -1742,12 +1980,12 @@ function setupJsx(ctx) {
|
|
|
1742
1980
|
}
|
|
1743
1981
|
function setupCssIndex(ctx) {
|
|
1744
1982
|
const index = {
|
|
1745
|
-
js:
|
|
1983
|
+
js: outdent28`
|
|
1746
1984
|
${ctx.file.export("./css")}
|
|
1747
1985
|
${ctx.file.export("./cx")}
|
|
1748
1986
|
${ctx.file.export("./cva")}
|
|
1749
1987
|
`,
|
|
1750
|
-
dts:
|
|
1988
|
+
dts: outdent28`
|
|
1751
1989
|
export * from './css'
|
|
1752
1990
|
export * from './cx'
|
|
1753
1991
|
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-20230211113952",
|
|
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.21",
|
|
22
22
|
"ts-pattern": "4.1.4",
|
|
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-20230211113952",
|
|
24
|
+
"@pandacss/logger": "0.0.0-dev-20230211113952",
|
|
25
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230211113952",
|
|
26
|
+
"@pandacss/shared": "0.0.0-dev-20230211113952",
|
|
27
|
+
"@pandacss/types": "0.0.0-dev-20230211113952",
|
|
28
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230211113952"
|
|
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-20230211113952"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"prebuild": "tsx scripts/prebuild.ts",
|