@pandacss/node 0.0.0-dev-20230122145009 → 0.0.0-dev-20230125073613
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 +33 -19
- package/dist/index.js +357 -263
- package/dist/index.mjs +356 -263
- 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, hypenateProperty, withoutSpace", "../helpers")}
|
|
166
|
+
${ctx.getImport("sortConditions, finalizeConditions", "./conditions")}
|
|
166
167
|
|
|
167
168
|
const classNameMap = ${stringify(utility.entries())}
|
|
168
169
|
|
|
@@ -176,7 +177,7 @@ function generateCssFn(ctx) {
|
|
|
176
177
|
|
|
177
178
|
function transform(prop, value) {
|
|
178
179
|
const key = resolveShorthand(prop)
|
|
179
|
-
const propKey = classNameMap[key] ||
|
|
180
|
+
const propKey = classNameMap[key] || hypenateProperty(key)
|
|
180
181
|
const className = \`$\{propKey}${separator}$\{withoutSpace(value)}\`
|
|
181
182
|
return { className }
|
|
182
183
|
}
|
|
@@ -189,6 +190,7 @@ function generateCssFn(ctx) {
|
|
|
189
190
|
breakpoints: { keys: breakpointKeys }
|
|
190
191
|
},
|
|
191
192
|
utility: {
|
|
193
|
+
prefix: ${ctx.prefix ? JSON.stringify(ctx.prefix) : void 0},
|
|
192
194
|
transform,
|
|
193
195
|
hasShorthand,
|
|
194
196
|
resolveShorthand,
|
|
@@ -204,11 +206,11 @@ function generateCssFn(ctx) {
|
|
|
204
206
|
|
|
205
207
|
// src/generators/cva.ts
|
|
206
208
|
import { outdent as outdent3 } from "outdent";
|
|
207
|
-
function generateCvaFn() {
|
|
209
|
+
function generateCvaFn(ctx) {
|
|
208
210
|
return {
|
|
209
211
|
js: outdent3`
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
${ctx.getImport("compact", "../helpers")}
|
|
213
|
+
${ctx.getImport("css, mergeCss", "./css")}
|
|
212
214
|
|
|
213
215
|
export function cva(config) {
|
|
214
216
|
const { base = {}, variants = {}, defaultVariants = {} } = config
|
|
@@ -237,7 +239,7 @@ function generateCvaFn() {
|
|
|
237
239
|
}
|
|
238
240
|
`,
|
|
239
241
|
dts: outdent3`
|
|
240
|
-
import { RecipeCreatorFn } from '../types/recipe'
|
|
242
|
+
import type { RecipeCreatorFn } from '../types/recipe'
|
|
241
243
|
|
|
242
244
|
export declare const cva: RecipeCreatorFn
|
|
243
245
|
|
|
@@ -316,9 +318,9 @@ function generatePreactJsxFactory(ctx) {
|
|
|
316
318
|
import { h } from 'preact'
|
|
317
319
|
import { forwardRef } from 'preact/compat'
|
|
318
320
|
import { useMemo } from 'preact/hooks'
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
${ctx.getImport("css, cx, assignCss", "../css/index")}
|
|
322
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
323
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
322
324
|
|
|
323
325
|
function styled(Dynamic, configOrCva = {}) {
|
|
324
326
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -330,7 +332,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
330
332
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
331
333
|
}, [restProps])
|
|
332
334
|
|
|
333
|
-
function classes(){
|
|
335
|
+
function classes() {
|
|
334
336
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
335
337
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
336
338
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
@@ -378,47 +380,39 @@ function generatePreactLayoutGrid() {
|
|
|
378
380
|
import { FunctionComponent } from 'preact'
|
|
379
381
|
|
|
380
382
|
export type LayoutGridProps = {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
count?: number
|
|
384
|
+
gutter?: string
|
|
385
|
+
maxWidth?: string
|
|
386
|
+
margin?: string
|
|
387
|
+
outline?: boolean
|
|
385
388
|
}
|
|
386
389
|
|
|
387
390
|
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
388
391
|
`,
|
|
389
392
|
js: outdent6`
|
|
393
|
+
import { h } from 'preact'
|
|
394
|
+
|
|
390
395
|
export function LayoutGrid(props) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
key={i}
|
|
412
|
-
style={{
|
|
413
|
-
display: 'flex',
|
|
414
|
-
background: 'rgba(255, 0, 0, 0.1)',
|
|
415
|
-
height: '100%',
|
|
416
|
-
}}
|
|
417
|
-
/>
|
|
418
|
-
))}
|
|
419
|
-
</div>
|
|
420
|
-
);
|
|
421
|
-
}
|
|
396
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
397
|
+
const hasMaxWidth = maxWidth != null
|
|
398
|
+
return h('div', {
|
|
399
|
+
className: 'panda-layout-grid',
|
|
400
|
+
style: {
|
|
401
|
+
'--gutter': gutter,
|
|
402
|
+
'--count': count,
|
|
403
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
404
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
405
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
406
|
+
},
|
|
407
|
+
children: Array.from({ length: count }).map((_, i) =>
|
|
408
|
+
h('span', {
|
|
409
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
410
|
+
key: i,
|
|
411
|
+
className: 'panda-layout-grid__item',
|
|
412
|
+
}),
|
|
413
|
+
),
|
|
414
|
+
});
|
|
415
|
+
}
|
|
422
416
|
`
|
|
423
417
|
};
|
|
424
418
|
}
|
|
@@ -432,29 +426,30 @@ function generate(ctx, name, pattern) {
|
|
|
432
426
|
return {
|
|
433
427
|
name: dashName,
|
|
434
428
|
js: outdent7`
|
|
429
|
+
import { h } from 'preact'
|
|
435
430
|
import { forwardRef } from 'preact/compat'
|
|
436
|
-
|
|
437
|
-
|
|
431
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
432
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
438
433
|
|
|
439
434
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
440
435
|
${match(props.length).with(
|
|
441
436
|
0,
|
|
442
437
|
() => outdent7`
|
|
443
|
-
return
|
|
438
|
+
return h(${ctx.jsxFactory}.div, { ref, ...props })
|
|
444
439
|
`
|
|
445
440
|
).otherwise(
|
|
446
441
|
() => outdent7`
|
|
447
442
|
const { ${props.join(", ")}, ...restProps } = props
|
|
448
443
|
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
449
|
-
return
|
|
444
|
+
return h(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
450
445
|
`
|
|
451
446
|
)}
|
|
452
447
|
})
|
|
453
448
|
`,
|
|
454
449
|
dts: outdent7`
|
|
455
|
-
import { FunctionComponent } from 'preact'
|
|
456
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
457
|
-
import { ${typeName} } from '../types/jsx'
|
|
450
|
+
import type { FunctionComponent } from 'preact'
|
|
451
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
452
|
+
import type { ${typeName} } from '../types/jsx'
|
|
458
453
|
|
|
459
454
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
460
455
|
|
|
@@ -473,25 +468,25 @@ function generatePreactJsxTypes(ctx) {
|
|
|
473
468
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
474
469
|
return {
|
|
475
470
|
jsxFactory: outdent8`
|
|
476
|
-
import { ${upperName} } from '../types/jsx'
|
|
471
|
+
import type { ${upperName} } from '../types/jsx'
|
|
477
472
|
export declare const ${name}: ${upperName}
|
|
478
473
|
`,
|
|
479
474
|
jsxType: outdent8`
|
|
480
|
-
import { JSX, ComponentProps } from 'preact'
|
|
481
|
-
import { JsxStyleProps, Assign } from '.'
|
|
482
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
475
|
+
import type { JSX, ComponentProps } from 'preact'
|
|
476
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
477
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
483
478
|
|
|
484
479
|
type Dict = Record<string, unknown>
|
|
485
480
|
type ElementType = keyof JSX.IntrinsicElements
|
|
486
481
|
|
|
487
|
-
type
|
|
482
|
+
type HTMLProps = {
|
|
488
483
|
htmlSize?: string | number
|
|
489
484
|
htmlWidth?: string | number
|
|
490
485
|
htmlHeight?: string | number
|
|
491
486
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
492
487
|
}
|
|
493
488
|
|
|
494
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
489
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
495
490
|
|
|
496
491
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
497
492
|
|
|
@@ -515,10 +510,10 @@ function generateReactJsxFactory(ctx) {
|
|
|
515
510
|
const { name, componentName } = ctx.jsxFactoryDetails;
|
|
516
511
|
return {
|
|
517
512
|
js: outdent9`
|
|
518
|
-
import { forwardRef, useMemo } from 'react'
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
513
|
+
import { createElement, forwardRef, useMemo } from 'react'
|
|
514
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
515
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
516
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
522
517
|
|
|
523
518
|
function styled(Dynamic, configOrCva = {}) {
|
|
524
519
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -530,21 +525,19 @@ function generateReactJsxFactory(ctx) {
|
|
|
530
525
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
531
526
|
}, [restProps])
|
|
532
527
|
|
|
533
|
-
function classes(){
|
|
528
|
+
function classes() {
|
|
534
529
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
535
530
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
536
531
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
537
532
|
return cx(css(styles), elementProps.className)
|
|
538
533
|
}
|
|
539
534
|
|
|
540
|
-
return(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
/>
|
|
547
|
-
)
|
|
535
|
+
return createElement(Element, {
|
|
536
|
+
ref,
|
|
537
|
+
...elementProps,
|
|
538
|
+
...normalizeHTMLProps(htmlProps),
|
|
539
|
+
className: classes(),
|
|
540
|
+
})
|
|
548
541
|
})
|
|
549
542
|
|
|
550
543
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -581,47 +574,39 @@ function generateReactLayoutGrid() {
|
|
|
581
574
|
import type { FunctionComponent } from 'react'
|
|
582
575
|
|
|
583
576
|
export type LayoutGridProps = {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
577
|
+
count?: number
|
|
578
|
+
gutter?: string
|
|
579
|
+
maxWidth?: string
|
|
580
|
+
margin?: string
|
|
581
|
+
outline?: boolean
|
|
588
582
|
}
|
|
589
583
|
|
|
590
584
|
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
591
585
|
`,
|
|
592
586
|
js: outdent10`
|
|
587
|
+
import { createElement } from 'react'
|
|
588
|
+
|
|
593
589
|
export function LayoutGrid(props) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
-
}
|
|
590
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
591
|
+
const hasMaxWidth = maxWidth != null
|
|
592
|
+
return createElement('div', {
|
|
593
|
+
className: 'panda-layout-grid',
|
|
594
|
+
style: {
|
|
595
|
+
'--gutter': gutter,
|
|
596
|
+
'--count': count,
|
|
597
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
598
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
599
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
600
|
+
},
|
|
601
|
+
children: Array.from({ length: count }).map((_, i) =>
|
|
602
|
+
createElement('span', {
|
|
603
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
604
|
+
key: i,
|
|
605
|
+
className: 'panda-layout-grid__item',
|
|
606
|
+
}),
|
|
607
|
+
),
|
|
608
|
+
})
|
|
609
|
+
}
|
|
625
610
|
`
|
|
626
611
|
};
|
|
627
612
|
}
|
|
@@ -635,30 +620,29 @@ function generate2(ctx, name, pattern) {
|
|
|
635
620
|
return {
|
|
636
621
|
name: dashName,
|
|
637
622
|
js: outdent11`
|
|
638
|
-
import { forwardRef } from 'react'
|
|
639
|
-
|
|
640
|
-
|
|
623
|
+
import { createElement, forwardRef } from 'react'
|
|
624
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
625
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
641
626
|
|
|
642
627
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
643
628
|
${match2(props.length).with(
|
|
644
629
|
0,
|
|
645
630
|
() => outdent11`
|
|
646
|
-
|
|
631
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...props })
|
|
647
632
|
`
|
|
648
633
|
).otherwise(
|
|
649
634
|
() => outdent11`
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
635
|
+
const { ${props.join(", ")}, ...restProps } = props
|
|
636
|
+
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
637
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
653
638
|
`
|
|
654
639
|
)}
|
|
655
|
-
|
|
656
640
|
})
|
|
657
641
|
`,
|
|
658
642
|
dts: outdent11`
|
|
659
|
-
import { FunctionComponent } from 'react'
|
|
660
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
661
|
-
import { ${typeName} } from '../types/jsx'
|
|
643
|
+
import type { FunctionComponent } from 'react'
|
|
644
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
645
|
+
import type { ${typeName} } from '../types/jsx'
|
|
662
646
|
|
|
663
647
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
664
648
|
|
|
@@ -681,20 +665,20 @@ import { ${upperName} } from '../types/jsx'
|
|
|
681
665
|
export declare const ${name}: ${upperName}
|
|
682
666
|
`,
|
|
683
667
|
jsxType: outdent12`
|
|
684
|
-
import { ElementType, ComponentProps } from 'react'
|
|
685
|
-
import { JsxStyleProps, Assign } from '.'
|
|
686
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
668
|
+
import type { ElementType, ComponentProps } from 'react'
|
|
669
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
670
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
687
671
|
|
|
688
672
|
type Dict = Record<string, unknown>
|
|
689
673
|
|
|
690
|
-
type
|
|
674
|
+
type HTMLProps = {
|
|
691
675
|
htmlSize?: string | number
|
|
692
676
|
htmlWidth?: string | number
|
|
693
677
|
htmlHeight?: string | number
|
|
694
678
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
695
679
|
}
|
|
696
680
|
|
|
697
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
681
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
698
682
|
|
|
699
683
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
700
684
|
|
|
@@ -720,9 +704,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
720
704
|
js: outdent13`
|
|
721
705
|
import { Dynamic } from 'solid-js/web'
|
|
722
706
|
import { mergeProps, splitProps } from 'solid-js'
|
|
723
|
-
import {
|
|
724
|
-
|
|
725
|
-
|
|
707
|
+
import { createComponent } from 'solid-js/web'
|
|
708
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
709
|
+
${ctx.getImport("normalizeHTMLProps", "../helpers")}
|
|
710
|
+
${ctx.getImport("allCssProperties", "./is-valid-prop")}
|
|
726
711
|
|
|
727
712
|
function styled(element, configOrCva = {}) {
|
|
728
713
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -730,10 +715,11 @@ function generateSolidJsxFactory(ctx) {
|
|
|
730
715
|
return function ${componentName}(props) {
|
|
731
716
|
const mergedProps = mergeProps({ as: element }, props)
|
|
732
717
|
|
|
733
|
-
const [localProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
718
|
+
const [localProps, styleProps, variantProps, htmlProps, elementProps] = splitProps(
|
|
734
719
|
mergedProps,
|
|
735
720
|
['as', 'class'],
|
|
736
721
|
allCssProperties,
|
|
722
|
+
cvaFn.variants,
|
|
737
723
|
normalizeHTMLProps.keys
|
|
738
724
|
)
|
|
739
725
|
|
|
@@ -744,13 +730,20 @@ function generateSolidJsxFactory(ctx) {
|
|
|
744
730
|
return cx(css(styles), localProps.class)
|
|
745
731
|
}
|
|
746
732
|
|
|
747
|
-
return (
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
{
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
733
|
+
return createComponent(
|
|
734
|
+
Dynamic,
|
|
735
|
+
mergeProps(
|
|
736
|
+
{
|
|
737
|
+
get component() {
|
|
738
|
+
return localProps.as
|
|
739
|
+
},
|
|
740
|
+
get class() {
|
|
741
|
+
return classes()
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
elementProps,
|
|
745
|
+
normalizeHTMLProps(htmlProps)
|
|
746
|
+
)
|
|
754
747
|
)
|
|
755
748
|
}
|
|
756
749
|
}
|
|
@@ -781,50 +774,48 @@ import { outdent as outdent14 } from "outdent";
|
|
|
781
774
|
function generateSolidLayoutGrid() {
|
|
782
775
|
return {
|
|
783
776
|
dts: outdent14`
|
|
784
|
-
import { ParentProps } from 'solid-js'
|
|
777
|
+
import type { ParentProps } from 'solid-js'
|
|
785
778
|
|
|
786
779
|
export type LayoutGridProps = {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
780
|
+
count?: number
|
|
781
|
+
gutter?: string
|
|
782
|
+
maxWidth?: string
|
|
783
|
+
margin?: string
|
|
784
|
+
outline?: boolean
|
|
791
785
|
}
|
|
792
786
|
|
|
793
787
|
export declare const LayoutGrid: ParentProps<LayoutGridProps>
|
|
794
788
|
`,
|
|
795
789
|
js: outdent14`
|
|
790
|
+
import { createComponent, For } from 'solid-js/web'
|
|
791
|
+
|
|
796
792
|
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
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
/>
|
|
824
|
-
))}
|
|
825
|
-
</div>
|
|
826
|
-
);
|
|
827
|
-
}
|
|
793
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
794
|
+
const hasMaxWidth = maxWidth != null
|
|
795
|
+
return createComponent('div', {
|
|
796
|
+
className: 'panda-layout-grid',
|
|
797
|
+
style: {
|
|
798
|
+
'--gutter': gutter,
|
|
799
|
+
'--count': count,
|
|
800
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
801
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
802
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
803
|
+
},
|
|
804
|
+
get children() {
|
|
805
|
+
return createComponent(For, {
|
|
806
|
+
get each() {
|
|
807
|
+
return Array.from({ length: count })
|
|
808
|
+
},
|
|
809
|
+
children: () =>
|
|
810
|
+
createComponent('span', {
|
|
811
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
812
|
+
className: 'panda-layout-grid__item',
|
|
813
|
+
}),
|
|
814
|
+
})
|
|
815
|
+
},
|
|
816
|
+
})
|
|
817
|
+
}
|
|
818
|
+
|
|
828
819
|
`
|
|
829
820
|
};
|
|
830
821
|
}
|
|
@@ -838,21 +829,22 @@ function generate3(ctx, name, pattern) {
|
|
|
838
829
|
return {
|
|
839
830
|
name: dashName,
|
|
840
831
|
js: outdent15`
|
|
841
|
-
import { splitProps } from 'solid-js'
|
|
842
|
-
import {
|
|
843
|
-
|
|
832
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
833
|
+
import { createComponent } from 'solid-js/web'
|
|
834
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
835
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
844
836
|
|
|
845
837
|
export function ${jsxName}(props) {
|
|
846
838
|
${match3(props.length).with(
|
|
847
839
|
0,
|
|
848
840
|
() => outdent15`
|
|
849
|
-
return
|
|
841
|
+
return createComponent(${ctx.jsxFactory}.div, props)
|
|
850
842
|
`
|
|
851
843
|
).otherwise(
|
|
852
844
|
() => outdent15`
|
|
853
845
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
854
846
|
const styleProps = ${styleFn}(patternProps)
|
|
855
|
-
return
|
|
847
|
+
return createComponent(${ctx.jsxFactory}.div, mergeProps(styleProps, restProps))
|
|
856
848
|
`
|
|
857
849
|
)}
|
|
858
850
|
}
|
|
@@ -879,26 +871,26 @@ function generateSolidJsxTypes(ctx) {
|
|
|
879
871
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
880
872
|
return {
|
|
881
873
|
jsxFactory: outdent16`
|
|
882
|
-
import { ${upperName} } from '../types/jsx'
|
|
874
|
+
import type { ${upperName} } from '../types/jsx'
|
|
883
875
|
export declare const ${name}: ${upperName}
|
|
884
876
|
`,
|
|
885
877
|
jsxType: outdent16`
|
|
886
|
-
import { JSX, ComponentProps, Component } from 'solid-js'
|
|
887
|
-
import { JsxStyleProps, Assign } from '.'
|
|
888
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
878
|
+
import type { JSX, ComponentProps, Component } from 'solid-js'
|
|
879
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
880
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
889
881
|
|
|
890
882
|
type Dict = Record<string, unknown>
|
|
891
883
|
|
|
892
884
|
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
893
885
|
|
|
894
|
-
type
|
|
886
|
+
type HTMLProps = {
|
|
895
887
|
htmlSize?: string | number
|
|
896
888
|
htmlWidth?: string | number
|
|
897
889
|
htmlHeight?: string | number
|
|
898
890
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
899
891
|
}
|
|
900
892
|
|
|
901
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
893
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
902
894
|
|
|
903
895
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
904
896
|
|
|
@@ -965,10 +957,10 @@ function generate4(ctx, name, pattern) {
|
|
|
965
957
|
return {
|
|
966
958
|
name: dashCase(name),
|
|
967
959
|
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'
|
|
960
|
+
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
961
|
+
import type { PropertyValue } from '../types/prop-type'
|
|
962
|
+
import type { Properties } from '../types/csstype'
|
|
963
|
+
import type { Tokens } from '../types/token'
|
|
972
964
|
|
|
973
965
|
export type ${capitalize(name)}Properties = {
|
|
974
966
|
${Object.keys(properties ?? {}).map((key) => {
|
|
@@ -998,8 +990,8 @@ function generate4(ctx, name, pattern) {
|
|
|
998
990
|
|
|
999
991
|
`,
|
|
1000
992
|
js: outdent17`
|
|
1001
|
-
|
|
1002
|
-
|
|
993
|
+
${ctx.getImport("mapObject", "../helpers")}
|
|
994
|
+
${ctx.getImport("css", "../css/index")}
|
|
1003
995
|
|
|
1004
996
|
const config = ${stringify2({ transform })}
|
|
1005
997
|
|
|
@@ -1015,15 +1007,35 @@ function generatePattern(ctx) {
|
|
|
1015
1007
|
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(ctx, name, pattern));
|
|
1016
1008
|
}
|
|
1017
1009
|
|
|
1010
|
+
// src/generators/pkg-json.ts
|
|
1011
|
+
function generatePackageJSON(ctx) {
|
|
1012
|
+
const pkg = {
|
|
1013
|
+
name: ctx.outdir,
|
|
1014
|
+
description: "This package is auto-generated by CSS Panda",
|
|
1015
|
+
version: `0.0.0-${performance.now()}`,
|
|
1016
|
+
type: "module",
|
|
1017
|
+
exports: {
|
|
1018
|
+
"./css": { types: "./css/index.d.ts", import: "./css/index.mjs" },
|
|
1019
|
+
"./jsx": { types: "./jsx/index.d.ts", import: "./jsx/index.mjs" },
|
|
1020
|
+
"./patterns": { types: "./patterns/index.d.ts", import: "./patterns/index.mjs" },
|
|
1021
|
+
"./recipes": { types: "./recipes/index.d.ts", import: "./recipes/index.mjs" },
|
|
1022
|
+
"./tokens": { types: "./tokens/index.d.ts", import: "./tokens/index.mjs" },
|
|
1023
|
+
"./types": { types: "./types/index.d.ts" },
|
|
1024
|
+
"./styles.css": "./styles.css"
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
return JSON.stringify(pkg, null, 2);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1018
1030
|
// src/generators/prop-types.ts
|
|
1019
1031
|
import { outdent as outdent18 } from "outdent";
|
|
1020
1032
|
function generatePropTypes(utility, strict) {
|
|
1021
1033
|
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1022
1034
|
const result = [
|
|
1023
1035
|
outdent18`
|
|
1024
|
-
import { ConditionalValue } from './conditions';
|
|
1025
|
-
import { Properties as CSSProperties } from './csstype'
|
|
1026
|
-
import { Tokens } from './token'
|
|
1036
|
+
import type { ConditionalValue } from './conditions';
|
|
1037
|
+
import type { Properties as CSSProperties } from './csstype'
|
|
1038
|
+
import type { Tokens } from './token'
|
|
1027
1039
|
|
|
1028
1040
|
type PropertyValueTypes = {`
|
|
1029
1041
|
];
|
|
@@ -1064,7 +1076,7 @@ function generateRecipes(ctx) {
|
|
|
1064
1076
|
return;
|
|
1065
1077
|
const js = [
|
|
1066
1078
|
outdent19`
|
|
1067
|
-
|
|
1079
|
+
${ctx.getImport("createCss, withoutSpace, compact", "../helpers")}
|
|
1068
1080
|
|
|
1069
1081
|
const createRecipe = (name, defaultVariants) => {
|
|
1070
1082
|
return (variants) => {
|
|
@@ -1080,6 +1092,7 @@ function generateRecipes(ctx) {
|
|
|
1080
1092
|
const context = {
|
|
1081
1093
|
hash: ${hash ? "true" : "false"},
|
|
1082
1094
|
utility: {
|
|
1095
|
+
prefix: ${ctx.prefix ? JSON.stringify(ctx.prefix) : void 0},
|
|
1083
1096
|
transform,
|
|
1084
1097
|
}
|
|
1085
1098
|
}
|
|
@@ -1097,7 +1110,7 @@ function generateRecipes(ctx) {
|
|
|
1097
1110
|
];
|
|
1098
1111
|
const dts = [
|
|
1099
1112
|
outdent19`
|
|
1100
|
-
import { ConditionalValue } from '../types'
|
|
1113
|
+
import type { ConditionalValue } from '../types'
|
|
1101
1114
|
`
|
|
1102
1115
|
];
|
|
1103
1116
|
Object.values(recipes).forEach((recipe) => {
|
|
@@ -1335,20 +1348,22 @@ function generateTokenJs(dict) {
|
|
|
1335
1348
|
js: outdent21`
|
|
1336
1349
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1337
1350
|
|
|
1338
|
-
export function
|
|
1339
|
-
|
|
1340
|
-
return value
|
|
1351
|
+
export function token(path, fallback) {
|
|
1352
|
+
return tokens[path]?.value || fallback
|
|
1341
1353
|
}
|
|
1342
1354
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
return variable
|
|
1355
|
+
function tokenVar(path, fallback) {
|
|
1356
|
+
return tokens[path]?.variable || fallback
|
|
1346
1357
|
}
|
|
1358
|
+
|
|
1359
|
+
token.var = tokenVar
|
|
1347
1360
|
`,
|
|
1348
1361
|
dts: outdent21`
|
|
1349
|
-
import { Token } from
|
|
1350
|
-
|
|
1351
|
-
export declare function
|
|
1362
|
+
import type { Token } from '../types/token'
|
|
1363
|
+
|
|
1364
|
+
export declare function token(path: Token, fallback?: string): string & {
|
|
1365
|
+
var: (path: Token, fallback?: string) => string
|
|
1366
|
+
}
|
|
1352
1367
|
`
|
|
1353
1368
|
};
|
|
1354
1369
|
}
|
|
@@ -1368,7 +1383,21 @@ function generateCssType(ctx) {
|
|
|
1368
1383
|
system: getType("system-types.d.ts"),
|
|
1369
1384
|
selectors: getType("selectors.d.ts"),
|
|
1370
1385
|
recipe: getType("recipe.d.ts"),
|
|
1386
|
+
composition: getType("composition.d.ts"),
|
|
1387
|
+
global: outdent22`
|
|
1388
|
+
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1389
|
+
import { GlobalStyleObject } from './system-types'
|
|
1390
|
+
import { CompositionStyles } from './composition'
|
|
1391
|
+
|
|
1392
|
+
declare module 'css-panda' {
|
|
1393
|
+
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig<V>
|
|
1394
|
+
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
1395
|
+
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
1396
|
+
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1397
|
+
}
|
|
1398
|
+
`,
|
|
1371
1399
|
exported: outdent22`
|
|
1400
|
+
import './global'
|
|
1372
1401
|
export { ConditionalValue } from './conditions'
|
|
1373
1402
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1374
1403
|
|
|
@@ -1394,8 +1423,7 @@ function setupHelpers(ctx) {
|
|
|
1394
1423
|
const sharedMjs = getEntrypoint("@pandacss/shared", { dev: "shared.mjs" });
|
|
1395
1424
|
const code = readFileSync3(sharedMjs, "utf-8");
|
|
1396
1425
|
return {
|
|
1397
|
-
|
|
1398
|
-
files: [{ file: ctx.getJsFile("helpers"), code }]
|
|
1426
|
+
files: [{ file: ctx.getExt("helpers"), code }]
|
|
1399
1427
|
};
|
|
1400
1428
|
}
|
|
1401
1429
|
function setupKeyframes(ctx) {
|
|
@@ -1406,9 +1434,8 @@ function setupKeyframes(ctx) {
|
|
|
1406
1434
|
};
|
|
1407
1435
|
}
|
|
1408
1436
|
function setupDesignTokens(ctx) {
|
|
1409
|
-
if (ctx.tokens.isEmpty)
|
|
1410
|
-
return
|
|
1411
|
-
}
|
|
1437
|
+
if (ctx.tokens.isEmpty)
|
|
1438
|
+
return;
|
|
1412
1439
|
const code = generateTokenJs(ctx.tokens);
|
|
1413
1440
|
const css2 = generateTokenCss(ctx);
|
|
1414
1441
|
return {
|
|
@@ -1416,7 +1443,7 @@ function setupDesignTokens(ctx) {
|
|
|
1416
1443
|
files: [
|
|
1417
1444
|
{ file: "index.css", code: css2 },
|
|
1418
1445
|
{ file: "index.d.ts", code: code.dts },
|
|
1419
|
-
{ file: ctx.
|
|
1446
|
+
{ file: ctx.getExt("index"), code: code.js }
|
|
1420
1447
|
]
|
|
1421
1448
|
};
|
|
1422
1449
|
}
|
|
@@ -1431,6 +1458,8 @@ function setupTypes(ctx) {
|
|
|
1431
1458
|
{ file: "csstype.d.ts", code: types.css },
|
|
1432
1459
|
{ file: "system-types.d.ts", code: types.system },
|
|
1433
1460
|
{ file: "selectors.d.ts", code: types.selectors },
|
|
1461
|
+
{ file: "composition.d.ts", code: types.composition },
|
|
1462
|
+
{ file: "global.d.ts", code: types.global },
|
|
1434
1463
|
{ file: "recipe.d.ts", code: types.recipe },
|
|
1435
1464
|
{ file: "index.d.ts", code: types.exported },
|
|
1436
1465
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
@@ -1446,18 +1475,18 @@ function setupCss(ctx) {
|
|
|
1446
1475
|
return {
|
|
1447
1476
|
dir: ctx.paths.css,
|
|
1448
1477
|
files: [
|
|
1449
|
-
{ file: ctx.
|
|
1450
|
-
{ file: ctx.
|
|
1478
|
+
{ file: ctx.getExt("conditions"), code: conditions.js },
|
|
1479
|
+
{ file: ctx.getExt("css"), code: code.js },
|
|
1451
1480
|
{ file: "css.d.ts", code: code.dts }
|
|
1452
1481
|
]
|
|
1453
1482
|
};
|
|
1454
1483
|
}
|
|
1455
1484
|
function setupCva(ctx) {
|
|
1456
|
-
const code = generateCvaFn();
|
|
1485
|
+
const code = generateCvaFn(ctx);
|
|
1457
1486
|
return {
|
|
1458
1487
|
dir: ctx.paths.css,
|
|
1459
1488
|
files: [
|
|
1460
|
-
{ file: ctx.
|
|
1489
|
+
{ file: ctx.getExt("cva"), code: code.js },
|
|
1461
1490
|
{ file: "cva.d.ts", code: code.dts }
|
|
1462
1491
|
]
|
|
1463
1492
|
};
|
|
@@ -1467,94 +1496,111 @@ function setupCx(ctx) {
|
|
|
1467
1496
|
return {
|
|
1468
1497
|
dir: ctx.paths.css,
|
|
1469
1498
|
files: [
|
|
1470
|
-
{ file: ctx.
|
|
1499
|
+
{ file: ctx.getExt("cx"), code: code.js },
|
|
1471
1500
|
{ file: "cx.d.ts", code: code.dts }
|
|
1472
1501
|
]
|
|
1473
1502
|
};
|
|
1474
1503
|
}
|
|
1475
1504
|
function setupRecipes(ctx) {
|
|
1476
1505
|
const code = generateRecipes(ctx);
|
|
1477
|
-
if (!code)
|
|
1478
|
-
return
|
|
1479
|
-
}
|
|
1506
|
+
if (!code)
|
|
1507
|
+
return;
|
|
1480
1508
|
return {
|
|
1481
1509
|
dir: ctx.paths.recipe,
|
|
1482
1510
|
files: [
|
|
1483
|
-
{ file: ctx.
|
|
1511
|
+
{ file: ctx.getExt("index"), code: code.js },
|
|
1484
1512
|
{ file: "index.d.ts", code: code.dts }
|
|
1485
1513
|
]
|
|
1486
1514
|
};
|
|
1487
1515
|
}
|
|
1488
1516
|
function setupPatterns(ctx) {
|
|
1489
1517
|
const files = generatePattern(ctx);
|
|
1490
|
-
if (!files)
|
|
1491
|
-
return
|
|
1492
|
-
|
|
1493
|
-
|
|
1518
|
+
if (!files)
|
|
1519
|
+
return;
|
|
1520
|
+
const index = {
|
|
1521
|
+
js: outdent23.string(files.map((file) => ctx.getExport(`./${file.name}`)).join("\n")),
|
|
1522
|
+
dts: outdent23.string(files.map((file) => `export { ${file.name} } from './${file.name}'`).join("\n"))
|
|
1523
|
+
};
|
|
1494
1524
|
return {
|
|
1495
1525
|
dir: ctx.paths.pattern,
|
|
1496
1526
|
files: [
|
|
1497
|
-
...files.map((file) => ({ file: ctx.
|
|
1527
|
+
...files.map((file) => ({ file: ctx.getExt(file.name), code: file.js })),
|
|
1498
1528
|
...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1499
|
-
{ file: ctx.
|
|
1500
|
-
{ file: "index.d.ts", code:
|
|
1529
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1530
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1501
1531
|
]
|
|
1502
1532
|
};
|
|
1503
1533
|
}
|
|
1504
1534
|
function setupJsx(ctx) {
|
|
1505
1535
|
if (!ctx.jsxFramework)
|
|
1506
|
-
return
|
|
1536
|
+
return;
|
|
1507
1537
|
const isValidProp = generateisValidProp(ctx);
|
|
1508
1538
|
const types = generateJsxTypes(ctx);
|
|
1509
1539
|
const factory = generateJsxFactory(ctx);
|
|
1510
1540
|
const patterns = generateJsxPatterns(ctx);
|
|
1511
1541
|
const layoutGrid = generateLayoutGrid(ctx);
|
|
1512
|
-
const
|
|
1542
|
+
const index = {
|
|
1543
|
+
js: outdent23`
|
|
1544
|
+
${ctx.getExport("./factory")}
|
|
1545
|
+
${ctx.getExport("./layout-grid")}
|
|
1546
|
+
${outdent23.string(patterns.map((file) => ctx.getExport(`./${file.name}`)).join("\n"))}
|
|
1547
|
+
`,
|
|
1548
|
+
dts: outdent23`
|
|
1513
1549
|
export * from './factory'
|
|
1514
1550
|
export * from './layout-grid'
|
|
1515
1551
|
${outdent23.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1516
|
-
|
|
1552
|
+
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1553
|
+
`
|
|
1554
|
+
};
|
|
1517
1555
|
return {
|
|
1518
1556
|
dir: ctx.paths.jsx,
|
|
1519
1557
|
files: [
|
|
1520
|
-
...patterns.map((file) => ({ file: `${file.name}.
|
|
1558
|
+
...patterns.map((file) => ({ file: `${file.name}.mjs`, code: file.js })),
|
|
1521
1559
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1522
|
-
{ file: "layout-grid.
|
|
1560
|
+
{ file: "layout-grid.mjs", code: layoutGrid.js },
|
|
1523
1561
|
{ file: "layout-grid.d.ts", code: layoutGrid.dts },
|
|
1524
|
-
{ file: ctx.
|
|
1562
|
+
{ file: ctx.getExt("is-valid-prop"), code: isValidProp.js },
|
|
1525
1563
|
{ 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 }
|
|
1564
|
+
{ file: "factory.mjs", code: factory.js },
|
|
1565
|
+
{ file: "index.d.ts", code: index.dts },
|
|
1566
|
+
{ file: "index.mjs", code: index.js }
|
|
1535
1567
|
]
|
|
1536
1568
|
};
|
|
1537
1569
|
}
|
|
1538
1570
|
function setupCssIndex(ctx) {
|
|
1539
|
-
const
|
|
1571
|
+
const index = {
|
|
1572
|
+
js: outdent23`
|
|
1573
|
+
${ctx.getExport("./css")}
|
|
1574
|
+
${ctx.getExport("./cx")}
|
|
1575
|
+
${ctx.getExport("./cva")}
|
|
1576
|
+
`,
|
|
1577
|
+
dts: outdent23`
|
|
1540
1578
|
export * from './css'
|
|
1541
1579
|
export * from './cx'
|
|
1542
1580
|
export * from './cva'
|
|
1543
|
-
|
|
1581
|
+
`
|
|
1582
|
+
};
|
|
1544
1583
|
return {
|
|
1545
1584
|
dir: ctx.paths.css,
|
|
1546
1585
|
files: [
|
|
1547
|
-
{ file: ctx.
|
|
1548
|
-
{ file: "index.d.ts", code }
|
|
1586
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1587
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1549
1588
|
]
|
|
1550
1589
|
};
|
|
1551
1590
|
}
|
|
1552
1591
|
function setupReset(ctx) {
|
|
1553
1592
|
if (!ctx.preflight)
|
|
1554
|
-
return
|
|
1593
|
+
return;
|
|
1555
1594
|
const code = generateReset();
|
|
1556
1595
|
return { files: [{ file: "reset.css", code }] };
|
|
1557
1596
|
}
|
|
1597
|
+
function setupPackageJson(ctx) {
|
|
1598
|
+
if (!ctx.emitPackage)
|
|
1599
|
+
return;
|
|
1600
|
+
return {
|
|
1601
|
+
files: [{ file: "package.json", code: generatePackageJSON(ctx) }]
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1558
1604
|
function generateSystem(ctx) {
|
|
1559
1605
|
return [
|
|
1560
1606
|
setupHelpers(ctx),
|
|
@@ -1568,8 +1614,9 @@ function generateSystem(ctx) {
|
|
|
1568
1614
|
setupPatterns(ctx),
|
|
1569
1615
|
setupCssIndex(ctx),
|
|
1570
1616
|
setupJsx(ctx),
|
|
1571
|
-
setupReset(ctx)
|
|
1572
|
-
|
|
1617
|
+
setupReset(ctx),
|
|
1618
|
+
setupPackageJson(ctx)
|
|
1619
|
+
].filter(Boolean);
|
|
1573
1620
|
}
|
|
1574
1621
|
|
|
1575
1622
|
// src/messages.ts
|
|
@@ -1654,10 +1701,14 @@ async function emitArtifacts(ctx) {
|
|
|
1654
1701
|
}
|
|
1655
1702
|
async function emitAndExtract(ctx) {
|
|
1656
1703
|
await emitArtifacts(ctx);
|
|
1704
|
+
return extractCss(ctx);
|
|
1705
|
+
}
|
|
1706
|
+
async function extractCss(ctx) {
|
|
1657
1707
|
await extractGlobalCss(ctx);
|
|
1658
1708
|
await extractStaticCss(ctx);
|
|
1659
1709
|
await extractFiles(ctx);
|
|
1660
1710
|
await bundleChunks(ctx);
|
|
1711
|
+
return buildCompleteMessage(ctx);
|
|
1661
1712
|
}
|
|
1662
1713
|
function getBaseCss(ctx) {
|
|
1663
1714
|
const css2 = [
|
|
@@ -1724,7 +1775,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1724
1775
|
const {
|
|
1725
1776
|
cwd: cwdProp = process.cwd(),
|
|
1726
1777
|
conditions: conditionsProp = {},
|
|
1727
|
-
|
|
1778
|
+
prefix,
|
|
1728
1779
|
cssVarRoot = ":where(:root, :host)",
|
|
1729
1780
|
outdir,
|
|
1730
1781
|
exclude: excludeProp = [],
|
|
@@ -1737,7 +1788,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
1737
1788
|
globalCss,
|
|
1738
1789
|
separator,
|
|
1739
1790
|
static: staticCss,
|
|
1740
|
-
outExtension = "mjs"
|
|
1791
|
+
outExtension = "mjs",
|
|
1792
|
+
emitPackage
|
|
1741
1793
|
} = config;
|
|
1742
1794
|
const {
|
|
1743
1795
|
breakpoints = {},
|
|
@@ -1755,15 +1807,17 @@ function createContext(conf, io = fileSystem) {
|
|
|
1755
1807
|
framework: jsxFramework
|
|
1756
1808
|
};
|
|
1757
1809
|
const cwd = resolve(cwdProp);
|
|
1758
|
-
const exclude = [".git", "node_modules", "test-results"].concat(excludeProp);
|
|
1810
|
+
const exclude = [".git", ".yarn", "node_modules", "test-results"].concat(excludeProp);
|
|
1759
1811
|
const tokens = new TokenDictionary({
|
|
1760
1812
|
tokens: tokensProp,
|
|
1813
|
+
breakpoints,
|
|
1761
1814
|
semanticTokens,
|
|
1762
|
-
prefix
|
|
1815
|
+
prefix
|
|
1763
1816
|
});
|
|
1764
1817
|
const hasTokens = !tokens.isEmpty;
|
|
1765
1818
|
logger4.debug({ type: "ctx:token", msg: tokens.allNames });
|
|
1766
1819
|
const utility = new Utility({
|
|
1820
|
+
prefix,
|
|
1767
1821
|
tokens,
|
|
1768
1822
|
config: utilities,
|
|
1769
1823
|
separator
|
|
@@ -1850,14 +1904,24 @@ function createContext(conf, io = fileSystem) {
|
|
|
1850
1904
|
function isStyleProp(prop) {
|
|
1851
1905
|
return isCssProperty(prop) || isCustomCssProperty(prop);
|
|
1852
1906
|
}
|
|
1853
|
-
function getPath(
|
|
1854
|
-
|
|
1907
|
+
function getPath(pathLike) {
|
|
1908
|
+
const paths2 = [cwd, emitPackage ? "node_modules" : void 0, outdir, pathLike].filter(Boolean);
|
|
1909
|
+
return join2(...paths2);
|
|
1855
1910
|
}
|
|
1856
1911
|
function absPath(str) {
|
|
1857
1912
|
return isAbsolute(str) ? str : join2(cwd, str);
|
|
1858
1913
|
}
|
|
1914
|
+
function getExt(file) {
|
|
1915
|
+
return `${file}.${outExtension}`;
|
|
1916
|
+
}
|
|
1917
|
+
function getImport(items, mod) {
|
|
1918
|
+
return `import { ${items} } from '${getExt(mod)}';`;
|
|
1919
|
+
}
|
|
1920
|
+
function getExport(mod) {
|
|
1921
|
+
return `export * from '${getExt(mod)}';`;
|
|
1922
|
+
}
|
|
1859
1923
|
const paths = {
|
|
1860
|
-
|
|
1924
|
+
root: getPath(),
|
|
1861
1925
|
css: getPath("css"),
|
|
1862
1926
|
token: getPath("tokens"),
|
|
1863
1927
|
types: getPath("types"),
|
|
@@ -1879,15 +1943,14 @@ function createContext(conf, io = fileSystem) {
|
|
|
1879
1943
|
);
|
|
1880
1944
|
}
|
|
1881
1945
|
function cleanOutdir() {
|
|
1882
|
-
return emptyDir(
|
|
1946
|
+
return emptyDir(paths.root);
|
|
1883
1947
|
}
|
|
1884
1948
|
function writeOutput(output) {
|
|
1885
|
-
|
|
1949
|
+
if (!output)
|
|
1950
|
+
return;
|
|
1951
|
+
const { dir = paths.root, files: files2 } = output;
|
|
1886
1952
|
return write(dir, files2);
|
|
1887
1953
|
}
|
|
1888
|
-
function getJsFile(file) {
|
|
1889
|
-
return `${file}.${outExtension}`;
|
|
1890
|
-
}
|
|
1891
1954
|
const chunks = {
|
|
1892
1955
|
dir: paths.chunk,
|
|
1893
1956
|
readFile(file) {
|
|
@@ -1917,6 +1980,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
1917
1980
|
const fileName = chunks.format(file);
|
|
1918
1981
|
return io.rm(join2(paths.chunk, fileName));
|
|
1919
1982
|
},
|
|
1983
|
+
empty() {
|
|
1984
|
+
return emptyDir(paths.chunk);
|
|
1985
|
+
},
|
|
1920
1986
|
glob: [`${paths.chunk}/**/*.css`]
|
|
1921
1987
|
};
|
|
1922
1988
|
function getFiles() {
|
|
@@ -1979,6 +2045,30 @@ function createContext(conf, io = fileSystem) {
|
|
|
1979
2045
|
sheet.processGlobalCss({
|
|
1980
2046
|
":root": {
|
|
1981
2047
|
"--made-with-panda": `'\u{1F43C}'`
|
|
2048
|
+
},
|
|
2049
|
+
".panda-layout-grid": {
|
|
2050
|
+
display: "grid",
|
|
2051
|
+
gap: "var(--gutter)",
|
|
2052
|
+
gridTemplateColumns: "repeat(var(--count), 1fr)",
|
|
2053
|
+
height: "100%",
|
|
2054
|
+
width: "100%",
|
|
2055
|
+
position: "absolute",
|
|
2056
|
+
inset: "0",
|
|
2057
|
+
pointerEvents: "none",
|
|
2058
|
+
maxWidth: "var(--max-width)",
|
|
2059
|
+
marginInline: "var(--margin-x)",
|
|
2060
|
+
paddingInline: "var(--padding-x)"
|
|
2061
|
+
},
|
|
2062
|
+
".panda-layout-grid__item": {
|
|
2063
|
+
display: "flex",
|
|
2064
|
+
"--color": "rgba(255, 0, 0, 0.1)",
|
|
2065
|
+
height: "100%",
|
|
2066
|
+
"&[data-variant=bg]": {
|
|
2067
|
+
background: "var(--color)"
|
|
2068
|
+
},
|
|
2069
|
+
"&[data-variant=outline]": {
|
|
2070
|
+
borderInline: "1px solid var(--color)"
|
|
2071
|
+
}
|
|
1982
2072
|
}
|
|
1983
2073
|
});
|
|
1984
2074
|
if (globalCss) {
|
|
@@ -2092,7 +2182,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
2092
2182
|
write,
|
|
2093
2183
|
writeOutput,
|
|
2094
2184
|
cleanOutdir,
|
|
2095
|
-
|
|
2185
|
+
getExt,
|
|
2186
|
+
getImport,
|
|
2187
|
+
getExport,
|
|
2096
2188
|
cssVarRoot,
|
|
2097
2189
|
tokens,
|
|
2098
2190
|
hasTokens,
|
|
@@ -2378,8 +2470,8 @@ process.on("uncaughtException", (err) => {
|
|
|
2378
2470
|
// src/generate.ts
|
|
2379
2471
|
async function build(config, configPath) {
|
|
2380
2472
|
const ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2381
|
-
await emitAndExtract(ctx);
|
|
2382
|
-
logger8.info(
|
|
2473
|
+
const msg = await emitAndExtract(ctx);
|
|
2474
|
+
logger8.info(msg);
|
|
2383
2475
|
return ctx;
|
|
2384
2476
|
}
|
|
2385
2477
|
async function generate5(config, configPath) {
|
|
@@ -2479,6 +2571,7 @@ export {
|
|
|
2479
2571
|
emitAndExtract,
|
|
2480
2572
|
emitArtifacts,
|
|
2481
2573
|
execCommand,
|
|
2574
|
+
extractCss,
|
|
2482
2575
|
generate5 as generate,
|
|
2483
2576
|
loadConfigAndCreateContext,
|
|
2484
2577
|
setupConfig,
|