@pandacss/node 0.0.0-dev-20230122145009 → 0.0.0-dev-20230124104736
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 +27 -16
- package/dist/index.js +294 -209
- package/dist/index.mjs +293 -209
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -69,7 +69,7 @@ async function extractChunks(ctx) {
|
|
|
69
69
|
}
|
|
70
70
|
async function bundleChunks(ctx) {
|
|
71
71
|
const css2 = await extractChunks(ctx);
|
|
72
|
-
await ctx.write(ctx.
|
|
72
|
+
await ctx.write(ctx.paths.root, [{ file: "styles.css", code: css2 }]);
|
|
73
73
|
}
|
|
74
74
|
async function writeFileChunk(ctx, file) {
|
|
75
75
|
logger2.info(`File changed: ${file}`);
|
|
@@ -89,7 +89,8 @@ function generateConditions(ctx) {
|
|
|
89
89
|
const keys = Object.keys(ctx.conditions.values).concat("base");
|
|
90
90
|
return {
|
|
91
91
|
js: outdent`
|
|
92
|
-
|
|
92
|
+
${ctx.getImport("withoutSpace", "../helpers")}
|
|
93
|
+
|
|
93
94
|
const conditions = new Set([${keys.map((key) => JSON.stringify(key))}])
|
|
94
95
|
|
|
95
96
|
export function isCondition(value){
|
|
@@ -157,12 +158,12 @@ function generateCssFn(ctx) {
|
|
|
157
158
|
const { separator } = utility;
|
|
158
159
|
return {
|
|
159
160
|
dts: outdent2`
|
|
160
|
-
import { SystemStyleObject } from '../types'
|
|
161
|
+
import type { SystemStyleObject } from '../types'
|
|
161
162
|
export declare function css(styles: SystemStyleObject): string
|
|
162
163
|
`,
|
|
163
164
|
js: outdent2`
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
${ctx.getImport("createCss, createMergeCss, withoutSpace", "../helpers")}
|
|
166
|
+
${ctx.getImport("sortConditions, finalizeConditions", "./conditions")}
|
|
166
167
|
|
|
167
168
|
const classNameMap = ${stringify(utility.entries())}
|
|
168
169
|
|
|
@@ -204,11 +205,11 @@ function generateCssFn(ctx) {
|
|
|
204
205
|
|
|
205
206
|
// src/generators/cva.ts
|
|
206
207
|
import { outdent as outdent3 } from "outdent";
|
|
207
|
-
function generateCvaFn() {
|
|
208
|
+
function generateCvaFn(ctx) {
|
|
208
209
|
return {
|
|
209
210
|
js: outdent3`
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
${ctx.getImport("compact", "../helpers")}
|
|
212
|
+
${ctx.getImport("css, mergeCss", "./css")}
|
|
212
213
|
|
|
213
214
|
export function cva(config) {
|
|
214
215
|
const { base = {}, variants = {}, defaultVariants = {} } = config
|
|
@@ -237,7 +238,7 @@ function generateCvaFn() {
|
|
|
237
238
|
}
|
|
238
239
|
`,
|
|
239
240
|
dts: outdent3`
|
|
240
|
-
import { RecipeCreatorFn } from '../types/recipe'
|
|
241
|
+
import type { RecipeCreatorFn } from '../types/recipe'
|
|
241
242
|
|
|
242
243
|
export declare const cva: RecipeCreatorFn
|
|
243
244
|
|
|
@@ -316,9 +317,9 @@ function generatePreactJsxFactory(ctx) {
|
|
|
316
317
|
import { h } from 'preact'
|
|
317
318
|
import { forwardRef } from 'preact/compat'
|
|
318
319
|
import { useMemo } from 'preact/hooks'
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
${ctx.getImport("css, cx, assignCss", "../css/index")}
|
|
321
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
322
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
322
323
|
|
|
323
324
|
function styled(Dynamic, configOrCva = {}) {
|
|
324
325
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -330,7 +331,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
330
331
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
331
332
|
}, [restProps])
|
|
332
333
|
|
|
333
|
-
function classes(){
|
|
334
|
+
function classes() {
|
|
334
335
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
335
336
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
336
337
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
@@ -432,29 +433,30 @@ function generate(ctx, name, pattern) {
|
|
|
432
433
|
return {
|
|
433
434
|
name: dashName,
|
|
434
435
|
js: outdent7`
|
|
436
|
+
import { h } from 'preact'
|
|
435
437
|
import { forwardRef } from 'preact/compat'
|
|
436
|
-
|
|
437
|
-
|
|
438
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
439
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
438
440
|
|
|
439
441
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
440
442
|
${match(props.length).with(
|
|
441
443
|
0,
|
|
442
444
|
() => outdent7`
|
|
443
|
-
return
|
|
445
|
+
return h(${ctx.jsxFactory}.div, { ref, ...props })
|
|
444
446
|
`
|
|
445
447
|
).otherwise(
|
|
446
448
|
() => outdent7`
|
|
447
449
|
const { ${props.join(", ")}, ...restProps } = props
|
|
448
450
|
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
449
|
-
return
|
|
451
|
+
return h(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
450
452
|
`
|
|
451
453
|
)}
|
|
452
454
|
})
|
|
453
455
|
`,
|
|
454
456
|
dts: outdent7`
|
|
455
|
-
import { FunctionComponent } from 'preact'
|
|
456
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
457
|
-
import { ${typeName} } from '../types/jsx'
|
|
457
|
+
import type { FunctionComponent } from 'preact'
|
|
458
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
459
|
+
import type { ${typeName} } from '../types/jsx'
|
|
458
460
|
|
|
459
461
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
460
462
|
|
|
@@ -473,25 +475,25 @@ function generatePreactJsxTypes(ctx) {
|
|
|
473
475
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
474
476
|
return {
|
|
475
477
|
jsxFactory: outdent8`
|
|
476
|
-
import { ${upperName} } from '../types/jsx'
|
|
478
|
+
import type { ${upperName} } from '../types/jsx'
|
|
477
479
|
export declare const ${name}: ${upperName}
|
|
478
480
|
`,
|
|
479
481
|
jsxType: outdent8`
|
|
480
|
-
import { JSX, ComponentProps } from 'preact'
|
|
481
|
-
import { JsxStyleProps, Assign } from '.'
|
|
482
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
482
|
+
import type { JSX, ComponentProps } from 'preact'
|
|
483
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
484
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
483
485
|
|
|
484
486
|
type Dict = Record<string, unknown>
|
|
485
487
|
type ElementType = keyof JSX.IntrinsicElements
|
|
486
488
|
|
|
487
|
-
type
|
|
489
|
+
type HTMLProps = {
|
|
488
490
|
htmlSize?: string | number
|
|
489
491
|
htmlWidth?: string | number
|
|
490
492
|
htmlHeight?: string | number
|
|
491
493
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
492
494
|
}
|
|
493
495
|
|
|
494
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
496
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
495
497
|
|
|
496
498
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
497
499
|
|
|
@@ -515,10 +517,10 @@ function generateReactJsxFactory(ctx) {
|
|
|
515
517
|
const { name, componentName } = ctx.jsxFactoryDetails;
|
|
516
518
|
return {
|
|
517
519
|
js: outdent9`
|
|
518
|
-
import { forwardRef, useMemo } from 'react'
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
520
|
+
import { createElement, forwardRef, useMemo } from 'react'
|
|
521
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
522
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
523
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
522
524
|
|
|
523
525
|
function styled(Dynamic, configOrCva = {}) {
|
|
524
526
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -530,21 +532,19 @@ function generateReactJsxFactory(ctx) {
|
|
|
530
532
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
531
533
|
}, [restProps])
|
|
532
534
|
|
|
533
|
-
function classes(){
|
|
535
|
+
function classes() {
|
|
534
536
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
535
537
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
536
538
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
537
539
|
return cx(css(styles), elementProps.className)
|
|
538
540
|
}
|
|
539
541
|
|
|
540
|
-
return(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
/>
|
|
547
|
-
)
|
|
542
|
+
return createElement(Element, {
|
|
543
|
+
ref,
|
|
544
|
+
...elementProps,
|
|
545
|
+
...normalizeHTMLProps(htmlProps),
|
|
546
|
+
className: classes(),
|
|
547
|
+
})
|
|
548
548
|
})
|
|
549
549
|
|
|
550
550
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -590,38 +590,37 @@ function generateReactLayoutGrid() {
|
|
|
590
590
|
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
591
591
|
`,
|
|
592
592
|
js: outdent10`
|
|
593
|
+
import { createElement } from 'react'
|
|
594
|
+
|
|
593
595
|
export function LayoutGrid(props) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
596
|
+
const { count = 12, margin, gutter = '24px', maxWidth } = props
|
|
597
|
+
const hasMaxWidth = maxWidth != null
|
|
598
|
+
return createElement('div', {
|
|
599
|
+
style: {
|
|
600
|
+
display: 'grid',
|
|
601
|
+
gap: gutter,
|
|
602
|
+
gridTemplateColumns: \`repeat(\${count}, 1fr)\`,
|
|
603
|
+
height: '100%',
|
|
604
|
+
width: '100%',
|
|
605
|
+
position: 'absolute',
|
|
606
|
+
inset: '0',
|
|
607
|
+
pointerEvents: 'none',
|
|
608
|
+
maxWidth: hasMaxWidth ? maxWidth : 'initial',
|
|
609
|
+
marginInline: hasMaxWidth ? 'auto' : undefined,
|
|
610
|
+
paddingInline: !hasMaxWidth ? margin : undefined,
|
|
611
|
+
},
|
|
612
|
+
children: Array.from({ length: count }).map((_, i) =>
|
|
613
|
+
createElement('span', {
|
|
614
|
+
key: i,
|
|
615
|
+
style: {
|
|
616
|
+
display: 'flex',
|
|
617
|
+
background: 'rgba(255, 0, 0, 0.1)',
|
|
602
618
|
height: '100%',
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
marginInline: hasMaxWidth ? 'auto' : undefined,
|
|
609
|
-
paddingInline: !hasMaxWidth ? margin : undefined,
|
|
610
|
-
}}
|
|
611
|
-
>
|
|
612
|
-
{Array.from({ length: count }).map((_, i) => (
|
|
613
|
-
<span
|
|
614
|
-
key={i}
|
|
615
|
-
style={{
|
|
616
|
-
display: 'flex',
|
|
617
|
-
background: 'rgba(255, 0, 0, 0.1)',
|
|
618
|
-
height: '100%',
|
|
619
|
-
}}
|
|
620
|
-
/>
|
|
621
|
-
))}
|
|
622
|
-
</div>
|
|
623
|
-
);
|
|
624
|
-
}
|
|
619
|
+
},
|
|
620
|
+
}),
|
|
621
|
+
),
|
|
622
|
+
})
|
|
623
|
+
}
|
|
625
624
|
`
|
|
626
625
|
};
|
|
627
626
|
}
|
|
@@ -635,30 +634,29 @@ function generate2(ctx, name, pattern) {
|
|
|
635
634
|
return {
|
|
636
635
|
name: dashName,
|
|
637
636
|
js: outdent11`
|
|
638
|
-
import { forwardRef } from 'react'
|
|
639
|
-
|
|
640
|
-
|
|
637
|
+
import { createElement, forwardRef } from 'react'
|
|
638
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
639
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
641
640
|
|
|
642
641
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
643
642
|
${match2(props.length).with(
|
|
644
643
|
0,
|
|
645
644
|
() => outdent11`
|
|
646
|
-
|
|
645
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...props })
|
|
647
646
|
`
|
|
648
647
|
).otherwise(
|
|
649
648
|
() => outdent11`
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
649
|
+
const { ${props.join(", ")}, ...restProps } = props
|
|
650
|
+
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
651
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
653
652
|
`
|
|
654
653
|
)}
|
|
655
|
-
|
|
656
654
|
})
|
|
657
655
|
`,
|
|
658
656
|
dts: outdent11`
|
|
659
|
-
import { FunctionComponent } from 'react'
|
|
660
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
661
|
-
import { ${typeName} } from '../types/jsx'
|
|
657
|
+
import type { FunctionComponent } from 'react'
|
|
658
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
659
|
+
import type { ${typeName} } from '../types/jsx'
|
|
662
660
|
|
|
663
661
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
664
662
|
|
|
@@ -681,20 +679,20 @@ import { ${upperName} } from '../types/jsx'
|
|
|
681
679
|
export declare const ${name}: ${upperName}
|
|
682
680
|
`,
|
|
683
681
|
jsxType: outdent12`
|
|
684
|
-
import { ElementType, ComponentProps } from 'react'
|
|
685
|
-
import { JsxStyleProps, Assign } from '.'
|
|
686
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
682
|
+
import type { ElementType, ComponentProps } from 'react'
|
|
683
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
684
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
687
685
|
|
|
688
686
|
type Dict = Record<string, unknown>
|
|
689
687
|
|
|
690
|
-
type
|
|
688
|
+
type HTMLProps = {
|
|
691
689
|
htmlSize?: string | number
|
|
692
690
|
htmlWidth?: string | number
|
|
693
691
|
htmlHeight?: string | number
|
|
694
692
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
695
693
|
}
|
|
696
694
|
|
|
697
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
695
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
698
696
|
|
|
699
697
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
700
698
|
|
|
@@ -720,9 +718,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
720
718
|
js: outdent13`
|
|
721
719
|
import { Dynamic } from 'solid-js/web'
|
|
722
720
|
import { mergeProps, splitProps } from 'solid-js'
|
|
723
|
-
import {
|
|
724
|
-
|
|
725
|
-
|
|
721
|
+
import { createComponent } from 'solid-js/web'
|
|
722
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
723
|
+
${ctx.getImport("normalizeHTMLProps", "../helpers")}
|
|
724
|
+
${ctx.getImport("allCssProperties", "./is-valid-prop")}
|
|
726
725
|
|
|
727
726
|
function styled(element, configOrCva = {}) {
|
|
728
727
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -730,10 +729,11 @@ function generateSolidJsxFactory(ctx) {
|
|
|
730
729
|
return function ${componentName}(props) {
|
|
731
730
|
const mergedProps = mergeProps({ as: element }, props)
|
|
732
731
|
|
|
733
|
-
const [localProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
732
|
+
const [localProps, styleProps, variantProps, htmlProps, elementProps] = splitProps(
|
|
734
733
|
mergedProps,
|
|
735
734
|
['as', 'class'],
|
|
736
735
|
allCssProperties,
|
|
736
|
+
cvaFn.variants,
|
|
737
737
|
normalizeHTMLProps.keys
|
|
738
738
|
)
|
|
739
739
|
|
|
@@ -744,13 +744,20 @@ function generateSolidJsxFactory(ctx) {
|
|
|
744
744
|
return cx(css(styles), localProps.class)
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
-
return (
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
{
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
747
|
+
return createComponent(
|
|
748
|
+
Dynamic,
|
|
749
|
+
mergeProps(
|
|
750
|
+
{
|
|
751
|
+
get component() {
|
|
752
|
+
return localProps.as
|
|
753
|
+
},
|
|
754
|
+
get class() {
|
|
755
|
+
return classes()
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
elementProps,
|
|
759
|
+
normalizeHTMLProps(htmlProps)
|
|
760
|
+
)
|
|
754
761
|
)
|
|
755
762
|
}
|
|
756
763
|
}
|
|
@@ -781,7 +788,7 @@ import { outdent as outdent14 } from "outdent";
|
|
|
781
788
|
function generateSolidLayoutGrid() {
|
|
782
789
|
return {
|
|
783
790
|
dts: outdent14`
|
|
784
|
-
import { ParentProps } from 'solid-js'
|
|
791
|
+
import type { ParentProps } from 'solid-js'
|
|
785
792
|
|
|
786
793
|
export type LayoutGridProps = {
|
|
787
794
|
count?: number
|
|
@@ -793,38 +800,43 @@ function generateSolidLayoutGrid() {
|
|
|
793
800
|
export declare const LayoutGrid: ParentProps<LayoutGridProps>
|
|
794
801
|
`,
|
|
795
802
|
js: outdent14`
|
|
803
|
+
import { createComponent, For } from 'solid-js/web'
|
|
804
|
+
|
|
796
805
|
export function LayoutGrid(props) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
806
|
+
const { count = 12, margin, gutter = '24px', maxWidth } = props
|
|
807
|
+
const hasMaxWidth = maxWidth != null
|
|
808
|
+
return createComponent('div', {
|
|
809
|
+
style: {
|
|
810
|
+
display: 'grid',
|
|
811
|
+
gap: gutter,
|
|
812
|
+
'grid-template-columns': \`repeat(\${count}, 1fr)\`,
|
|
813
|
+
height: '100%',
|
|
814
|
+
width: '100%',
|
|
815
|
+
position: 'absolute',
|
|
816
|
+
inset: '0',
|
|
817
|
+
'pointer-events': 'none',
|
|
818
|
+
'max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
819
|
+
'margin-inline': hasMaxWidth ? 'auto' : undefined,
|
|
820
|
+
'padding-inline': !hasMaxWidth ? margin : undefined,
|
|
821
|
+
},
|
|
822
|
+
get children() {
|
|
823
|
+
return createComponent(For, {
|
|
824
|
+
get each() {
|
|
825
|
+
return Array.from({ length: count })
|
|
826
|
+
},
|
|
827
|
+
children: () =>
|
|
828
|
+
createComponent('span', {
|
|
829
|
+
style: {
|
|
819
830
|
display: 'flex',
|
|
820
831
|
background: 'rgba(255, 0, 0, 0.1)',
|
|
821
832
|
height: '100%',
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
833
|
+
},
|
|
834
|
+
}),
|
|
835
|
+
})
|
|
836
|
+
},
|
|
837
|
+
})
|
|
838
|
+
}
|
|
839
|
+
|
|
828
840
|
`
|
|
829
841
|
};
|
|
830
842
|
}
|
|
@@ -838,21 +850,22 @@ function generate3(ctx, name, pattern) {
|
|
|
838
850
|
return {
|
|
839
851
|
name: dashName,
|
|
840
852
|
js: outdent15`
|
|
841
|
-
import { splitProps } from 'solid-js'
|
|
842
|
-
import {
|
|
843
|
-
|
|
853
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
854
|
+
import { createComponent } from 'solid-js/web'
|
|
855
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
856
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
844
857
|
|
|
845
858
|
export function ${jsxName}(props) {
|
|
846
859
|
${match3(props.length).with(
|
|
847
860
|
0,
|
|
848
861
|
() => outdent15`
|
|
849
|
-
return
|
|
862
|
+
return createComponent(${ctx.jsxFactory}.div, props)
|
|
850
863
|
`
|
|
851
864
|
).otherwise(
|
|
852
865
|
() => outdent15`
|
|
853
866
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
854
867
|
const styleProps = ${styleFn}(patternProps)
|
|
855
|
-
return
|
|
868
|
+
return createComponent(${ctx.jsxFactory}.div, mergeProps(styleProps, restProps))
|
|
856
869
|
`
|
|
857
870
|
)}
|
|
858
871
|
}
|
|
@@ -879,26 +892,26 @@ function generateSolidJsxTypes(ctx) {
|
|
|
879
892
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
880
893
|
return {
|
|
881
894
|
jsxFactory: outdent16`
|
|
882
|
-
import { ${upperName} } from '../types/jsx'
|
|
895
|
+
import type { ${upperName} } from '../types/jsx'
|
|
883
896
|
export declare const ${name}: ${upperName}
|
|
884
897
|
`,
|
|
885
898
|
jsxType: outdent16`
|
|
886
|
-
import { JSX, ComponentProps, Component } from 'solid-js'
|
|
887
|
-
import { JsxStyleProps, Assign } from '.'
|
|
888
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
899
|
+
import type { JSX, ComponentProps, Component } from 'solid-js'
|
|
900
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
901
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
889
902
|
|
|
890
903
|
type Dict = Record<string, unknown>
|
|
891
904
|
|
|
892
905
|
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
893
906
|
|
|
894
|
-
type
|
|
907
|
+
type HTMLProps = {
|
|
895
908
|
htmlSize?: string | number
|
|
896
909
|
htmlWidth?: string | number
|
|
897
910
|
htmlHeight?: string | number
|
|
898
911
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
899
912
|
}
|
|
900
913
|
|
|
901
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
914
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
902
915
|
|
|
903
916
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
904
917
|
|
|
@@ -965,10 +978,10 @@ function generate4(ctx, name, pattern) {
|
|
|
965
978
|
return {
|
|
966
979
|
name: dashCase(name),
|
|
967
980
|
dts: outdent17`
|
|
968
|
-
import { SystemStyleObject, ConditionalValue } from '../types'
|
|
969
|
-
import { PropertyValue } from '../types/prop-type'
|
|
970
|
-
import { Properties } from '../types/csstype'
|
|
971
|
-
import { Tokens } from '../types/token'
|
|
981
|
+
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
982
|
+
import type { PropertyValue } from '../types/prop-type'
|
|
983
|
+
import type { Properties } from '../types/csstype'
|
|
984
|
+
import type { Tokens } from '../types/token'
|
|
972
985
|
|
|
973
986
|
export type ${capitalize(name)}Properties = {
|
|
974
987
|
${Object.keys(properties ?? {}).map((key) => {
|
|
@@ -998,8 +1011,8 @@ function generate4(ctx, name, pattern) {
|
|
|
998
1011
|
|
|
999
1012
|
`,
|
|
1000
1013
|
js: outdent17`
|
|
1001
|
-
|
|
1002
|
-
|
|
1014
|
+
${ctx.getImport("mapObject", "../helpers")}
|
|
1015
|
+
${ctx.getImport("css", "../css/index")}
|
|
1003
1016
|
|
|
1004
1017
|
const config = ${stringify2({ transform })}
|
|
1005
1018
|
|
|
@@ -1015,15 +1028,35 @@ function generatePattern(ctx) {
|
|
|
1015
1028
|
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(ctx, name, pattern));
|
|
1016
1029
|
}
|
|
1017
1030
|
|
|
1031
|
+
// src/generators/pkg-json.ts
|
|
1032
|
+
function generatePackageJSON(ctx) {
|
|
1033
|
+
const pkg = {
|
|
1034
|
+
name: ctx.outdir,
|
|
1035
|
+
description: "This package is auto-generated by CSS Panda",
|
|
1036
|
+
version: `0.0.0-${performance.now()}`,
|
|
1037
|
+
type: "module",
|
|
1038
|
+
exports: {
|
|
1039
|
+
"./css": { types: "./css/index.d.ts", import: "./css/index.mjs" },
|
|
1040
|
+
"./jsx": { types: "./jsx/index.d.ts", import: "./jsx/index.mjs" },
|
|
1041
|
+
"./patterns": { types: "./patterns/index.d.ts", import: "./patterns/index.mjs" },
|
|
1042
|
+
"./recipes": { types: "./recipes/index.d.ts", import: "./recipes/index.mjs" },
|
|
1043
|
+
"./tokens": { types: "./tokens/index.d.ts", import: "./tokens/index.mjs" },
|
|
1044
|
+
"./types": { types: "./types/index.d.ts" },
|
|
1045
|
+
"./styles.css": "./styles.css"
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
return JSON.stringify(pkg, null, 2);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1018
1051
|
// src/generators/prop-types.ts
|
|
1019
1052
|
import { outdent as outdent18 } from "outdent";
|
|
1020
1053
|
function generatePropTypes(utility, strict) {
|
|
1021
1054
|
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1022
1055
|
const result = [
|
|
1023
1056
|
outdent18`
|
|
1024
|
-
import { ConditionalValue } from './conditions';
|
|
1025
|
-
import { Properties as CSSProperties } from './csstype'
|
|
1026
|
-
import { Tokens } from './token'
|
|
1057
|
+
import type { ConditionalValue } from './conditions';
|
|
1058
|
+
import type { Properties as CSSProperties } from './csstype'
|
|
1059
|
+
import type { Tokens } from './token'
|
|
1027
1060
|
|
|
1028
1061
|
type PropertyValueTypes = {`
|
|
1029
1062
|
];
|
|
@@ -1064,7 +1097,7 @@ function generateRecipes(ctx) {
|
|
|
1064
1097
|
return;
|
|
1065
1098
|
const js = [
|
|
1066
1099
|
outdent19`
|
|
1067
|
-
|
|
1100
|
+
${ctx.getImport("createCss, withoutSpace, compact", "../helpers")}
|
|
1068
1101
|
|
|
1069
1102
|
const createRecipe = (name, defaultVariants) => {
|
|
1070
1103
|
return (variants) => {
|
|
@@ -1097,7 +1130,7 @@ function generateRecipes(ctx) {
|
|
|
1097
1130
|
];
|
|
1098
1131
|
const dts = [
|
|
1099
1132
|
outdent19`
|
|
1100
|
-
import { ConditionalValue } from '../types'
|
|
1133
|
+
import type { ConditionalValue } from '../types'
|
|
1101
1134
|
`
|
|
1102
1135
|
];
|
|
1103
1136
|
Object.values(recipes).forEach((recipe) => {
|
|
@@ -1335,20 +1368,21 @@ function generateTokenJs(dict) {
|
|
|
1335
1368
|
js: outdent21`
|
|
1336
1369
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1337
1370
|
|
|
1338
|
-
export function
|
|
1371
|
+
export function token(path) {
|
|
1339
1372
|
const { value } = tokens[path] || {}
|
|
1340
1373
|
return value
|
|
1341
1374
|
}
|
|
1342
1375
|
|
|
1343
|
-
|
|
1376
|
+
function tokenVar(path) {
|
|
1344
1377
|
const { variable } = tokens[path] || {}
|
|
1345
1378
|
return variable
|
|
1346
1379
|
}
|
|
1380
|
+
|
|
1381
|
+
token.var = tokenVar
|
|
1347
1382
|
`,
|
|
1348
1383
|
dts: outdent21`
|
|
1349
|
-
import { Token } from
|
|
1350
|
-
export declare function
|
|
1351
|
-
export declare function getTokenVar(path: Token): string
|
|
1384
|
+
import type { Token } from '../types/token'
|
|
1385
|
+
export declare function token(path: Token): string & { var: (path: Token) => string }
|
|
1352
1386
|
`
|
|
1353
1387
|
};
|
|
1354
1388
|
}
|
|
@@ -1368,7 +1402,21 @@ function generateCssType(ctx) {
|
|
|
1368
1402
|
system: getType("system-types.d.ts"),
|
|
1369
1403
|
selectors: getType("selectors.d.ts"),
|
|
1370
1404
|
recipe: getType("recipe.d.ts"),
|
|
1405
|
+
composition: getType("composition.d.ts"),
|
|
1406
|
+
global: outdent22`
|
|
1407
|
+
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1408
|
+
import { GlobalStyleObject } from './system-types'
|
|
1409
|
+
import { CompositionStyles } from './composition'
|
|
1410
|
+
|
|
1411
|
+
declare module 'css-panda' {
|
|
1412
|
+
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig<V>
|
|
1413
|
+
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
1414
|
+
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
1415
|
+
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1416
|
+
}
|
|
1417
|
+
`,
|
|
1371
1418
|
exported: outdent22`
|
|
1419
|
+
import './global'
|
|
1372
1420
|
export { ConditionalValue } from './conditions'
|
|
1373
1421
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1374
1422
|
|
|
@@ -1394,8 +1442,7 @@ function setupHelpers(ctx) {
|
|
|
1394
1442
|
const sharedMjs = getEntrypoint("@pandacss/shared", { dev: "shared.mjs" });
|
|
1395
1443
|
const code = readFileSync3(sharedMjs, "utf-8");
|
|
1396
1444
|
return {
|
|
1397
|
-
|
|
1398
|
-
files: [{ file: ctx.getJsFile("helpers"), code }]
|
|
1445
|
+
files: [{ file: ctx.getExt("helpers"), code }]
|
|
1399
1446
|
};
|
|
1400
1447
|
}
|
|
1401
1448
|
function setupKeyframes(ctx) {
|
|
@@ -1406,9 +1453,8 @@ function setupKeyframes(ctx) {
|
|
|
1406
1453
|
};
|
|
1407
1454
|
}
|
|
1408
1455
|
function setupDesignTokens(ctx) {
|
|
1409
|
-
if (ctx.tokens.isEmpty)
|
|
1410
|
-
return
|
|
1411
|
-
}
|
|
1456
|
+
if (ctx.tokens.isEmpty)
|
|
1457
|
+
return;
|
|
1412
1458
|
const code = generateTokenJs(ctx.tokens);
|
|
1413
1459
|
const css2 = generateTokenCss(ctx);
|
|
1414
1460
|
return {
|
|
@@ -1416,7 +1462,7 @@ function setupDesignTokens(ctx) {
|
|
|
1416
1462
|
files: [
|
|
1417
1463
|
{ file: "index.css", code: css2 },
|
|
1418
1464
|
{ file: "index.d.ts", code: code.dts },
|
|
1419
|
-
{ file: ctx.
|
|
1465
|
+
{ file: ctx.getExt("index"), code: code.js }
|
|
1420
1466
|
]
|
|
1421
1467
|
};
|
|
1422
1468
|
}
|
|
@@ -1431,6 +1477,8 @@ function setupTypes(ctx) {
|
|
|
1431
1477
|
{ file: "csstype.d.ts", code: types.css },
|
|
1432
1478
|
{ file: "system-types.d.ts", code: types.system },
|
|
1433
1479
|
{ file: "selectors.d.ts", code: types.selectors },
|
|
1480
|
+
{ file: "composition.d.ts", code: types.composition },
|
|
1481
|
+
{ file: "global.d.ts", code: types.global },
|
|
1434
1482
|
{ file: "recipe.d.ts", code: types.recipe },
|
|
1435
1483
|
{ file: "index.d.ts", code: types.exported },
|
|
1436
1484
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
@@ -1446,18 +1494,18 @@ function setupCss(ctx) {
|
|
|
1446
1494
|
return {
|
|
1447
1495
|
dir: ctx.paths.css,
|
|
1448
1496
|
files: [
|
|
1449
|
-
{ file: ctx.
|
|
1450
|
-
{ file: ctx.
|
|
1497
|
+
{ file: ctx.getExt("conditions"), code: conditions.js },
|
|
1498
|
+
{ file: ctx.getExt("css"), code: code.js },
|
|
1451
1499
|
{ file: "css.d.ts", code: code.dts }
|
|
1452
1500
|
]
|
|
1453
1501
|
};
|
|
1454
1502
|
}
|
|
1455
1503
|
function setupCva(ctx) {
|
|
1456
|
-
const code = generateCvaFn();
|
|
1504
|
+
const code = generateCvaFn(ctx);
|
|
1457
1505
|
return {
|
|
1458
1506
|
dir: ctx.paths.css,
|
|
1459
1507
|
files: [
|
|
1460
|
-
{ file: ctx.
|
|
1508
|
+
{ file: ctx.getExt("cva"), code: code.js },
|
|
1461
1509
|
{ file: "cva.d.ts", code: code.dts }
|
|
1462
1510
|
]
|
|
1463
1511
|
};
|
|
@@ -1467,94 +1515,111 @@ function setupCx(ctx) {
|
|
|
1467
1515
|
return {
|
|
1468
1516
|
dir: ctx.paths.css,
|
|
1469
1517
|
files: [
|
|
1470
|
-
{ file: ctx.
|
|
1518
|
+
{ file: ctx.getExt("cx"), code: code.js },
|
|
1471
1519
|
{ file: "cx.d.ts", code: code.dts }
|
|
1472
1520
|
]
|
|
1473
1521
|
};
|
|
1474
1522
|
}
|
|
1475
1523
|
function setupRecipes(ctx) {
|
|
1476
1524
|
const code = generateRecipes(ctx);
|
|
1477
|
-
if (!code)
|
|
1478
|
-
return
|
|
1479
|
-
}
|
|
1525
|
+
if (!code)
|
|
1526
|
+
return;
|
|
1480
1527
|
return {
|
|
1481
1528
|
dir: ctx.paths.recipe,
|
|
1482
1529
|
files: [
|
|
1483
|
-
{ file: ctx.
|
|
1530
|
+
{ file: ctx.getExt("index"), code: code.js },
|
|
1484
1531
|
{ file: "index.d.ts", code: code.dts }
|
|
1485
1532
|
]
|
|
1486
1533
|
};
|
|
1487
1534
|
}
|
|
1488
1535
|
function setupPatterns(ctx) {
|
|
1489
1536
|
const files = generatePattern(ctx);
|
|
1490
|
-
if (!files)
|
|
1491
|
-
return
|
|
1492
|
-
|
|
1493
|
-
|
|
1537
|
+
if (!files)
|
|
1538
|
+
return;
|
|
1539
|
+
const index = {
|
|
1540
|
+
js: outdent23.string(files.map((file) => ctx.getExport(`./${file.name}`)).join("\n")),
|
|
1541
|
+
dts: outdent23.string(files.map((file) => `export { ${file.name} } from './${file.name}'`).join("\n"))
|
|
1542
|
+
};
|
|
1494
1543
|
return {
|
|
1495
1544
|
dir: ctx.paths.pattern,
|
|
1496
1545
|
files: [
|
|
1497
|
-
...files.map((file) => ({ file: ctx.
|
|
1546
|
+
...files.map((file) => ({ file: ctx.getExt(file.name), code: file.js })),
|
|
1498
1547
|
...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1499
|
-
{ file: ctx.
|
|
1500
|
-
{ file: "index.d.ts", code:
|
|
1548
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1549
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1501
1550
|
]
|
|
1502
1551
|
};
|
|
1503
1552
|
}
|
|
1504
1553
|
function setupJsx(ctx) {
|
|
1505
1554
|
if (!ctx.jsxFramework)
|
|
1506
|
-
return
|
|
1555
|
+
return;
|
|
1507
1556
|
const isValidProp = generateisValidProp(ctx);
|
|
1508
1557
|
const types = generateJsxTypes(ctx);
|
|
1509
1558
|
const factory = generateJsxFactory(ctx);
|
|
1510
1559
|
const patterns = generateJsxPatterns(ctx);
|
|
1511
1560
|
const layoutGrid = generateLayoutGrid(ctx);
|
|
1512
|
-
const
|
|
1561
|
+
const index = {
|
|
1562
|
+
js: outdent23`
|
|
1563
|
+
${ctx.getExport("./factory")}
|
|
1564
|
+
${ctx.getExport("./layout-grid")}
|
|
1565
|
+
${outdent23.string(patterns.map((file) => ctx.getExport(`./${file.name}`)).join("\n"))}
|
|
1566
|
+
`,
|
|
1567
|
+
dts: outdent23`
|
|
1513
1568
|
export * from './factory'
|
|
1514
1569
|
export * from './layout-grid'
|
|
1515
1570
|
${outdent23.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1516
|
-
|
|
1571
|
+
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1572
|
+
`
|
|
1573
|
+
};
|
|
1517
1574
|
return {
|
|
1518
1575
|
dir: ctx.paths.jsx,
|
|
1519
1576
|
files: [
|
|
1520
|
-
...patterns.map((file) => ({ file: `${file.name}.
|
|
1577
|
+
...patterns.map((file) => ({ file: `${file.name}.mjs`, code: file.js })),
|
|
1521
1578
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1522
|
-
{ file: "layout-grid.
|
|
1579
|
+
{ file: "layout-grid.mjs", code: layoutGrid.js },
|
|
1523
1580
|
{ file: "layout-grid.d.ts", code: layoutGrid.dts },
|
|
1524
|
-
{ file: ctx.
|
|
1581
|
+
{ file: ctx.getExt("is-valid-prop"), code: isValidProp.js },
|
|
1525
1582
|
{ file: "factory.d.ts", code: types.jsxFactory },
|
|
1526
|
-
{ file: "factory.
|
|
1527
|
-
{
|
|
1528
|
-
|
|
1529
|
-
code: outdent23`
|
|
1530
|
-
${indexCode}
|
|
1531
|
-
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1532
|
-
`
|
|
1533
|
-
},
|
|
1534
|
-
{ file: "index.jsx", code: indexCode }
|
|
1583
|
+
{ file: "factory.mjs", code: factory.js },
|
|
1584
|
+
{ file: "index.d.ts", code: index.dts },
|
|
1585
|
+
{ file: "index.mjs", code: index.js }
|
|
1535
1586
|
]
|
|
1536
1587
|
};
|
|
1537
1588
|
}
|
|
1538
1589
|
function setupCssIndex(ctx) {
|
|
1539
|
-
const
|
|
1590
|
+
const index = {
|
|
1591
|
+
js: outdent23`
|
|
1592
|
+
${ctx.getExport("./css")}
|
|
1593
|
+
${ctx.getExport("./cx")}
|
|
1594
|
+
${ctx.getExport("./cva")}
|
|
1595
|
+
`,
|
|
1596
|
+
dts: outdent23`
|
|
1540
1597
|
export * from './css'
|
|
1541
1598
|
export * from './cx'
|
|
1542
1599
|
export * from './cva'
|
|
1543
|
-
|
|
1600
|
+
`
|
|
1601
|
+
};
|
|
1544
1602
|
return {
|
|
1545
1603
|
dir: ctx.paths.css,
|
|
1546
1604
|
files: [
|
|
1547
|
-
{ file: ctx.
|
|
1548
|
-
{ file: "index.d.ts", code }
|
|
1605
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1606
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1549
1607
|
]
|
|
1550
1608
|
};
|
|
1551
1609
|
}
|
|
1552
1610
|
function setupReset(ctx) {
|
|
1553
1611
|
if (!ctx.preflight)
|
|
1554
|
-
return
|
|
1612
|
+
return;
|
|
1555
1613
|
const code = generateReset();
|
|
1556
1614
|
return { files: [{ file: "reset.css", code }] };
|
|
1557
1615
|
}
|
|
1616
|
+
function setupPackageJson(ctx) {
|
|
1617
|
+
if (!ctx.emitPackage)
|
|
1618
|
+
return;
|
|
1619
|
+
return {
|
|
1620
|
+
files: [{ file: "package.json", code: generatePackageJSON(ctx) }]
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1558
1623
|
function generateSystem(ctx) {
|
|
1559
1624
|
return [
|
|
1560
1625
|
setupHelpers(ctx),
|
|
@@ -1568,8 +1633,9 @@ function generateSystem(ctx) {
|
|
|
1568
1633
|
setupPatterns(ctx),
|
|
1569
1634
|
setupCssIndex(ctx),
|
|
1570
1635
|
setupJsx(ctx),
|
|
1571
|
-
setupReset(ctx)
|
|
1572
|
-
|
|
1636
|
+
setupReset(ctx),
|
|
1637
|
+
setupPackageJson(ctx)
|
|
1638
|
+
].filter(Boolean);
|
|
1573
1639
|
}
|
|
1574
1640
|
|
|
1575
1641
|
// src/messages.ts
|
|
@@ -1654,10 +1720,14 @@ async function emitArtifacts(ctx) {
|
|
|
1654
1720
|
}
|
|
1655
1721
|
async function emitAndExtract(ctx) {
|
|
1656
1722
|
await emitArtifacts(ctx);
|
|
1723
|
+
return extractCss(ctx);
|
|
1724
|
+
}
|
|
1725
|
+
async function extractCss(ctx) {
|
|
1657
1726
|
await extractGlobalCss(ctx);
|
|
1658
1727
|
await extractStaticCss(ctx);
|
|
1659
1728
|
await extractFiles(ctx);
|
|
1660
1729
|
await bundleChunks(ctx);
|
|
1730
|
+
return buildCompleteMessage(ctx);
|
|
1661
1731
|
}
|
|
1662
1732
|
function getBaseCss(ctx) {
|
|
1663
1733
|
const css2 = [
|
|
@@ -1737,7 +1807,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
1737
1807
|
globalCss,
|
|
1738
1808
|
separator,
|
|
1739
1809
|
static: staticCss,
|
|
1740
|
-
outExtension = "mjs"
|
|
1810
|
+
outExtension = "mjs",
|
|
1811
|
+
emitPackage
|
|
1741
1812
|
} = config;
|
|
1742
1813
|
const {
|
|
1743
1814
|
breakpoints = {},
|
|
@@ -1755,9 +1826,10 @@ function createContext(conf, io = fileSystem) {
|
|
|
1755
1826
|
framework: jsxFramework
|
|
1756
1827
|
};
|
|
1757
1828
|
const cwd = resolve(cwdProp);
|
|
1758
|
-
const exclude = [".git", "node_modules", "test-results"].concat(excludeProp);
|
|
1829
|
+
const exclude = [".git", ".yarn", "node_modules", "test-results"].concat(excludeProp);
|
|
1759
1830
|
const tokens = new TokenDictionary({
|
|
1760
1831
|
tokens: tokensProp,
|
|
1832
|
+
breakpoints,
|
|
1761
1833
|
semanticTokens,
|
|
1762
1834
|
prefix: cssVarPrefix
|
|
1763
1835
|
});
|
|
@@ -1850,14 +1922,24 @@ function createContext(conf, io = fileSystem) {
|
|
|
1850
1922
|
function isStyleProp(prop) {
|
|
1851
1923
|
return isCssProperty(prop) || isCustomCssProperty(prop);
|
|
1852
1924
|
}
|
|
1853
|
-
function getPath(
|
|
1854
|
-
|
|
1925
|
+
function getPath(pathLike) {
|
|
1926
|
+
const paths2 = [cwd, emitPackage ? "node_modules" : void 0, outdir, pathLike].filter(Boolean);
|
|
1927
|
+
return join2(...paths2);
|
|
1855
1928
|
}
|
|
1856
1929
|
function absPath(str) {
|
|
1857
1930
|
return isAbsolute(str) ? str : join2(cwd, str);
|
|
1858
1931
|
}
|
|
1932
|
+
function getExt(file) {
|
|
1933
|
+
return `${file}.${outExtension}`;
|
|
1934
|
+
}
|
|
1935
|
+
function getImport(items, mod) {
|
|
1936
|
+
return `import { ${items} } from '${getExt(mod)}';`;
|
|
1937
|
+
}
|
|
1938
|
+
function getExport(mod) {
|
|
1939
|
+
return `export * from '${getExt(mod)}';`;
|
|
1940
|
+
}
|
|
1859
1941
|
const paths = {
|
|
1860
|
-
|
|
1942
|
+
root: getPath(),
|
|
1861
1943
|
css: getPath("css"),
|
|
1862
1944
|
token: getPath("tokens"),
|
|
1863
1945
|
types: getPath("types"),
|
|
@@ -1879,15 +1961,14 @@ function createContext(conf, io = fileSystem) {
|
|
|
1879
1961
|
);
|
|
1880
1962
|
}
|
|
1881
1963
|
function cleanOutdir() {
|
|
1882
|
-
return emptyDir(
|
|
1964
|
+
return emptyDir(paths.root);
|
|
1883
1965
|
}
|
|
1884
1966
|
function writeOutput(output) {
|
|
1885
|
-
|
|
1967
|
+
if (!output)
|
|
1968
|
+
return;
|
|
1969
|
+
const { dir = paths.root, files: files2 } = output;
|
|
1886
1970
|
return write(dir, files2);
|
|
1887
1971
|
}
|
|
1888
|
-
function getJsFile(file) {
|
|
1889
|
-
return `${file}.${outExtension}`;
|
|
1890
|
-
}
|
|
1891
1972
|
const chunks = {
|
|
1892
1973
|
dir: paths.chunk,
|
|
1893
1974
|
readFile(file) {
|
|
@@ -2092,7 +2173,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
2092
2173
|
write,
|
|
2093
2174
|
writeOutput,
|
|
2094
2175
|
cleanOutdir,
|
|
2095
|
-
|
|
2176
|
+
getExt,
|
|
2177
|
+
getImport,
|
|
2178
|
+
getExport,
|
|
2096
2179
|
cssVarRoot,
|
|
2097
2180
|
tokens,
|
|
2098
2181
|
hasTokens,
|
|
@@ -2378,8 +2461,8 @@ process.on("uncaughtException", (err) => {
|
|
|
2378
2461
|
// src/generate.ts
|
|
2379
2462
|
async function build(config, configPath) {
|
|
2380
2463
|
const ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2381
|
-
await emitAndExtract(ctx);
|
|
2382
|
-
logger8.info(
|
|
2464
|
+
const msg = await emitAndExtract(ctx);
|
|
2465
|
+
logger8.info(msg);
|
|
2383
2466
|
return ctx;
|
|
2384
2467
|
}
|
|
2385
2468
|
async function generate5(config, configPath) {
|
|
@@ -2479,6 +2562,7 @@ export {
|
|
|
2479
2562
|
emitAndExtract,
|
|
2480
2563
|
emitArtifacts,
|
|
2481
2564
|
execCommand,
|
|
2565
|
+
extractCss,
|
|
2482
2566
|
generate5 as generate,
|
|
2483
2567
|
loadConfigAndCreateContext,
|
|
2484
2568
|
setupConfig,
|