@pandacss/node 0.0.0-dev-20221124070053 → 0.0.0-dev-20221124124535
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +271 -71
- package/dist/index.mjs +270 -70
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -70,7 +70,7 @@ async function writeFileChunk(ctx, file) {
|
|
|
70
70
|
// src/generators/index.ts
|
|
71
71
|
import { readFileSync as readFileSync3 } from "fs";
|
|
72
72
|
import { lookItUpSync } from "look-it-up";
|
|
73
|
-
import
|
|
73
|
+
import outdent22 from "outdent";
|
|
74
74
|
import { dirname as dirname2 } from "path";
|
|
75
75
|
|
|
76
76
|
// src/generators/conditions.ts
|
|
@@ -332,27 +332,90 @@ function generatePreactJsxFactory(ctx) {
|
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
// src/generators/jsx/preact-layout-grid.ts
|
|
336
|
+
import { outdent as outdent7 } from "outdent";
|
|
337
|
+
function generatePreactLayoutGrid() {
|
|
338
|
+
return {
|
|
339
|
+
dts: outdent7`
|
|
340
|
+
import { FunctionComponent } from 'preact'
|
|
341
|
+
|
|
342
|
+
export type LayoutGridProps = {
|
|
343
|
+
count?: number
|
|
344
|
+
gutter?: string
|
|
345
|
+
maxWidth?: string
|
|
346
|
+
margin?: string
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
350
|
+
`,
|
|
351
|
+
js: outdent7`
|
|
352
|
+
export function LayoutGrid(props) {
|
|
353
|
+
const { count = 12, margin, gutter = '24px', maxWidth } = props
|
|
354
|
+
const hasMaxWidth = maxWidth != null;
|
|
355
|
+
return (
|
|
356
|
+
<div
|
|
357
|
+
style={{
|
|
358
|
+
display: 'grid',
|
|
359
|
+
gap: gutter,
|
|
360
|
+
gridTemplateColumns: \`repeat(\${count}, 1fr)\`,
|
|
361
|
+
height: '100%',
|
|
362
|
+
width: '100%',
|
|
363
|
+
position: 'absolute',
|
|
364
|
+
inset: '0',
|
|
365
|
+
pointerEvents: 'none',
|
|
366
|
+
maxWidth: hasMaxWidth ? maxWidth : 'initial',
|
|
367
|
+
marginInline: hasMaxWidth ? 'auto' : undefined,
|
|
368
|
+
paddingInline: !hasMaxWidth ? margin : undefined,
|
|
369
|
+
}}
|
|
370
|
+
>
|
|
371
|
+
{Array.from({ length: count }).map((_, i) => (
|
|
372
|
+
<span
|
|
373
|
+
key={i}
|
|
374
|
+
style={{
|
|
375
|
+
display: 'flex',
|
|
376
|
+
background: 'rgba(255, 0, 0, 0.1)',
|
|
377
|
+
height: '100%',
|
|
378
|
+
}}
|
|
379
|
+
/>
|
|
380
|
+
))}
|
|
381
|
+
</div>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
`
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
335
388
|
// src/generators/jsx/preact-pattern.ts
|
|
336
389
|
import { capitalize as capitalize2, dashCase } from "@pandacss/shared";
|
|
337
|
-
import { outdent as
|
|
390
|
+
import { outdent as outdent8 } from "outdent";
|
|
391
|
+
import { match } from "ts-pattern";
|
|
338
392
|
function generate(name, pattern, jsxFactory) {
|
|
339
393
|
const upperName = capitalize2(name);
|
|
340
394
|
const jsxName = pattern.jsx ?? upperName;
|
|
341
395
|
const keys = Object.keys(pattern.properties ?? {});
|
|
342
396
|
return {
|
|
343
397
|
name: dashCase(name),
|
|
344
|
-
js:
|
|
398
|
+
js: outdent8`
|
|
345
399
|
import { forwardRef } from 'preact/compat'
|
|
346
400
|
import { ${jsxFactory} } from './factory'
|
|
347
401
|
import { config } from '../patterns/${dashCase(name)}'
|
|
348
402
|
|
|
349
403
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
404
|
+
${match(keys.length).with(
|
|
405
|
+
0,
|
|
406
|
+
() => `
|
|
407
|
+
return <${jsxFactory}.div ref={ref} {...props} />
|
|
408
|
+
`
|
|
409
|
+
).otherwise(
|
|
410
|
+
() => `
|
|
411
|
+
const { ${keys.join(", ")}, ...restProps } = props
|
|
412
|
+
const styleProps = config.transform({${keys.join(", ")}})
|
|
413
|
+
return <${jsxFactory}.div ref={ref} {...styleProps} {...restProps} />
|
|
414
|
+
`
|
|
415
|
+
)}
|
|
353
416
|
})
|
|
354
417
|
`,
|
|
355
|
-
dts:
|
|
418
|
+
dts: outdent8`
|
|
356
419
|
import { ComponentProps, JSX, ComponentChildren } from 'preact';
|
|
357
420
|
import { ${upperName}Options } from '../patterns/${dashCase(name)}'
|
|
358
421
|
import { JSXStyleProperties, Assign } from '../types'
|
|
@@ -365,7 +428,7 @@ function generate(name, pattern, jsxFactory) {
|
|
|
365
428
|
type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
|
|
366
429
|
Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
|
|
367
430
|
|
|
368
|
-
type ${jsxName}Props<C extends ElementType> = Polymorphic<C, ${upperName}Options>
|
|
431
|
+
type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Options>
|
|
369
432
|
|
|
370
433
|
export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
|
|
371
434
|
`
|
|
@@ -379,12 +442,12 @@ function generatePreactJsxPattern(ctx) {
|
|
|
379
442
|
|
|
380
443
|
// src/generators/jsx/react-jsx.ts
|
|
381
444
|
import { capitalize as capitalize3 } from "@pandacss/shared";
|
|
382
|
-
import { outdent as
|
|
445
|
+
import { outdent as outdent9 } from "outdent";
|
|
383
446
|
function generateReactJsxFactory(ctx) {
|
|
384
447
|
const name = ctx.jsxFactory;
|
|
385
448
|
const upperName = capitalize3(name);
|
|
386
449
|
return {
|
|
387
|
-
dts:
|
|
450
|
+
dts: outdent9`
|
|
388
451
|
import type { ComponentProps } from "react"
|
|
389
452
|
import type { JSXStyleProperties } from "../types"
|
|
390
453
|
|
|
@@ -398,7 +461,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
398
461
|
|
|
399
462
|
export declare const ${name}: JSXFactory
|
|
400
463
|
`,
|
|
401
|
-
js:
|
|
464
|
+
js: outdent9`
|
|
402
465
|
import { forwardRef } from 'react'
|
|
403
466
|
import { isCssProperty } from './is-valid-prop'
|
|
404
467
|
import { css } from '../css'
|
|
@@ -459,27 +522,91 @@ function generateReactJsxFactory(ctx) {
|
|
|
459
522
|
};
|
|
460
523
|
}
|
|
461
524
|
|
|
525
|
+
// src/generators/jsx/react-layout-grid.ts
|
|
526
|
+
import { outdent as outdent10 } from "outdent";
|
|
527
|
+
function generateReactLayoutGrid() {
|
|
528
|
+
return {
|
|
529
|
+
dts: outdent10`
|
|
530
|
+
import type { FunctionComponent } from 'react'
|
|
531
|
+
|
|
532
|
+
export type LayoutGridProps = {
|
|
533
|
+
count?: number
|
|
534
|
+
gutter?: string
|
|
535
|
+
maxWidth?: string
|
|
536
|
+
margin?: string
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
|
|
540
|
+
`,
|
|
541
|
+
js: outdent10`
|
|
542
|
+
export function LayoutGrid(props) {
|
|
543
|
+
const { count = 12, margin, gutter = '24px', maxWidth } = props
|
|
544
|
+
const hasMaxWidth = maxWidth != null;
|
|
545
|
+
return (
|
|
546
|
+
<div
|
|
547
|
+
style={{
|
|
548
|
+
display: 'grid',
|
|
549
|
+
gap: gutter,
|
|
550
|
+
gridTemplateColumns: \`repeat(\${count}, 1fr)\`,
|
|
551
|
+
height: '100%',
|
|
552
|
+
width: '100%',
|
|
553
|
+
position: 'absolute',
|
|
554
|
+
inset: '0',
|
|
555
|
+
pointerEvents: 'none',
|
|
556
|
+
maxWidth: hasMaxWidth ? maxWidth : 'initial',
|
|
557
|
+
marginInline: hasMaxWidth ? 'auto' : undefined,
|
|
558
|
+
paddingInline: !hasMaxWidth ? margin : undefined,
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
{Array.from({ length: count }).map((_, i) => (
|
|
562
|
+
<span
|
|
563
|
+
key={i}
|
|
564
|
+
style={{
|
|
565
|
+
display: 'flex',
|
|
566
|
+
background: 'rgba(255, 0, 0, 0.1)',
|
|
567
|
+
height: '100%',
|
|
568
|
+
}}
|
|
569
|
+
/>
|
|
570
|
+
))}
|
|
571
|
+
</div>
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
`
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
462
578
|
// src/generators/jsx/react-pattern.ts
|
|
463
579
|
import { capitalize as capitalize4, dashCase as dashCase2 } from "@pandacss/shared";
|
|
464
|
-
import { outdent as
|
|
580
|
+
import { outdent as outdent11 } from "outdent";
|
|
581
|
+
import { match as match2 } from "ts-pattern";
|
|
465
582
|
function generate2(name, pattern, jsxFactory) {
|
|
466
583
|
const upperName = capitalize4(name);
|
|
467
584
|
const jsxName = pattern.jsx ?? upperName;
|
|
468
585
|
const keys = Object.keys(pattern.properties ?? {});
|
|
469
586
|
return {
|
|
470
587
|
name: dashCase2(name),
|
|
471
|
-
js:
|
|
588
|
+
js: outdent11`
|
|
472
589
|
import { forwardRef } from 'react'
|
|
473
590
|
import { ${jsxFactory} } from './factory'
|
|
474
591
|
import { config } from '../patterns/${dashCase2(name)}'
|
|
475
592
|
|
|
476
593
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
594
|
+
${match2(keys.length).with(
|
|
595
|
+
0,
|
|
596
|
+
() => `
|
|
597
|
+
return <${jsxFactory}.div ref={ref} {...props} />
|
|
598
|
+
`
|
|
599
|
+
).otherwise(
|
|
600
|
+
() => `
|
|
601
|
+
const { ${keys.join(", ")}, ...restProps } = props
|
|
602
|
+
const styleProps = config.transform({${keys.join(", ")}})
|
|
603
|
+
return <${jsxFactory}.div ref={ref} {...styleProps} {...restProps} />
|
|
604
|
+
`
|
|
605
|
+
)}
|
|
606
|
+
|
|
480
607
|
})
|
|
481
608
|
`,
|
|
482
|
-
dts:
|
|
609
|
+
dts: outdent11`
|
|
483
610
|
import { ComponentProps, ElementType, PropsWithChildren } from 'react'
|
|
484
611
|
import { ${upperName}Options } from '../patterns/${dashCase2(name)}'
|
|
485
612
|
import { JSXStyleProperties, Assign } from '../types'
|
|
@@ -489,7 +616,7 @@ function generate2(name, pattern, jsxFactory) {
|
|
|
489
616
|
type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
|
|
490
617
|
Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
|
|
491
618
|
|
|
492
|
-
export type ${jsxName}Props<C extends ElementType> = Polymorphic<C, ${upperName}Options>
|
|
619
|
+
export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Options>
|
|
493
620
|
|
|
494
621
|
export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
|
|
495
622
|
`
|
|
@@ -503,12 +630,12 @@ function generateReactJsxPattern(ctx) {
|
|
|
503
630
|
|
|
504
631
|
// src/generators/jsx/solid-jsx.ts
|
|
505
632
|
import { capitalize as capitalize5 } from "@pandacss/shared";
|
|
506
|
-
import { outdent as
|
|
633
|
+
import { outdent as outdent12 } from "outdent";
|
|
507
634
|
function generateSolidJsxFactory(ctx) {
|
|
508
635
|
const name = ctx.jsxFactory;
|
|
509
636
|
const upperName = capitalize5(name);
|
|
510
637
|
return {
|
|
511
|
-
dts:
|
|
638
|
+
dts: outdent12`
|
|
512
639
|
import type { JSX } from 'solid-js'
|
|
513
640
|
import type { JSXStyleProperties, Assign} from '../types'
|
|
514
641
|
|
|
@@ -522,7 +649,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
522
649
|
|
|
523
650
|
export declare const ${name}: JSXFactory
|
|
524
651
|
`,
|
|
525
|
-
js:
|
|
652
|
+
js: outdent12`
|
|
526
653
|
import { Dynamic } from 'solid-js/web';
|
|
527
654
|
import { mergeProps, splitProps } from 'solid-js';
|
|
528
655
|
import { allCssProperties } from './is-valid-prop'
|
|
@@ -570,27 +697,88 @@ function generateSolidJsxFactory(ctx) {
|
|
|
570
697
|
};
|
|
571
698
|
}
|
|
572
699
|
|
|
700
|
+
// src/generators/jsx/solid-layout-grid.ts
|
|
701
|
+
import { outdent as outdent13 } from "outdent";
|
|
702
|
+
function generateSolidLayoutGrid() {
|
|
703
|
+
return {
|
|
704
|
+
dts: outdent13`
|
|
705
|
+
export type LayoutGridProps = {
|
|
706
|
+
count?: number
|
|
707
|
+
gutter?: string
|
|
708
|
+
maxWidth?: string
|
|
709
|
+
margin?: string
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export declare const LayoutGrid: React.FC<LayoutGridProps>
|
|
713
|
+
`,
|
|
714
|
+
js: outdent13`
|
|
715
|
+
export function LayoutGrid(props) {
|
|
716
|
+
const { count = 12, margin, gutter = '24px', maxWidth } = props
|
|
717
|
+
const hasMaxWidth = maxWidth != null;
|
|
718
|
+
return (
|
|
719
|
+
<div
|
|
720
|
+
style={{
|
|
721
|
+
display: 'grid',
|
|
722
|
+
gap: gutter,
|
|
723
|
+
'grid-template-columns': \`repeat(\${count}, 1fr)\`,
|
|
724
|
+
height: '100%',
|
|
725
|
+
width: '100%',
|
|
726
|
+
position: 'absolute',
|
|
727
|
+
inset: '0',
|
|
728
|
+
'pointer-events': 'none',
|
|
729
|
+
'max-width': hasMaxWidth ? maxWidth : 'initial',
|
|
730
|
+
'margin-inline': hasMaxWidth ? 'auto' : undefined,
|
|
731
|
+
'padding-inline': !hasMaxWidth ? margin : undefined,
|
|
732
|
+
}}
|
|
733
|
+
>
|
|
734
|
+
{Array.from({ length: count }).map((_, i) => (
|
|
735
|
+
<span
|
|
736
|
+
key={i}
|
|
737
|
+
style={{
|
|
738
|
+
display: 'flex',
|
|
739
|
+
background: 'rgba(255, 0, 0, 0.1)',
|
|
740
|
+
height: '100%',
|
|
741
|
+
}}
|
|
742
|
+
/>
|
|
743
|
+
))}
|
|
744
|
+
</div>
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
`
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
573
751
|
// src/generators/jsx/solid-pattern.ts
|
|
574
752
|
import { capitalize as capitalize6, dashCase as dashCase3 } from "@pandacss/shared";
|
|
575
|
-
import { outdent as
|
|
753
|
+
import { outdent as outdent14 } from "outdent";
|
|
754
|
+
import { match as match3 } from "ts-pattern";
|
|
576
755
|
function generate3(name, pattern, jsxFactory) {
|
|
577
756
|
const upperName = capitalize6(name);
|
|
578
757
|
const jsxName = pattern.jsx ?? upperName;
|
|
579
758
|
const keys = Object.keys(pattern.properties ?? {});
|
|
580
759
|
return {
|
|
581
760
|
name: dashCase3(name),
|
|
582
|
-
js:
|
|
761
|
+
js: outdent14`
|
|
583
762
|
import { splitProps } from 'solid-js'
|
|
584
763
|
import { ${jsxFactory} } from './factory'
|
|
585
764
|
import { config } from '../patterns/${dashCase3(name)}'
|
|
586
765
|
|
|
587
766
|
export function ${jsxName}(props) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
767
|
+
${match3(keys.length).with(
|
|
768
|
+
0,
|
|
769
|
+
() => `
|
|
770
|
+
return <${jsxFactory}.div {...props} />
|
|
771
|
+
`
|
|
772
|
+
).otherwise(
|
|
773
|
+
() => `
|
|
774
|
+
const [patternProps, restProps] = splitProps(props, [${keys.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
775
|
+
const styleProps = config.transform(patternProps)
|
|
776
|
+
return <${jsxFactory}.div {...styleProps} {...restProps} />
|
|
777
|
+
`
|
|
778
|
+
)}
|
|
591
779
|
}
|
|
592
780
|
`,
|
|
593
|
-
dts:
|
|
781
|
+
dts: outdent14`
|
|
594
782
|
import { ComponentProps, JSX } from 'solid-js'
|
|
595
783
|
import { ${upperName}Options } from '../patterns/${dashCase3(name)}'
|
|
596
784
|
import { Assign, JSXStyleProperties } from '../types'
|
|
@@ -601,7 +789,7 @@ function generate3(name, pattern, jsxFactory) {
|
|
|
601
789
|
type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties &
|
|
602
790
|
Assign<Omit<PropsOf<C>, 'color'>, P & { as?: C }>
|
|
603
791
|
|
|
604
|
-
export type ${jsxName}Props<C extends ElementType> = Polymorphic<C, ${upperName}Options>
|
|
792
|
+
export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Options>
|
|
605
793
|
|
|
606
794
|
export declare function ${jsxName}<V extends ElementType>(props: ${jsxName}Props<V>): JSX.Element
|
|
607
795
|
`
|
|
@@ -630,17 +818,25 @@ var patternMap = {
|
|
|
630
818
|
function generateJsxPatterns(ctx) {
|
|
631
819
|
return patternMap[ctx.jsxFramework](ctx);
|
|
632
820
|
}
|
|
821
|
+
var layoutGridMap = {
|
|
822
|
+
react: generateReactLayoutGrid,
|
|
823
|
+
preact: generatePreactLayoutGrid,
|
|
824
|
+
solid: generateSolidLayoutGrid
|
|
825
|
+
};
|
|
826
|
+
function generateLayoutGrid(ctx) {
|
|
827
|
+
return layoutGridMap[ctx.jsxFramework]();
|
|
828
|
+
}
|
|
633
829
|
|
|
634
830
|
// src/generators/pattern.ts
|
|
635
831
|
import { capitalize as capitalize7, dashCase as dashCase4, unionType as unionType2 } from "@pandacss/shared";
|
|
636
|
-
import { outdent as
|
|
832
|
+
import { outdent as outdent15 } from "outdent";
|
|
637
833
|
import { stringify as stringify2 } from "telejson";
|
|
638
|
-
import { match } from "ts-pattern";
|
|
834
|
+
import { match as match4 } from "ts-pattern";
|
|
639
835
|
function generate4(name, pattern) {
|
|
640
836
|
const { properties, transform, strict } = pattern;
|
|
641
837
|
return {
|
|
642
838
|
name: dashCase4(name),
|
|
643
|
-
dts:
|
|
839
|
+
dts: outdent15`
|
|
644
840
|
import { SystemStyleObject, ConditionalValue } from "../types"
|
|
645
841
|
import { Properties } from "../types/csstype"
|
|
646
842
|
import { Tokens } from "../types/token"
|
|
@@ -648,7 +844,7 @@ function generate4(name, pattern) {
|
|
|
648
844
|
export type ${capitalize7(name)}Options = {
|
|
649
845
|
${Object.keys(properties ?? {}).map((key) => {
|
|
650
846
|
const value = properties[key];
|
|
651
|
-
return
|
|
847
|
+
return match4(value).with({ type: "property" }, (value2) => {
|
|
652
848
|
return `${key}?: SystemStyleObject["${value2.value}"]`;
|
|
653
849
|
}).with({ type: "token" }, (value2) => {
|
|
654
850
|
if (value2.property) {
|
|
@@ -663,13 +859,13 @@ function generate4(name, pattern) {
|
|
|
663
859
|
}).join("\n ")}
|
|
664
860
|
}
|
|
665
861
|
|
|
666
|
-
${strict ?
|
|
862
|
+
${strict ? outdent15`export declare function ${name}(options: ${capitalize7(name)}Options): string` : outdent15`
|
|
667
863
|
type Merge<T> = Omit<SystemStyleObject, keyof T> & T
|
|
668
864
|
export declare function ${name}(options: Merge<${capitalize7(name)}Options>): string
|
|
669
865
|
`}
|
|
670
866
|
|
|
671
867
|
`,
|
|
672
|
-
js:
|
|
868
|
+
js: outdent15`
|
|
673
869
|
import { mapObject } from "../helpers"
|
|
674
870
|
import { css } from "../css"
|
|
675
871
|
|
|
@@ -686,10 +882,10 @@ function generatePattern(ctx) {
|
|
|
686
882
|
}
|
|
687
883
|
|
|
688
884
|
// src/generators/prop-types.ts
|
|
689
|
-
import { outdent as
|
|
885
|
+
import { outdent as outdent16 } from "outdent";
|
|
690
886
|
function generatePropTypes(utility) {
|
|
691
887
|
const result = [
|
|
692
|
-
|
|
888
|
+
outdent16`
|
|
693
889
|
import { Properties as CSSProperties } from "./csstype"
|
|
694
890
|
|
|
695
891
|
type BasePropTypes = {`
|
|
@@ -717,14 +913,14 @@ function generatePropTypes(utility) {
|
|
|
717
913
|
|
|
718
914
|
// src/generators/recipe.ts
|
|
719
915
|
import { capitalize as capitalize8, unionType as unionType3 } from "@pandacss/shared";
|
|
720
|
-
import { outdent as
|
|
916
|
+
import { outdent as outdent17 } from "outdent";
|
|
721
917
|
function generateRecipes(ctx) {
|
|
722
918
|
const { recipes = {}, hash, hasRecipes, utility } = ctx;
|
|
723
919
|
const { separator } = utility;
|
|
724
920
|
if (!hasRecipes)
|
|
725
921
|
return;
|
|
726
922
|
const js = [
|
|
727
|
-
|
|
923
|
+
outdent17`
|
|
728
924
|
import { createCss, withoutSpace } from "../helpers"
|
|
729
925
|
|
|
730
926
|
const createRecipe = (name) => {
|
|
@@ -748,10 +944,10 @@ function generateRecipes(ctx) {
|
|
|
748
944
|
];
|
|
749
945
|
const dts = [""];
|
|
750
946
|
Object.values(recipes).forEach((recipe) => {
|
|
751
|
-
js.push(
|
|
947
|
+
js.push(outdent17`
|
|
752
948
|
export const ${recipe.name} = createRecipe('${recipe.name}')
|
|
753
949
|
`);
|
|
754
|
-
dts.push(
|
|
950
|
+
dts.push(outdent17`
|
|
755
951
|
import { ConditionalValue } from "../types"
|
|
756
952
|
|
|
757
953
|
export type ${capitalize8(recipe.name)}Value = {
|
|
@@ -766,8 +962,8 @@ function generateRecipes(ctx) {
|
|
|
766
962
|
`);
|
|
767
963
|
});
|
|
768
964
|
return {
|
|
769
|
-
js:
|
|
770
|
-
dts:
|
|
965
|
+
js: outdent17.string(js.join("\n\n")),
|
|
966
|
+
dts: outdent17.string(dts.join("\n\n"))
|
|
771
967
|
};
|
|
772
968
|
}
|
|
773
969
|
|
|
@@ -874,14 +1070,14 @@ function generateReset() {
|
|
|
874
1070
|
|
|
875
1071
|
// src/generators/token-css.ts
|
|
876
1072
|
import { toCss, toKeyframeCss } from "@pandacss/core";
|
|
877
|
-
import { outdent as
|
|
878
|
-
import { match as
|
|
1073
|
+
import { outdent as outdent18 } from "outdent";
|
|
1074
|
+
import { match as match5, P } from "ts-pattern";
|
|
879
1075
|
function generateKeyframes(keyframes) {
|
|
880
1076
|
if (keyframes) {
|
|
881
1077
|
return toKeyframeCss(keyframes);
|
|
882
1078
|
}
|
|
883
1079
|
}
|
|
884
|
-
var getConditionMessage = (value) =>
|
|
1080
|
+
var getConditionMessage = (value) => outdent18`
|
|
885
1081
|
It seems you provided an invalid condition for semantic tokens.
|
|
886
1082
|
|
|
887
1083
|
- You provided: \`${value}\`
|
|
@@ -902,7 +1098,7 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
902
1098
|
results.push(css3);
|
|
903
1099
|
} else {
|
|
904
1100
|
const cond = conditions.normalize(key);
|
|
905
|
-
const css3 =
|
|
1101
|
+
const css3 = match5(cond).with({ type: "parent-nesting" }, (cond2) => {
|
|
906
1102
|
const selector = cond2.value.replace(/\s&/g, "");
|
|
907
1103
|
const { css: css4 } = toCss(varsObj);
|
|
908
1104
|
return `${selector} {
|
|
@@ -936,7 +1132,7 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
936
1132
|
|
|
937
1133
|
// src/generators/token-dts.ts
|
|
938
1134
|
import { unionType as unionType4, capitalize as capitalize9 } from "@pandacss/shared";
|
|
939
|
-
import { outdent as
|
|
1135
|
+
import { outdent as outdent19 } from "outdent";
|
|
940
1136
|
import { singular } from "pluralize";
|
|
941
1137
|
function generateTokenDts(dict) {
|
|
942
1138
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -954,11 +1150,11 @@ function generateTokenDts(dict) {
|
|
|
954
1150
|
}
|
|
955
1151
|
interfaceSet.add("}");
|
|
956
1152
|
set.add(Array.from(interfaceSet).join("\n"));
|
|
957
|
-
return
|
|
1153
|
+
return outdent19.string(Array.from(set).join("\n\n"));
|
|
958
1154
|
}
|
|
959
1155
|
|
|
960
1156
|
// src/generators/token-js.ts
|
|
961
|
-
import
|
|
1157
|
+
import outdent20 from "outdent";
|
|
962
1158
|
function generateTokenJs(dict) {
|
|
963
1159
|
const map = /* @__PURE__ */ new Map();
|
|
964
1160
|
dict.allTokens.forEach((token) => {
|
|
@@ -968,7 +1164,7 @@ function generateTokenJs(dict) {
|
|
|
968
1164
|
});
|
|
969
1165
|
const obj = Object.fromEntries(map);
|
|
970
1166
|
return {
|
|
971
|
-
js:
|
|
1167
|
+
js: outdent20`
|
|
972
1168
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
973
1169
|
|
|
974
1170
|
function getToken(path) {
|
|
@@ -981,7 +1177,7 @@ function generateTokenJs(dict) {
|
|
|
981
1177
|
return variable
|
|
982
1178
|
}
|
|
983
1179
|
`,
|
|
984
|
-
dts:
|
|
1180
|
+
dts: outdent20`
|
|
985
1181
|
import { Token } from "../types/token"
|
|
986
1182
|
export declare function getToken(path: Token): string
|
|
987
1183
|
export declare function getTokenVar(path: Token): string
|
|
@@ -991,7 +1187,7 @@ function generateTokenJs(dict) {
|
|
|
991
1187
|
|
|
992
1188
|
// src/generators/types.ts
|
|
993
1189
|
import { readFileSync as readFileSync2 } from "fs-extra";
|
|
994
|
-
import
|
|
1190
|
+
import outdent21 from "outdent";
|
|
995
1191
|
function getType(file) {
|
|
996
1192
|
const filepath = getEntrypoint("@pandacss/types", { dev: file });
|
|
997
1193
|
return readFileSync2(filepath, "utf8");
|
|
@@ -1001,7 +1197,7 @@ function generateCssType(ctx) {
|
|
|
1001
1197
|
return {
|
|
1002
1198
|
cssType: getType("csstype.d.ts"),
|
|
1003
1199
|
pandaCssType: getType("system-types.d.ts"),
|
|
1004
|
-
publicType:
|
|
1200
|
+
publicType: outdent21`
|
|
1005
1201
|
import * as System from './system-types'
|
|
1006
1202
|
import { PropTypes } from './prop-type'
|
|
1007
1203
|
import { Conditions } from './conditions'
|
|
@@ -1122,7 +1318,7 @@ function setupPatterns(ctx) {
|
|
|
1122
1318
|
if (!files) {
|
|
1123
1319
|
return { files: [] };
|
|
1124
1320
|
}
|
|
1125
|
-
const indexCode =
|
|
1321
|
+
const indexCode = outdent22.string(files.map((file) => `export * from './${file.name}'`).join("\n"));
|
|
1126
1322
|
return {
|
|
1127
1323
|
dir: ctx.paths.pattern,
|
|
1128
1324
|
files: [
|
|
@@ -1139,15 +1335,19 @@ function setupJsx(ctx) {
|
|
|
1139
1335
|
const isValidProp = generateisValidProp(ctx);
|
|
1140
1336
|
const factory = generateJsxFactory(ctx);
|
|
1141
1337
|
const patterns = generateJsxPatterns(ctx);
|
|
1142
|
-
const
|
|
1338
|
+
const layoutGrid = generateLayoutGrid(ctx);
|
|
1339
|
+
const indexCode = outdent22`
|
|
1143
1340
|
export * from './factory'
|
|
1144
|
-
|
|
1341
|
+
export * from './layout-grid'
|
|
1342
|
+
${outdent22.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1145
1343
|
`;
|
|
1146
1344
|
return {
|
|
1147
1345
|
dir: ctx.paths.jsx,
|
|
1148
1346
|
files: [
|
|
1149
1347
|
...patterns.map((file) => ({ file: `${file.name}.jsx`, code: file.js })),
|
|
1150
1348
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1349
|
+
{ file: "layout-grid.jsx", code: layoutGrid.js },
|
|
1350
|
+
{ file: "layout-grid.d.ts", code: layoutGrid.dts },
|
|
1151
1351
|
{ file: "is-valid-prop.js", code: isValidProp.js },
|
|
1152
1352
|
{ file: "factory.d.ts", code: factory.dts },
|
|
1153
1353
|
{ file: "factory.jsx", code: factory.js },
|
|
@@ -1157,7 +1357,7 @@ function setupJsx(ctx) {
|
|
|
1157
1357
|
};
|
|
1158
1358
|
}
|
|
1159
1359
|
function setupCssIndex(ctx) {
|
|
1160
|
-
const code =
|
|
1360
|
+
const code = outdent22`
|
|
1161
1361
|
export * from './css'
|
|
1162
1362
|
export * from './cx'
|
|
1163
1363
|
export * from './global-css'
|
|
@@ -1178,7 +1378,7 @@ function setupReset(ctx) {
|
|
|
1178
1378
|
return { files: [{ file: "reset.css", code }] };
|
|
1179
1379
|
}
|
|
1180
1380
|
function setupGitIgnore(ctx) {
|
|
1181
|
-
const txt =
|
|
1381
|
+
const txt = outdent22`## CSS Panda
|
|
1182
1382
|
${ctx.outdir}
|
|
1183
1383
|
`;
|
|
1184
1384
|
const file = lookItUpSync(".gitignore");
|
|
@@ -1217,30 +1417,30 @@ function generateSystem(ctx) {
|
|
|
1217
1417
|
|
|
1218
1418
|
// src/messages.ts
|
|
1219
1419
|
import { colors, logger as logger3, quote as quote2 } from "@pandacss/logger";
|
|
1220
|
-
import { outdent as
|
|
1420
|
+
import { outdent as outdent23 } from "outdent";
|
|
1221
1421
|
var tick = colors.green().bold("\u2714\uFE0F");
|
|
1222
1422
|
function artifactsGeneratedMessage(ctx) {
|
|
1223
1423
|
return [
|
|
1224
|
-
|
|
1424
|
+
outdent23`
|
|
1225
1425
|
${tick} ${quote2(ctx.outdir, "/css")}: the css function to author styles
|
|
1226
1426
|
`,
|
|
1227
|
-
ctx.hasTokens &&
|
|
1427
|
+
ctx.hasTokens && outdent23`
|
|
1228
1428
|
${tick} ${quote2(ctx.outdir, "/tokens")}: the css variables and js function to query your tokens
|
|
1229
1429
|
`,
|
|
1230
|
-
ctx.hasPattern &&
|
|
1430
|
+
ctx.hasPattern && outdent23`
|
|
1231
1431
|
${tick} ${quote2(ctx.outdir, "/patterns")}: functions to implement common css patterns
|
|
1232
1432
|
`,
|
|
1233
|
-
ctx.hasRecipes &&
|
|
1433
|
+
ctx.hasRecipes && outdent23`
|
|
1234
1434
|
${tick} ${quote2(ctx.outdir, "/recipes")}: functions to create multi-variant styles
|
|
1235
1435
|
`,
|
|
1236
|
-
ctx.jsxFramework &&
|
|
1436
|
+
ctx.jsxFramework && outdent23`
|
|
1237
1437
|
${tick} ${quote2(ctx.outdir, "/jsx")}: style prop powered elements for ${ctx.jsxFramework}
|
|
1238
1438
|
`,
|
|
1239
1439
|
"\n"
|
|
1240
1440
|
].filter(Boolean).join("\n");
|
|
1241
1441
|
}
|
|
1242
1442
|
function configExistsMessage(cmd) {
|
|
1243
|
-
return
|
|
1443
|
+
return outdent23`
|
|
1244
1444
|
\n
|
|
1245
1445
|
It looks like you already have panda created\`.
|
|
1246
1446
|
|
|
@@ -1249,7 +1449,7 @@ function configExistsMessage(cmd) {
|
|
|
1249
1449
|
`;
|
|
1250
1450
|
}
|
|
1251
1451
|
function thankYouMessage() {
|
|
1252
|
-
return
|
|
1452
|
+
return outdent23`
|
|
1253
1453
|
|
|
1254
1454
|
🚀 Thanks for choosing ${colors.cyan("Panda")} to write your css.
|
|
1255
1455
|
|
|
@@ -1261,7 +1461,7 @@ var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
|
1261
1461
|
var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
1262
1462
|
function scaffoldCompleteMessage() {
|
|
1263
1463
|
return logger3.box(
|
|
1264
|
-
|
|
1464
|
+
outdent23`
|
|
1265
1465
|
|
|
1266
1466
|
${colors.bold().cyan("Next steps:")}
|
|
1267
1467
|
|
|
@@ -1893,7 +2093,7 @@ async function generate5(config, configPath) {
|
|
|
1893
2093
|
import { logger as logger8, quote as quote3 } from "@pandacss/logger";
|
|
1894
2094
|
import { writeFile as writeFile2 } from "fs-extra";
|
|
1895
2095
|
import { lookItUpSync as lookItUpSync3 } from "look-it-up";
|
|
1896
|
-
import { outdent as
|
|
2096
|
+
import { outdent as outdent24 } from "outdent";
|
|
1897
2097
|
import { join as join4 } from "path";
|
|
1898
2098
|
import getPackageManager2 from "preferred-pm";
|
|
1899
2099
|
async function setupConfig(cwd, { force }) {
|
|
@@ -1907,7 +2107,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
1907
2107
|
if (!force && configFile) {
|
|
1908
2108
|
logger8.warn("config exists", configExistsMessage(cmd));
|
|
1909
2109
|
} else {
|
|
1910
|
-
const content =
|
|
2110
|
+
const content = outdent24`
|
|
1911
2111
|
import { defineConfig } from "css-panda"
|
|
1912
2112
|
|
|
1913
2113
|
export default defineConfig({
|
|
@@ -1933,7 +2133,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
1933
2133
|
}
|
|
1934
2134
|
async function setupPostcss(cwd) {
|
|
1935
2135
|
logger8.info({ type: "init", msg: `creating postcss config file: ${quote3("postcss.config.cjs")}` });
|
|
1936
|
-
const content =
|
|
2136
|
+
const content = outdent24`
|
|
1937
2137
|
module.exports = {
|
|
1938
2138
|
plugins: {
|
|
1939
2139
|
'css-panda/postcss': {},
|