@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.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
emitAndExtract: () => emitAndExtract,
|
|
33
33
|
emitArtifacts: () => emitArtifacts,
|
|
34
34
|
execCommand: () => execCommand,
|
|
35
|
+
extractCss: () => extractCss,
|
|
35
36
|
generate: () => generate5,
|
|
36
37
|
loadConfigAndCreateContext: () => loadConfigAndCreateContext,
|
|
37
38
|
setupConfig: () => setupConfig,
|
|
@@ -115,7 +116,7 @@ async function extractChunks(ctx) {
|
|
|
115
116
|
}
|
|
116
117
|
async function bundleChunks(ctx) {
|
|
117
118
|
const css2 = await extractChunks(ctx);
|
|
118
|
-
await ctx.write(ctx.
|
|
119
|
+
await ctx.write(ctx.paths.root, [{ file: "styles.css", code: css2 }]);
|
|
119
120
|
}
|
|
120
121
|
async function writeFileChunk(ctx, file) {
|
|
121
122
|
import_logger2.logger.info(`File changed: ${file}`);
|
|
@@ -135,7 +136,8 @@ function generateConditions(ctx) {
|
|
|
135
136
|
const keys = Object.keys(ctx.conditions.values).concat("base");
|
|
136
137
|
return {
|
|
137
138
|
js: import_outdent.default`
|
|
138
|
-
|
|
139
|
+
${ctx.getImport("withoutSpace", "../helpers")}
|
|
140
|
+
|
|
139
141
|
const conditions = new Set([${keys.map((key) => JSON.stringify(key))}])
|
|
140
142
|
|
|
141
143
|
export function isCondition(value){
|
|
@@ -203,12 +205,12 @@ function generateCssFn(ctx) {
|
|
|
203
205
|
const { separator } = utility;
|
|
204
206
|
return {
|
|
205
207
|
dts: import_outdent2.outdent`
|
|
206
|
-
import { SystemStyleObject } from '../types'
|
|
208
|
+
import type { SystemStyleObject } from '../types'
|
|
207
209
|
export declare function css(styles: SystemStyleObject): string
|
|
208
210
|
`,
|
|
209
211
|
js: import_outdent2.outdent`
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
${ctx.getImport("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
213
|
+
${ctx.getImport("sortConditions, finalizeConditions", "./conditions")}
|
|
212
214
|
|
|
213
215
|
const classNameMap = ${stringify(utility.entries())}
|
|
214
216
|
|
|
@@ -222,7 +224,7 @@ function generateCssFn(ctx) {
|
|
|
222
224
|
|
|
223
225
|
function transform(prop, value) {
|
|
224
226
|
const key = resolveShorthand(prop)
|
|
225
|
-
const propKey = classNameMap[key] ||
|
|
227
|
+
const propKey = classNameMap[key] || hypenateProperty(key)
|
|
226
228
|
const className = \`$\{propKey}${separator}$\{withoutSpace(value)}\`
|
|
227
229
|
return { className }
|
|
228
230
|
}
|
|
@@ -235,6 +237,7 @@ function generateCssFn(ctx) {
|
|
|
235
237
|
breakpoints: { keys: breakpointKeys }
|
|
236
238
|
},
|
|
237
239
|
utility: {
|
|
240
|
+
prefix: ${ctx.prefix ? JSON.stringify(ctx.prefix) : void 0},
|
|
238
241
|
transform,
|
|
239
242
|
hasShorthand,
|
|
240
243
|
resolveShorthand,
|
|
@@ -250,11 +253,11 @@ function generateCssFn(ctx) {
|
|
|
250
253
|
|
|
251
254
|
// src/generators/cva.ts
|
|
252
255
|
var import_outdent3 = require("outdent");
|
|
253
|
-
function generateCvaFn() {
|
|
256
|
+
function generateCvaFn(ctx) {
|
|
254
257
|
return {
|
|
255
258
|
js: import_outdent3.outdent`
|
|
256
|
-
|
|
257
|
-
|
|
259
|
+
${ctx.getImport("compact", "../helpers")}
|
|
260
|
+
${ctx.getImport("css, mergeCss", "./css")}
|
|
258
261
|
|
|
259
262
|
export function cva(config) {
|
|
260
263
|
const { base = {}, variants = {}, defaultVariants = {} } = config
|
|
@@ -283,7 +286,7 @@ function generateCvaFn() {
|
|
|
283
286
|
}
|
|
284
287
|
`,
|
|
285
288
|
dts: import_outdent3.outdent`
|
|
286
|
-
import { RecipeCreatorFn } from '../types/recipe'
|
|
289
|
+
import type { RecipeCreatorFn } from '../types/recipe'
|
|
287
290
|
|
|
288
291
|
export declare const cva: RecipeCreatorFn
|
|
289
292
|
|
|
@@ -362,9 +365,9 @@ function generatePreactJsxFactory(ctx) {
|
|
|
362
365
|
import { h } from 'preact'
|
|
363
366
|
import { forwardRef } from 'preact/compat'
|
|
364
367
|
import { useMemo } from 'preact/hooks'
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
+
${ctx.getImport("css, cx, assignCss", "../css/index")}
|
|
369
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
370
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
368
371
|
|
|
369
372
|
function styled(Dynamic, configOrCva = {}) {
|
|
370
373
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -376,7 +379,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
376
379
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
377
380
|
}, [restProps])
|
|
378
381
|
|
|
379
|
-
function classes(){
|
|
382
|
+
function classes() {
|
|
380
383
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
381
384
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
382
385
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
@@ -424,47 +427,39 @@ function generatePreactLayoutGrid() {
|
|
|
424
427
|
import { FunctionComponent } from 'preact'
|
|
425
428
|
|
|
426
429
|
export type LayoutGridProps = {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
430
|
+
count?: number
|
|
431
|
+
gutter?: string
|
|
432
|
+
maxWidth?: string
|
|
433
|
+
margin?: string
|
|
434
|
+
outline?: boolean
|
|
431
435
|
}
|
|
432
436
|
|
|
433
437
|
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
434
438
|
`,
|
|
435
439
|
js: import_outdent6.outdent`
|
|
440
|
+
import { h } from 'preact'
|
|
441
|
+
|
|
436
442
|
export function LayoutGrid(props) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
key={i}
|
|
458
|
-
style={{
|
|
459
|
-
display: 'flex',
|
|
460
|
-
background: 'rgba(255, 0, 0, 0.1)',
|
|
461
|
-
height: '100%',
|
|
462
|
-
}}
|
|
463
|
-
/>
|
|
464
|
-
))}
|
|
465
|
-
</div>
|
|
466
|
-
);
|
|
467
|
-
}
|
|
443
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
444
|
+
const hasMaxWidth = maxWidth != null
|
|
445
|
+
return h('div', {
|
|
446
|
+
className: 'panda-layout-grid',
|
|
447
|
+
style: {
|
|
448
|
+
'--gutter': gutter,
|
|
449
|
+
'--count': count,
|
|
450
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
451
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
452
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
453
|
+
},
|
|
454
|
+
children: Array.from({ length: count }).map((_, i) =>
|
|
455
|
+
h('span', {
|
|
456
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
457
|
+
key: i,
|
|
458
|
+
className: 'panda-layout-grid__item',
|
|
459
|
+
}),
|
|
460
|
+
),
|
|
461
|
+
});
|
|
462
|
+
}
|
|
468
463
|
`
|
|
469
464
|
};
|
|
470
465
|
}
|
|
@@ -478,29 +473,30 @@ function generate(ctx, name, pattern) {
|
|
|
478
473
|
return {
|
|
479
474
|
name: dashName,
|
|
480
475
|
js: import_outdent7.outdent`
|
|
476
|
+
import { h } from 'preact'
|
|
481
477
|
import { forwardRef } from 'preact/compat'
|
|
482
|
-
|
|
483
|
-
|
|
478
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
479
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
484
480
|
|
|
485
481
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
486
482
|
${(0, import_ts_pattern.match)(props.length).with(
|
|
487
483
|
0,
|
|
488
484
|
() => import_outdent7.outdent`
|
|
489
|
-
return
|
|
485
|
+
return h(${ctx.jsxFactory}.div, { ref, ...props })
|
|
490
486
|
`
|
|
491
487
|
).otherwise(
|
|
492
488
|
() => import_outdent7.outdent`
|
|
493
489
|
const { ${props.join(", ")}, ...restProps } = props
|
|
494
490
|
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
495
|
-
return
|
|
491
|
+
return h(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
496
492
|
`
|
|
497
493
|
)}
|
|
498
494
|
})
|
|
499
495
|
`,
|
|
500
496
|
dts: import_outdent7.outdent`
|
|
501
|
-
import { FunctionComponent } from 'preact'
|
|
502
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
503
|
-
import { ${typeName} } from '../types/jsx'
|
|
497
|
+
import type { FunctionComponent } from 'preact'
|
|
498
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
499
|
+
import type { ${typeName} } from '../types/jsx'
|
|
504
500
|
|
|
505
501
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
506
502
|
|
|
@@ -519,25 +515,25 @@ function generatePreactJsxTypes(ctx) {
|
|
|
519
515
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
520
516
|
return {
|
|
521
517
|
jsxFactory: import_outdent8.outdent`
|
|
522
|
-
import { ${upperName} } from '../types/jsx'
|
|
518
|
+
import type { ${upperName} } from '../types/jsx'
|
|
523
519
|
export declare const ${name}: ${upperName}
|
|
524
520
|
`,
|
|
525
521
|
jsxType: import_outdent8.outdent`
|
|
526
|
-
import { JSX, ComponentProps } from 'preact'
|
|
527
|
-
import { JsxStyleProps, Assign } from '.'
|
|
528
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
522
|
+
import type { JSX, ComponentProps } from 'preact'
|
|
523
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
524
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
529
525
|
|
|
530
526
|
type Dict = Record<string, unknown>
|
|
531
527
|
type ElementType = keyof JSX.IntrinsicElements
|
|
532
528
|
|
|
533
|
-
type
|
|
529
|
+
type HTMLProps = {
|
|
534
530
|
htmlSize?: string | number
|
|
535
531
|
htmlWidth?: string | number
|
|
536
532
|
htmlHeight?: string | number
|
|
537
533
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
538
534
|
}
|
|
539
535
|
|
|
540
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
536
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
541
537
|
|
|
542
538
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
543
539
|
|
|
@@ -561,10 +557,10 @@ function generateReactJsxFactory(ctx) {
|
|
|
561
557
|
const { name, componentName } = ctx.jsxFactoryDetails;
|
|
562
558
|
return {
|
|
563
559
|
js: import_outdent9.outdent`
|
|
564
|
-
import { forwardRef, useMemo } from 'react'
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
560
|
+
import { createElement, forwardRef, useMemo } from 'react'
|
|
561
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
562
|
+
${ctx.getImport("splitProps, normalizeHTMLProps", "../helpers")}
|
|
563
|
+
${ctx.getImport("isCssProperty", "./is-valid-prop")}
|
|
568
564
|
|
|
569
565
|
function styled(Dynamic, configOrCva = {}) {
|
|
570
566
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -576,21 +572,19 @@ function generateReactJsxFactory(ctx) {
|
|
|
576
572
|
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
577
573
|
}, [restProps])
|
|
578
574
|
|
|
579
|
-
function classes(){
|
|
575
|
+
function classes() {
|
|
580
576
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
581
577
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
582
578
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
583
579
|
return cx(css(styles), elementProps.className)
|
|
584
580
|
}
|
|
585
581
|
|
|
586
|
-
return(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
/>
|
|
593
|
-
)
|
|
582
|
+
return createElement(Element, {
|
|
583
|
+
ref,
|
|
584
|
+
...elementProps,
|
|
585
|
+
...normalizeHTMLProps(htmlProps),
|
|
586
|
+
className: classes(),
|
|
587
|
+
})
|
|
594
588
|
})
|
|
595
589
|
|
|
596
590
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -627,47 +621,39 @@ function generateReactLayoutGrid() {
|
|
|
627
621
|
import type { FunctionComponent } from 'react'
|
|
628
622
|
|
|
629
623
|
export type LayoutGridProps = {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
624
|
+
count?: number
|
|
625
|
+
gutter?: string
|
|
626
|
+
maxWidth?: string
|
|
627
|
+
margin?: string
|
|
628
|
+
outline?: boolean
|
|
634
629
|
}
|
|
635
630
|
|
|
636
631
|
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
637
632
|
`,
|
|
638
633
|
js: import_outdent10.outdent`
|
|
634
|
+
import { createElement } from 'react'
|
|
635
|
+
|
|
639
636
|
export function LayoutGrid(props) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
key={i}
|
|
661
|
-
style={{
|
|
662
|
-
display: 'flex',
|
|
663
|
-
background: 'rgba(255, 0, 0, 0.1)',
|
|
664
|
-
height: '100%',
|
|
665
|
-
}}
|
|
666
|
-
/>
|
|
667
|
-
))}
|
|
668
|
-
</div>
|
|
669
|
-
);
|
|
670
|
-
}
|
|
637
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
638
|
+
const hasMaxWidth = maxWidth != null
|
|
639
|
+
return createElement('div', {
|
|
640
|
+
className: 'panda-layout-grid',
|
|
641
|
+
style: {
|
|
642
|
+
'--gutter': gutter,
|
|
643
|
+
'--count': count,
|
|
644
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
645
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
646
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
647
|
+
},
|
|
648
|
+
children: Array.from({ length: count }).map((_, i) =>
|
|
649
|
+
createElement('span', {
|
|
650
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
651
|
+
key: i,
|
|
652
|
+
className: 'panda-layout-grid__item',
|
|
653
|
+
}),
|
|
654
|
+
),
|
|
655
|
+
})
|
|
656
|
+
}
|
|
671
657
|
`
|
|
672
658
|
};
|
|
673
659
|
}
|
|
@@ -681,30 +667,29 @@ function generate2(ctx, name, pattern) {
|
|
|
681
667
|
return {
|
|
682
668
|
name: dashName,
|
|
683
669
|
js: import_outdent11.outdent`
|
|
684
|
-
import { forwardRef } from 'react'
|
|
685
|
-
|
|
686
|
-
|
|
670
|
+
import { createElement, forwardRef } from 'react'
|
|
671
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
672
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
687
673
|
|
|
688
674
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
689
675
|
${(0, import_ts_pattern2.match)(props.length).with(
|
|
690
676
|
0,
|
|
691
677
|
() => import_outdent11.outdent`
|
|
692
|
-
|
|
678
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...props })
|
|
693
679
|
`
|
|
694
680
|
).otherwise(
|
|
695
681
|
() => import_outdent11.outdent`
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
682
|
+
const { ${props.join(", ")}, ...restProps } = props
|
|
683
|
+
const styleProps = ${styleFn}({${props.join(", ")}})
|
|
684
|
+
return createElement(${ctx.jsxFactory}.div, { ref, ...styleProps, ...restProps })
|
|
699
685
|
`
|
|
700
686
|
)}
|
|
701
|
-
|
|
702
687
|
})
|
|
703
688
|
`,
|
|
704
689
|
dts: import_outdent11.outdent`
|
|
705
|
-
import { FunctionComponent } from 'react'
|
|
706
|
-
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
707
|
-
import { ${typeName} } from '../types/jsx'
|
|
690
|
+
import type { FunctionComponent } from 'react'
|
|
691
|
+
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
692
|
+
import type { ${typeName} } from '../types/jsx'
|
|
708
693
|
|
|
709
694
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
710
695
|
|
|
@@ -727,20 +712,20 @@ import { ${upperName} } from '../types/jsx'
|
|
|
727
712
|
export declare const ${name}: ${upperName}
|
|
728
713
|
`,
|
|
729
714
|
jsxType: import_outdent12.outdent`
|
|
730
|
-
import { ElementType, ComponentProps } from 'react'
|
|
731
|
-
import { JsxStyleProps, Assign } from '.'
|
|
732
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
715
|
+
import type { ElementType, ComponentProps } from 'react'
|
|
716
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
717
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
733
718
|
|
|
734
719
|
type Dict = Record<string, unknown>
|
|
735
720
|
|
|
736
|
-
type
|
|
721
|
+
type HTMLProps = {
|
|
737
722
|
htmlSize?: string | number
|
|
738
723
|
htmlWidth?: string | number
|
|
739
724
|
htmlHeight?: string | number
|
|
740
725
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
741
726
|
}
|
|
742
727
|
|
|
743
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
728
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
744
729
|
|
|
745
730
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
746
731
|
|
|
@@ -766,9 +751,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
766
751
|
js: import_outdent13.outdent`
|
|
767
752
|
import { Dynamic } from 'solid-js/web'
|
|
768
753
|
import { mergeProps, splitProps } from 'solid-js'
|
|
769
|
-
import {
|
|
770
|
-
|
|
771
|
-
|
|
754
|
+
import { createComponent } from 'solid-js/web'
|
|
755
|
+
${ctx.getImport("css, cx, cva, assignCss", "../css/index")}
|
|
756
|
+
${ctx.getImport("normalizeHTMLProps", "../helpers")}
|
|
757
|
+
${ctx.getImport("allCssProperties", "./is-valid-prop")}
|
|
772
758
|
|
|
773
759
|
function styled(element, configOrCva = {}) {
|
|
774
760
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
@@ -776,10 +762,11 @@ function generateSolidJsxFactory(ctx) {
|
|
|
776
762
|
return function ${componentName}(props) {
|
|
777
763
|
const mergedProps = mergeProps({ as: element }, props)
|
|
778
764
|
|
|
779
|
-
const [localProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
765
|
+
const [localProps, styleProps, variantProps, htmlProps, elementProps] = splitProps(
|
|
780
766
|
mergedProps,
|
|
781
767
|
['as', 'class'],
|
|
782
768
|
allCssProperties,
|
|
769
|
+
cvaFn.variants,
|
|
783
770
|
normalizeHTMLProps.keys
|
|
784
771
|
)
|
|
785
772
|
|
|
@@ -790,13 +777,20 @@ function generateSolidJsxFactory(ctx) {
|
|
|
790
777
|
return cx(css(styles), localProps.class)
|
|
791
778
|
}
|
|
792
779
|
|
|
793
|
-
return (
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
{
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
780
|
+
return createComponent(
|
|
781
|
+
Dynamic,
|
|
782
|
+
mergeProps(
|
|
783
|
+
{
|
|
784
|
+
get component() {
|
|
785
|
+
return localProps.as
|
|
786
|
+
},
|
|
787
|
+
get class() {
|
|
788
|
+
return classes()
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
elementProps,
|
|
792
|
+
normalizeHTMLProps(htmlProps)
|
|
793
|
+
)
|
|
800
794
|
)
|
|
801
795
|
}
|
|
802
796
|
}
|
|
@@ -827,50 +821,48 @@ var import_outdent14 = require("outdent");
|
|
|
827
821
|
function generateSolidLayoutGrid() {
|
|
828
822
|
return {
|
|
829
823
|
dts: import_outdent14.outdent`
|
|
830
|
-
import { ParentProps } from 'solid-js'
|
|
824
|
+
import type { ParentProps } from 'solid-js'
|
|
831
825
|
|
|
832
826
|
export type LayoutGridProps = {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
827
|
+
count?: number
|
|
828
|
+
gutter?: string
|
|
829
|
+
maxWidth?: string
|
|
830
|
+
margin?: string
|
|
831
|
+
outline?: boolean
|
|
837
832
|
}
|
|
838
833
|
|
|
839
834
|
export declare const LayoutGrid: ParentProps<LayoutGridProps>
|
|
840
835
|
`,
|
|
841
836
|
js: import_outdent14.outdent`
|
|
837
|
+
import { createComponent, For } from 'solid-js/web'
|
|
838
|
+
|
|
842
839
|
export function LayoutGrid(props) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
/>
|
|
870
|
-
))}
|
|
871
|
-
</div>
|
|
872
|
-
);
|
|
873
|
-
}
|
|
840
|
+
const { count = 12, margin, gutter = '24px', maxWidth, outline } = props
|
|
841
|
+
const hasMaxWidth = maxWidth != null
|
|
842
|
+
return createComponent('div', {
|
|
843
|
+
className: 'panda-layout-grid',
|
|
844
|
+
style: {
|
|
845
|
+
'--gutter': gutter,
|
|
846
|
+
'--count': count,
|
|
847
|
+
'--max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
848
|
+
'--margin-x': hasMaxWidth ? 'auto' : undefined,
|
|
849
|
+
'--padding-x': !hasMaxWidth ? margin : undefined,
|
|
850
|
+
},
|
|
851
|
+
get children() {
|
|
852
|
+
return createComponent(For, {
|
|
853
|
+
get each() {
|
|
854
|
+
return Array.from({ length: count })
|
|
855
|
+
},
|
|
856
|
+
children: () =>
|
|
857
|
+
createComponent('span', {
|
|
858
|
+
'data-variant': outline ? 'outline' : 'bg',
|
|
859
|
+
className: 'panda-layout-grid__item',
|
|
860
|
+
}),
|
|
861
|
+
})
|
|
862
|
+
},
|
|
863
|
+
})
|
|
864
|
+
}
|
|
865
|
+
|
|
874
866
|
`
|
|
875
867
|
};
|
|
876
868
|
}
|
|
@@ -884,21 +876,22 @@ function generate3(ctx, name, pattern) {
|
|
|
884
876
|
return {
|
|
885
877
|
name: dashName,
|
|
886
878
|
js: import_outdent15.outdent`
|
|
887
|
-
import { splitProps } from 'solid-js'
|
|
888
|
-
import {
|
|
889
|
-
|
|
879
|
+
import { splitProps, mergeProps } from 'solid-js'
|
|
880
|
+
import { createComponent } from 'solid-js/web'
|
|
881
|
+
${ctx.getImport(ctx.jsxFactory, "./factory")}
|
|
882
|
+
${ctx.getImport(styleFn, `../patterns/${dashName}`)}
|
|
890
883
|
|
|
891
884
|
export function ${jsxName}(props) {
|
|
892
885
|
${(0, import_ts_pattern3.match)(props.length).with(
|
|
893
886
|
0,
|
|
894
887
|
() => import_outdent15.outdent`
|
|
895
|
-
return
|
|
888
|
+
return createComponent(${ctx.jsxFactory}.div, props)
|
|
896
889
|
`
|
|
897
890
|
).otherwise(
|
|
898
891
|
() => import_outdent15.outdent`
|
|
899
892
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
900
893
|
const styleProps = ${styleFn}(patternProps)
|
|
901
|
-
return
|
|
894
|
+
return createComponent(${ctx.jsxFactory}.div, mergeProps(styleProps, restProps))
|
|
902
895
|
`
|
|
903
896
|
)}
|
|
904
897
|
}
|
|
@@ -925,26 +918,26 @@ function generateSolidJsxTypes(ctx) {
|
|
|
925
918
|
const { name, componentName, upperName, typeName } = ctx.jsxFactoryDetails;
|
|
926
919
|
return {
|
|
927
920
|
jsxFactory: import_outdent16.outdent`
|
|
928
|
-
import { ${upperName} } from '../types/jsx'
|
|
921
|
+
import type { ${upperName} } from '../types/jsx'
|
|
929
922
|
export declare const ${name}: ${upperName}
|
|
930
923
|
`,
|
|
931
924
|
jsxType: import_outdent16.outdent`
|
|
932
|
-
import { JSX, ComponentProps, Component } from 'solid-js'
|
|
933
|
-
import { JsxStyleProps, Assign } from '.'
|
|
934
|
-
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
925
|
+
import type { JSX, ComponentProps, Component } from 'solid-js'
|
|
926
|
+
import type { JsxStyleProps, Assign } from '.'
|
|
927
|
+
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
935
928
|
|
|
936
929
|
type Dict = Record<string, unknown>
|
|
937
930
|
|
|
938
931
|
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
939
932
|
|
|
940
|
-
type
|
|
933
|
+
type HTMLProps = {
|
|
941
934
|
htmlSize?: string | number
|
|
942
935
|
htmlWidth?: string | number
|
|
943
936
|
htmlHeight?: string | number
|
|
944
937
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
945
938
|
}
|
|
946
939
|
|
|
947
|
-
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> &
|
|
940
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & HTMLProps
|
|
948
941
|
|
|
949
942
|
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
950
943
|
|
|
@@ -1011,10 +1004,10 @@ function generate4(ctx, name, pattern) {
|
|
|
1011
1004
|
return {
|
|
1012
1005
|
name: (0, import_shared.dashCase)(name),
|
|
1013
1006
|
dts: import_outdent17.outdent`
|
|
1014
|
-
import { SystemStyleObject, ConditionalValue } from '../types'
|
|
1015
|
-
import { PropertyValue } from '../types/prop-type'
|
|
1016
|
-
import { Properties } from '../types/csstype'
|
|
1017
|
-
import { Tokens } from '../types/token'
|
|
1007
|
+
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
1008
|
+
import type { PropertyValue } from '../types/prop-type'
|
|
1009
|
+
import type { Properties } from '../types/csstype'
|
|
1010
|
+
import type { Tokens } from '../types/token'
|
|
1018
1011
|
|
|
1019
1012
|
export type ${(0, import_shared.capitalize)(name)}Properties = {
|
|
1020
1013
|
${Object.keys(properties ?? {}).map((key) => {
|
|
@@ -1044,8 +1037,8 @@ function generate4(ctx, name, pattern) {
|
|
|
1044
1037
|
|
|
1045
1038
|
`,
|
|
1046
1039
|
js: import_outdent17.outdent`
|
|
1047
|
-
|
|
1048
|
-
|
|
1040
|
+
${ctx.getImport("mapObject", "../helpers")}
|
|
1041
|
+
${ctx.getImport("css", "../css/index")}
|
|
1049
1042
|
|
|
1050
1043
|
const config = ${(0, import_javascript_stringify.stringify)({ transform })}
|
|
1051
1044
|
|
|
@@ -1061,15 +1054,35 @@ function generatePattern(ctx) {
|
|
|
1061
1054
|
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(ctx, name, pattern));
|
|
1062
1055
|
}
|
|
1063
1056
|
|
|
1057
|
+
// src/generators/pkg-json.ts
|
|
1058
|
+
function generatePackageJSON(ctx) {
|
|
1059
|
+
const pkg = {
|
|
1060
|
+
name: ctx.outdir,
|
|
1061
|
+
description: "This package is auto-generated by CSS Panda",
|
|
1062
|
+
version: `0.0.0-${performance.now()}`,
|
|
1063
|
+
type: "module",
|
|
1064
|
+
exports: {
|
|
1065
|
+
"./css": { types: "./css/index.d.ts", import: "./css/index.mjs" },
|
|
1066
|
+
"./jsx": { types: "./jsx/index.d.ts", import: "./jsx/index.mjs" },
|
|
1067
|
+
"./patterns": { types: "./patterns/index.d.ts", import: "./patterns/index.mjs" },
|
|
1068
|
+
"./recipes": { types: "./recipes/index.d.ts", import: "./recipes/index.mjs" },
|
|
1069
|
+
"./tokens": { types: "./tokens/index.d.ts", import: "./tokens/index.mjs" },
|
|
1070
|
+
"./types": { types: "./types/index.d.ts" },
|
|
1071
|
+
"./styles.css": "./styles.css"
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
return JSON.stringify(pkg, null, 2);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1064
1077
|
// src/generators/prop-types.ts
|
|
1065
1078
|
var import_outdent18 = require("outdent");
|
|
1066
1079
|
function generatePropTypes(utility, strict) {
|
|
1067
1080
|
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1068
1081
|
const result = [
|
|
1069
1082
|
import_outdent18.outdent`
|
|
1070
|
-
import { ConditionalValue } from './conditions';
|
|
1071
|
-
import { Properties as CSSProperties } from './csstype'
|
|
1072
|
-
import { Tokens } from './token'
|
|
1083
|
+
import type { ConditionalValue } from './conditions';
|
|
1084
|
+
import type { Properties as CSSProperties } from './csstype'
|
|
1085
|
+
import type { Tokens } from './token'
|
|
1073
1086
|
|
|
1074
1087
|
type PropertyValueTypes = {`
|
|
1075
1088
|
];
|
|
@@ -1110,7 +1123,7 @@ function generateRecipes(ctx) {
|
|
|
1110
1123
|
return;
|
|
1111
1124
|
const js = [
|
|
1112
1125
|
import_outdent19.outdent`
|
|
1113
|
-
|
|
1126
|
+
${ctx.getImport("createCss, withoutSpace, compact", "../helpers")}
|
|
1114
1127
|
|
|
1115
1128
|
const createRecipe = (name, defaultVariants) => {
|
|
1116
1129
|
return (variants) => {
|
|
@@ -1126,6 +1139,7 @@ function generateRecipes(ctx) {
|
|
|
1126
1139
|
const context = {
|
|
1127
1140
|
hash: ${hash ? "true" : "false"},
|
|
1128
1141
|
utility: {
|
|
1142
|
+
prefix: ${ctx.prefix ? JSON.stringify(ctx.prefix) : void 0},
|
|
1129
1143
|
transform,
|
|
1130
1144
|
}
|
|
1131
1145
|
}
|
|
@@ -1143,7 +1157,7 @@ function generateRecipes(ctx) {
|
|
|
1143
1157
|
];
|
|
1144
1158
|
const dts = [
|
|
1145
1159
|
import_outdent19.outdent`
|
|
1146
|
-
import { ConditionalValue } from '../types'
|
|
1160
|
+
import type { ConditionalValue } from '../types'
|
|
1147
1161
|
`
|
|
1148
1162
|
];
|
|
1149
1163
|
Object.values(recipes).forEach((recipe) => {
|
|
@@ -1381,20 +1395,22 @@ function generateTokenJs(dict) {
|
|
|
1381
1395
|
js: import_outdent21.default`
|
|
1382
1396
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1383
1397
|
|
|
1384
|
-
export function
|
|
1385
|
-
|
|
1386
|
-
return value
|
|
1398
|
+
export function token(path, fallback) {
|
|
1399
|
+
return tokens[path]?.value || fallback
|
|
1387
1400
|
}
|
|
1388
1401
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
return variable
|
|
1402
|
+
function tokenVar(path, fallback) {
|
|
1403
|
+
return tokens[path]?.variable || fallback
|
|
1392
1404
|
}
|
|
1405
|
+
|
|
1406
|
+
token.var = tokenVar
|
|
1393
1407
|
`,
|
|
1394
1408
|
dts: import_outdent21.default`
|
|
1395
|
-
import { Token } from
|
|
1396
|
-
|
|
1397
|
-
export declare function
|
|
1409
|
+
import type { Token } from '../types/token'
|
|
1410
|
+
|
|
1411
|
+
export declare function token(path: Token, fallback?: string): string & {
|
|
1412
|
+
var: (path: Token, fallback?: string) => string
|
|
1413
|
+
}
|
|
1398
1414
|
`
|
|
1399
1415
|
};
|
|
1400
1416
|
}
|
|
@@ -1414,7 +1430,21 @@ function generateCssType(ctx) {
|
|
|
1414
1430
|
system: getType("system-types.d.ts"),
|
|
1415
1431
|
selectors: getType("selectors.d.ts"),
|
|
1416
1432
|
recipe: getType("recipe.d.ts"),
|
|
1433
|
+
composition: getType("composition.d.ts"),
|
|
1434
|
+
global: import_outdent22.default`
|
|
1435
|
+
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1436
|
+
import { GlobalStyleObject } from './system-types'
|
|
1437
|
+
import { CompositionStyles } from './composition'
|
|
1438
|
+
|
|
1439
|
+
declare module 'css-panda' {
|
|
1440
|
+
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig<V>
|
|
1441
|
+
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
1442
|
+
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
1443
|
+
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1444
|
+
}
|
|
1445
|
+
`,
|
|
1417
1446
|
exported: import_outdent22.default`
|
|
1447
|
+
import './global'
|
|
1418
1448
|
export { ConditionalValue } from './conditions'
|
|
1419
1449
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1420
1450
|
|
|
@@ -1440,8 +1470,7 @@ function setupHelpers(ctx) {
|
|
|
1440
1470
|
const sharedMjs = getEntrypoint("@pandacss/shared", { dev: "shared.mjs" });
|
|
1441
1471
|
const code = (0, import_fs2.readFileSync)(sharedMjs, "utf-8");
|
|
1442
1472
|
return {
|
|
1443
|
-
|
|
1444
|
-
files: [{ file: ctx.getJsFile("helpers"), code }]
|
|
1473
|
+
files: [{ file: ctx.getExt("helpers"), code }]
|
|
1445
1474
|
};
|
|
1446
1475
|
}
|
|
1447
1476
|
function setupKeyframes(ctx) {
|
|
@@ -1452,9 +1481,8 @@ function setupKeyframes(ctx) {
|
|
|
1452
1481
|
};
|
|
1453
1482
|
}
|
|
1454
1483
|
function setupDesignTokens(ctx) {
|
|
1455
|
-
if (ctx.tokens.isEmpty)
|
|
1456
|
-
return
|
|
1457
|
-
}
|
|
1484
|
+
if (ctx.tokens.isEmpty)
|
|
1485
|
+
return;
|
|
1458
1486
|
const code = generateTokenJs(ctx.tokens);
|
|
1459
1487
|
const css2 = generateTokenCss(ctx);
|
|
1460
1488
|
return {
|
|
@@ -1462,7 +1490,7 @@ function setupDesignTokens(ctx) {
|
|
|
1462
1490
|
files: [
|
|
1463
1491
|
{ file: "index.css", code: css2 },
|
|
1464
1492
|
{ file: "index.d.ts", code: code.dts },
|
|
1465
|
-
{ file: ctx.
|
|
1493
|
+
{ file: ctx.getExt("index"), code: code.js }
|
|
1466
1494
|
]
|
|
1467
1495
|
};
|
|
1468
1496
|
}
|
|
@@ -1477,6 +1505,8 @@ function setupTypes(ctx) {
|
|
|
1477
1505
|
{ file: "csstype.d.ts", code: types.css },
|
|
1478
1506
|
{ file: "system-types.d.ts", code: types.system },
|
|
1479
1507
|
{ file: "selectors.d.ts", code: types.selectors },
|
|
1508
|
+
{ file: "composition.d.ts", code: types.composition },
|
|
1509
|
+
{ file: "global.d.ts", code: types.global },
|
|
1480
1510
|
{ file: "recipe.d.ts", code: types.recipe },
|
|
1481
1511
|
{ file: "index.d.ts", code: types.exported },
|
|
1482
1512
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
@@ -1492,18 +1522,18 @@ function setupCss(ctx) {
|
|
|
1492
1522
|
return {
|
|
1493
1523
|
dir: ctx.paths.css,
|
|
1494
1524
|
files: [
|
|
1495
|
-
{ file: ctx.
|
|
1496
|
-
{ file: ctx.
|
|
1525
|
+
{ file: ctx.getExt("conditions"), code: conditions.js },
|
|
1526
|
+
{ file: ctx.getExt("css"), code: code.js },
|
|
1497
1527
|
{ file: "css.d.ts", code: code.dts }
|
|
1498
1528
|
]
|
|
1499
1529
|
};
|
|
1500
1530
|
}
|
|
1501
1531
|
function setupCva(ctx) {
|
|
1502
|
-
const code = generateCvaFn();
|
|
1532
|
+
const code = generateCvaFn(ctx);
|
|
1503
1533
|
return {
|
|
1504
1534
|
dir: ctx.paths.css,
|
|
1505
1535
|
files: [
|
|
1506
|
-
{ file: ctx.
|
|
1536
|
+
{ file: ctx.getExt("cva"), code: code.js },
|
|
1507
1537
|
{ file: "cva.d.ts", code: code.dts }
|
|
1508
1538
|
]
|
|
1509
1539
|
};
|
|
@@ -1513,94 +1543,111 @@ function setupCx(ctx) {
|
|
|
1513
1543
|
return {
|
|
1514
1544
|
dir: ctx.paths.css,
|
|
1515
1545
|
files: [
|
|
1516
|
-
{ file: ctx.
|
|
1546
|
+
{ file: ctx.getExt("cx"), code: code.js },
|
|
1517
1547
|
{ file: "cx.d.ts", code: code.dts }
|
|
1518
1548
|
]
|
|
1519
1549
|
};
|
|
1520
1550
|
}
|
|
1521
1551
|
function setupRecipes(ctx) {
|
|
1522
1552
|
const code = generateRecipes(ctx);
|
|
1523
|
-
if (!code)
|
|
1524
|
-
return
|
|
1525
|
-
}
|
|
1553
|
+
if (!code)
|
|
1554
|
+
return;
|
|
1526
1555
|
return {
|
|
1527
1556
|
dir: ctx.paths.recipe,
|
|
1528
1557
|
files: [
|
|
1529
|
-
{ file: ctx.
|
|
1558
|
+
{ file: ctx.getExt("index"), code: code.js },
|
|
1530
1559
|
{ file: "index.d.ts", code: code.dts }
|
|
1531
1560
|
]
|
|
1532
1561
|
};
|
|
1533
1562
|
}
|
|
1534
1563
|
function setupPatterns(ctx) {
|
|
1535
1564
|
const files = generatePattern(ctx);
|
|
1536
|
-
if (!files)
|
|
1537
|
-
return
|
|
1538
|
-
|
|
1539
|
-
|
|
1565
|
+
if (!files)
|
|
1566
|
+
return;
|
|
1567
|
+
const index = {
|
|
1568
|
+
js: import_outdent23.default.string(files.map((file) => ctx.getExport(`./${file.name}`)).join("\n")),
|
|
1569
|
+
dts: import_outdent23.default.string(files.map((file) => `export { ${file.name} } from './${file.name}'`).join("\n"))
|
|
1570
|
+
};
|
|
1540
1571
|
return {
|
|
1541
1572
|
dir: ctx.paths.pattern,
|
|
1542
1573
|
files: [
|
|
1543
|
-
...files.map((file) => ({ file: ctx.
|
|
1574
|
+
...files.map((file) => ({ file: ctx.getExt(file.name), code: file.js })),
|
|
1544
1575
|
...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1545
|
-
{ file: ctx.
|
|
1546
|
-
{ file: "index.d.ts", code:
|
|
1576
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1577
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1547
1578
|
]
|
|
1548
1579
|
};
|
|
1549
1580
|
}
|
|
1550
1581
|
function setupJsx(ctx) {
|
|
1551
1582
|
if (!ctx.jsxFramework)
|
|
1552
|
-
return
|
|
1583
|
+
return;
|
|
1553
1584
|
const isValidProp = generateisValidProp(ctx);
|
|
1554
1585
|
const types = generateJsxTypes(ctx);
|
|
1555
1586
|
const factory = generateJsxFactory(ctx);
|
|
1556
1587
|
const patterns = generateJsxPatterns(ctx);
|
|
1557
1588
|
const layoutGrid = generateLayoutGrid(ctx);
|
|
1558
|
-
const
|
|
1589
|
+
const index = {
|
|
1590
|
+
js: import_outdent23.default`
|
|
1591
|
+
${ctx.getExport("./factory")}
|
|
1592
|
+
${ctx.getExport("./layout-grid")}
|
|
1593
|
+
${import_outdent23.default.string(patterns.map((file) => ctx.getExport(`./${file.name}`)).join("\n"))}
|
|
1594
|
+
`,
|
|
1595
|
+
dts: import_outdent23.default`
|
|
1559
1596
|
export * from './factory'
|
|
1560
1597
|
export * from './layout-grid'
|
|
1561
1598
|
${import_outdent23.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1562
|
-
|
|
1599
|
+
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1600
|
+
`
|
|
1601
|
+
};
|
|
1563
1602
|
return {
|
|
1564
1603
|
dir: ctx.paths.jsx,
|
|
1565
1604
|
files: [
|
|
1566
|
-
...patterns.map((file) => ({ file: `${file.name}.
|
|
1605
|
+
...patterns.map((file) => ({ file: `${file.name}.mjs`, code: file.js })),
|
|
1567
1606
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1568
|
-
{ file: "layout-grid.
|
|
1607
|
+
{ file: "layout-grid.mjs", code: layoutGrid.js },
|
|
1569
1608
|
{ file: "layout-grid.d.ts", code: layoutGrid.dts },
|
|
1570
|
-
{ file: ctx.
|
|
1609
|
+
{ file: ctx.getExt("is-valid-prop"), code: isValidProp.js },
|
|
1571
1610
|
{ file: "factory.d.ts", code: types.jsxFactory },
|
|
1572
|
-
{ file: "factory.
|
|
1573
|
-
{
|
|
1574
|
-
|
|
1575
|
-
code: import_outdent23.default`
|
|
1576
|
-
${indexCode}
|
|
1577
|
-
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1578
|
-
`
|
|
1579
|
-
},
|
|
1580
|
-
{ file: "index.jsx", code: indexCode }
|
|
1611
|
+
{ file: "factory.mjs", code: factory.js },
|
|
1612
|
+
{ file: "index.d.ts", code: index.dts },
|
|
1613
|
+
{ file: "index.mjs", code: index.js }
|
|
1581
1614
|
]
|
|
1582
1615
|
};
|
|
1583
1616
|
}
|
|
1584
1617
|
function setupCssIndex(ctx) {
|
|
1585
|
-
const
|
|
1618
|
+
const index = {
|
|
1619
|
+
js: import_outdent23.default`
|
|
1620
|
+
${ctx.getExport("./css")}
|
|
1621
|
+
${ctx.getExport("./cx")}
|
|
1622
|
+
${ctx.getExport("./cva")}
|
|
1623
|
+
`,
|
|
1624
|
+
dts: import_outdent23.default`
|
|
1586
1625
|
export * from './css'
|
|
1587
1626
|
export * from './cx'
|
|
1588
1627
|
export * from './cva'
|
|
1589
|
-
|
|
1628
|
+
`
|
|
1629
|
+
};
|
|
1590
1630
|
return {
|
|
1591
1631
|
dir: ctx.paths.css,
|
|
1592
1632
|
files: [
|
|
1593
|
-
{ file: ctx.
|
|
1594
|
-
{ file: "index.d.ts", code }
|
|
1633
|
+
{ file: ctx.getExt("index"), code: index.js },
|
|
1634
|
+
{ file: "index.d.ts", code: index.dts }
|
|
1595
1635
|
]
|
|
1596
1636
|
};
|
|
1597
1637
|
}
|
|
1598
1638
|
function setupReset(ctx) {
|
|
1599
1639
|
if (!ctx.preflight)
|
|
1600
|
-
return
|
|
1640
|
+
return;
|
|
1601
1641
|
const code = generateReset();
|
|
1602
1642
|
return { files: [{ file: "reset.css", code }] };
|
|
1603
1643
|
}
|
|
1644
|
+
function setupPackageJson(ctx) {
|
|
1645
|
+
if (!ctx.emitPackage)
|
|
1646
|
+
return;
|
|
1647
|
+
return {
|
|
1648
|
+
files: [{ file: "package.json", code: generatePackageJSON(ctx) }]
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1604
1651
|
function generateSystem(ctx) {
|
|
1605
1652
|
return [
|
|
1606
1653
|
setupHelpers(ctx),
|
|
@@ -1614,8 +1661,9 @@ function generateSystem(ctx) {
|
|
|
1614
1661
|
setupPatterns(ctx),
|
|
1615
1662
|
setupCssIndex(ctx),
|
|
1616
1663
|
setupJsx(ctx),
|
|
1617
|
-
setupReset(ctx)
|
|
1618
|
-
|
|
1664
|
+
setupReset(ctx),
|
|
1665
|
+
setupPackageJson(ctx)
|
|
1666
|
+
].filter(Boolean);
|
|
1619
1667
|
}
|
|
1620
1668
|
|
|
1621
1669
|
// src/messages.ts
|
|
@@ -1700,10 +1748,14 @@ async function emitArtifacts(ctx) {
|
|
|
1700
1748
|
}
|
|
1701
1749
|
async function emitAndExtract(ctx) {
|
|
1702
1750
|
await emitArtifacts(ctx);
|
|
1751
|
+
return extractCss(ctx);
|
|
1752
|
+
}
|
|
1753
|
+
async function extractCss(ctx) {
|
|
1703
1754
|
await extractGlobalCss(ctx);
|
|
1704
1755
|
await extractStaticCss(ctx);
|
|
1705
1756
|
await extractFiles(ctx);
|
|
1706
1757
|
await bundleChunks(ctx);
|
|
1758
|
+
return buildCompleteMessage(ctx);
|
|
1707
1759
|
}
|
|
1708
1760
|
function getBaseCss(ctx) {
|
|
1709
1761
|
const css2 = [
|
|
@@ -1763,7 +1815,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1763
1815
|
const {
|
|
1764
1816
|
cwd: cwdProp = process.cwd(),
|
|
1765
1817
|
conditions: conditionsProp = {},
|
|
1766
|
-
|
|
1818
|
+
prefix,
|
|
1767
1819
|
cssVarRoot = ":where(:root, :host)",
|
|
1768
1820
|
outdir,
|
|
1769
1821
|
exclude: excludeProp = [],
|
|
@@ -1776,7 +1828,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
1776
1828
|
globalCss,
|
|
1777
1829
|
separator,
|
|
1778
1830
|
static: staticCss,
|
|
1779
|
-
outExtension = "mjs"
|
|
1831
|
+
outExtension = "mjs",
|
|
1832
|
+
emitPackage
|
|
1780
1833
|
} = config;
|
|
1781
1834
|
const {
|
|
1782
1835
|
breakpoints = {},
|
|
@@ -1794,15 +1847,17 @@ function createContext(conf, io = fileSystem) {
|
|
|
1794
1847
|
framework: jsxFramework
|
|
1795
1848
|
};
|
|
1796
1849
|
const cwd = (0, import_path2.resolve)(cwdProp);
|
|
1797
|
-
const exclude = [".git", "node_modules", "test-results"].concat(excludeProp);
|
|
1850
|
+
const exclude = [".git", ".yarn", "node_modules", "test-results"].concat(excludeProp);
|
|
1798
1851
|
const tokens = new import_token_dictionary.TokenDictionary({
|
|
1799
1852
|
tokens: tokensProp,
|
|
1853
|
+
breakpoints,
|
|
1800
1854
|
semanticTokens,
|
|
1801
|
-
prefix
|
|
1855
|
+
prefix
|
|
1802
1856
|
});
|
|
1803
1857
|
const hasTokens = !tokens.isEmpty;
|
|
1804
1858
|
import_logger4.logger.debug({ type: "ctx:token", msg: tokens.allNames });
|
|
1805
1859
|
const utility = new import_core3.Utility({
|
|
1860
|
+
prefix,
|
|
1806
1861
|
tokens,
|
|
1807
1862
|
config: utilities,
|
|
1808
1863
|
separator
|
|
@@ -1889,14 +1944,24 @@ function createContext(conf, io = fileSystem) {
|
|
|
1889
1944
|
function isStyleProp(prop) {
|
|
1890
1945
|
return (0, import_is_valid_prop3.isCssProperty)(prop) || isCustomCssProperty(prop);
|
|
1891
1946
|
}
|
|
1892
|
-
function getPath(
|
|
1893
|
-
|
|
1947
|
+
function getPath(pathLike) {
|
|
1948
|
+
const paths2 = [cwd, emitPackage ? "node_modules" : void 0, outdir, pathLike].filter(Boolean);
|
|
1949
|
+
return (0, import_path2.join)(...paths2);
|
|
1894
1950
|
}
|
|
1895
1951
|
function absPath(str) {
|
|
1896
1952
|
return (0, import_path2.isAbsolute)(str) ? str : (0, import_path2.join)(cwd, str);
|
|
1897
1953
|
}
|
|
1954
|
+
function getExt(file) {
|
|
1955
|
+
return `${file}.${outExtension}`;
|
|
1956
|
+
}
|
|
1957
|
+
function getImport(items, mod) {
|
|
1958
|
+
return `import { ${items} } from '${getExt(mod)}';`;
|
|
1959
|
+
}
|
|
1960
|
+
function getExport(mod) {
|
|
1961
|
+
return `export * from '${getExt(mod)}';`;
|
|
1962
|
+
}
|
|
1898
1963
|
const paths = {
|
|
1899
|
-
|
|
1964
|
+
root: getPath(),
|
|
1900
1965
|
css: getPath("css"),
|
|
1901
1966
|
token: getPath("tokens"),
|
|
1902
1967
|
types: getPath("types"),
|
|
@@ -1918,15 +1983,14 @@ function createContext(conf, io = fileSystem) {
|
|
|
1918
1983
|
);
|
|
1919
1984
|
}
|
|
1920
1985
|
function cleanOutdir() {
|
|
1921
|
-
return (0, import_fs_extra2.emptyDir)(
|
|
1986
|
+
return (0, import_fs_extra2.emptyDir)(paths.root);
|
|
1922
1987
|
}
|
|
1923
1988
|
function writeOutput(output) {
|
|
1924
|
-
|
|
1989
|
+
if (!output)
|
|
1990
|
+
return;
|
|
1991
|
+
const { dir = paths.root, files: files2 } = output;
|
|
1925
1992
|
return write(dir, files2);
|
|
1926
1993
|
}
|
|
1927
|
-
function getJsFile(file) {
|
|
1928
|
-
return `${file}.${outExtension}`;
|
|
1929
|
-
}
|
|
1930
1994
|
const chunks = {
|
|
1931
1995
|
dir: paths.chunk,
|
|
1932
1996
|
readFile(file) {
|
|
@@ -1956,6 +2020,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
1956
2020
|
const fileName = chunks.format(file);
|
|
1957
2021
|
return io.rm((0, import_path2.join)(paths.chunk, fileName));
|
|
1958
2022
|
},
|
|
2023
|
+
empty() {
|
|
2024
|
+
return (0, import_fs_extra2.emptyDir)(paths.chunk);
|
|
2025
|
+
},
|
|
1959
2026
|
glob: [`${paths.chunk}/**/*.css`]
|
|
1960
2027
|
};
|
|
1961
2028
|
function getFiles() {
|
|
@@ -2018,6 +2085,30 @@ function createContext(conf, io = fileSystem) {
|
|
|
2018
2085
|
sheet.processGlobalCss({
|
|
2019
2086
|
":root": {
|
|
2020
2087
|
"--made-with-panda": `'\u{1F43C}'`
|
|
2088
|
+
},
|
|
2089
|
+
".panda-layout-grid": {
|
|
2090
|
+
display: "grid",
|
|
2091
|
+
gap: "var(--gutter)",
|
|
2092
|
+
gridTemplateColumns: "repeat(var(--count), 1fr)",
|
|
2093
|
+
height: "100%",
|
|
2094
|
+
width: "100%",
|
|
2095
|
+
position: "absolute",
|
|
2096
|
+
inset: "0",
|
|
2097
|
+
pointerEvents: "none",
|
|
2098
|
+
maxWidth: "var(--max-width)",
|
|
2099
|
+
marginInline: "var(--margin-x)",
|
|
2100
|
+
paddingInline: "var(--padding-x)"
|
|
2101
|
+
},
|
|
2102
|
+
".panda-layout-grid__item": {
|
|
2103
|
+
display: "flex",
|
|
2104
|
+
"--color": "rgba(255, 0, 0, 0.1)",
|
|
2105
|
+
height: "100%",
|
|
2106
|
+
"&[data-variant=bg]": {
|
|
2107
|
+
background: "var(--color)"
|
|
2108
|
+
},
|
|
2109
|
+
"&[data-variant=outline]": {
|
|
2110
|
+
borderInline: "1px solid var(--color)"
|
|
2111
|
+
}
|
|
2021
2112
|
}
|
|
2022
2113
|
});
|
|
2023
2114
|
if (globalCss) {
|
|
@@ -2131,7 +2222,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
2131
2222
|
write,
|
|
2132
2223
|
writeOutput,
|
|
2133
2224
|
cleanOutdir,
|
|
2134
|
-
|
|
2225
|
+
getExt,
|
|
2226
|
+
getImport,
|
|
2227
|
+
getExport,
|
|
2135
2228
|
cssVarRoot,
|
|
2136
2229
|
tokens,
|
|
2137
2230
|
hasTokens,
|
|
@@ -2417,8 +2510,8 @@ process.on("uncaughtException", (err) => {
|
|
|
2417
2510
|
// src/generate.ts
|
|
2418
2511
|
async function build(config, configPath) {
|
|
2419
2512
|
const ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2420
|
-
await emitAndExtract(ctx);
|
|
2421
|
-
import_logger8.logger.info(
|
|
2513
|
+
const msg = await emitAndExtract(ctx);
|
|
2514
|
+
import_logger8.logger.info(msg);
|
|
2422
2515
|
return ctx;
|
|
2423
2516
|
}
|
|
2424
2517
|
async function generate5(config, configPath) {
|
|
@@ -2519,6 +2612,7 @@ async function setupPostcss(cwd) {
|
|
|
2519
2612
|
emitAndExtract,
|
|
2520
2613
|
emitArtifacts,
|
|
2521
2614
|
execCommand,
|
|
2615
|
+
extractCss,
|
|
2522
2616
|
generate,
|
|
2523
2617
|
loadConfigAndCreateContext,
|
|
2524
2618
|
setupConfig,
|