@pandacss/node 0.0.0-dev-20221222102219 → 0.0.0-dev-20221229135204

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.mjs CHANGED
@@ -81,7 +81,7 @@ async function writeFileChunk(ctx, file) {
81
81
 
82
82
  // src/generators/index.ts
83
83
  import { readFileSync as readFileSync3 } from "fs";
84
- import outdent22 from "outdent";
84
+ import outdent25 from "outdent";
85
85
 
86
86
  // src/generators/conditions.ts
87
87
  import { unionType } from "@pandacss/shared";
@@ -289,21 +289,6 @@ function generatePreactJsxFactory(ctx) {
289
289
  const name = ctx.jsxFactory;
290
290
  const upperName = capitalize(name);
291
291
  return {
292
- dts: outdent6`
293
- import type { ComponentProps, JSX } from 'preact'
294
- import type { JSXStyleProperties } from '../types'
295
-
296
- type Element = keyof JSX.IntrinsicElements
297
-
298
- export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties
299
-
300
-
301
- type JSXFactory = {
302
- [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
303
- }
304
-
305
- export declare const ${name}: JSXFactory
306
- `,
307
292
  js: outdent6`
308
293
  import { h } from 'preact'
309
294
  import { forwardRef } from 'preact/compat'
@@ -451,19 +436,11 @@ function generate(name, pattern, jsxFactory) {
451
436
  })
452
437
  `,
453
438
  dts: outdent8`
454
- import { ComponentProps, JSX, ComponentChildren } from 'preact';
455
439
  import { ${upperName}Properties } from '../patterns/${dashCase(name)}'
456
- import { JSXStyleProperties, Assign } from '../types'
457
-
458
- type ElementType = keyof JSX.IntrinsicElements
459
-
460
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
461
- Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
440
+ import { PolymorphicComponent } from '../types/jsx'
462
441
 
463
- type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
464
-
465
442
  ${pattern.description ? `/** ${pattern.description} */` : ""}
466
- export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
443
+ export declare const ${jsxName}: PolymorphicComponent<"div", ${upperName}Properties>
467
444
  `
468
445
  };
469
446
  }
@@ -471,28 +448,59 @@ function generatePreactJsxPattern(ctx) {
471
448
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate(name, pattern, ctx.jsxFactory));
472
449
  }
473
450
 
474
- // src/generators/jsx/react-jsx.ts
451
+ // src/generators/jsx/preact-types.ts
475
452
  import { capitalize as capitalize3 } from "@pandacss/shared";
476
453
  import { outdent as outdent9 } from "outdent";
477
- function generateReactJsxFactory(ctx) {
454
+ function generatePreactJsxTypes(ctx) {
478
455
  const name = ctx.jsxFactory;
479
456
  const upperName = capitalize3(name);
480
457
  return {
481
- dts: outdent9`
482
- import type { ComponentProps } from "react"
483
- import type { JSXStyleProperties } from "../types"
484
-
485
- type Element = keyof JSX.IntrinsicElements
458
+ jsxFactory: outdent9`
459
+ import { PolymorphicComponents } from '../types/jsx'
460
+ export declare const ${name}: PolymorphicComponents
461
+ `,
462
+ jsxType: outdent9`
463
+ import type { JSX, ComponentProps, ElementType } from 'preact'
464
+ import type { JsxStyleProps, Assign } from '.'
486
465
 
487
- export type HTML${upperName}Props<T extends Element> = Omit<ComponentProps<T>, 'color'> | JSXStyleProperties;
466
+ type Element = keyof JSX.IntrinsicElements
467
+ type As<P = any> = JSX.ElementType<P>
468
+ type Dict<T = unknown> = Record<string, T>
488
469
 
489
- type JSXFactory = {
490
- [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
491
- }
470
+ type Clean<T> = Omit<T, 'transition' | 'as' | 'color'>
492
471
 
493
- export declare const ${name}: JSXFactory
494
- `,
495
- js: outdent9`
472
+ type PolymorphicProps<
473
+ ComponentProps extends Dict,
474
+ AsProps extends Dict,
475
+ AdditionalProps extends Dict = {},
476
+ AsComponent extends As = As,
477
+ > = Assign<Clean<ComponentProps>, AdditionalProps> &
478
+ Assign<Clean<AsProps>, AdditionalProps> & {
479
+ as?: AsComponent
480
+ }
481
+
482
+ export type PolymorphicComponent<C extends As, P extends Dict = {}> = {
483
+ <E extends As = C>(props: PolymorphicProps<ComponentProps<C>, ComponentProps<E>, P, E> & JsxStyleProps<P>): JSX.Element
484
+ displayName?: string
485
+ }
486
+
487
+ export type PolymorphicComponents = {
488
+ [K in Element]: PolymorphicComponent<K, {}>
489
+ }
490
+
491
+ export type HTML${upperName}Props<T extends As> = Clean<ComponentProps<T>> & JsxStyleProps
492
+ `
493
+ };
494
+ }
495
+
496
+ // src/generators/jsx/react-jsx.ts
497
+ import { capitalize as capitalize4 } from "@pandacss/shared";
498
+ import { outdent as outdent10 } from "outdent";
499
+ function generateReactJsxFactory(ctx) {
500
+ const name = ctx.jsxFactory;
501
+ const upperName = capitalize4(name);
502
+ return {
503
+ js: outdent10`
496
504
  import { forwardRef } from 'react'
497
505
  import { isCssProperty } from './is-valid-prop'
498
506
  import { css } from '../css'
@@ -554,10 +562,10 @@ function generateReactJsxFactory(ctx) {
554
562
  }
555
563
 
556
564
  // src/generators/jsx/react-layout-grid.ts
557
- import { outdent as outdent10 } from "outdent";
565
+ import { outdent as outdent11 } from "outdent";
558
566
  function generateReactLayoutGrid() {
559
567
  return {
560
- dts: outdent10`
568
+ dts: outdent11`
561
569
  import type { FunctionComponent } from 'react'
562
570
 
563
571
  export type LayoutGridProps = {
@@ -569,7 +577,7 @@ function generateReactLayoutGrid() {
569
577
 
570
578
  export declare const LayoutGrid: FunctionComponent<LayoutGridProps>
571
579
  `,
572
- js: outdent10`
580
+ js: outdent11`
573
581
  export function LayoutGrid(props) {
574
582
  const { count = 12, margin, gutter = '24px', maxWidth } = props
575
583
  const hasMaxWidth = maxWidth != null;
@@ -607,17 +615,17 @@ function generateReactLayoutGrid() {
607
615
  }
608
616
 
609
617
  // src/generators/jsx/react-pattern.ts
610
- import { capitalize as capitalize4, dashCase as dashCase2 } from "@pandacss/shared";
611
- import { outdent as outdent11 } from "outdent";
618
+ import { capitalize as capitalize5, dashCase as dashCase2 } from "@pandacss/shared";
619
+ import { outdent as outdent12 } from "outdent";
612
620
  import { match as match2 } from "ts-pattern";
613
621
  function generate2(name, pattern, jsxFactory) {
614
- const upperName = capitalize4(name);
622
+ const upperName = capitalize5(name);
615
623
  const upperFn = `get${upperName}Style`;
616
624
  const jsxName = pattern.jsx ?? upperName;
617
625
  const keys = Object.keys(pattern.properties ?? {});
618
626
  return {
619
627
  name: dashCase2(name),
620
- js: outdent11`
628
+ js: outdent12`
621
629
  import { forwardRef } from 'react'
622
630
  import { ${jsxFactory} } from './factory'
623
631
  import { ${upperFn} } from '../patterns/${dashCase2(name)}'
@@ -625,11 +633,11 @@ function generate2(name, pattern, jsxFactory) {
625
633
  export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
626
634
  ${match2(keys.length).with(
627
635
  0,
628
- () => outdent11`
636
+ () => outdent12`
629
637
  return <${jsxFactory}.div ref={ref} {...props} />
630
638
  `
631
639
  ).otherwise(
632
- () => outdent11`
640
+ () => outdent12`
633
641
  const { ${keys.join(", ")}, ...restProps } = props
634
642
  const styleProps = ${upperFn}({${keys.join(", ")}})
635
643
  return <${jsxFactory}.div ref={ref} {...styleProps} {...restProps} />
@@ -638,19 +646,12 @@ function generate2(name, pattern, jsxFactory) {
638
646
 
639
647
  })
640
648
  `,
641
- dts: outdent11`
642
- import { ComponentProps, ElementType } from 'react'
649
+ dts: outdent12`
643
650
  import { ${upperName}Properties } from '../patterns/${dashCase2(name)}'
644
- import { JSXStyleProperties, Assign } from '../types'
645
-
646
- type Polymorphic<C extends ElementType = "div", P = {}> =
647
- | JSXStyleProperties
648
- | Assign<Omit<ComponentProps<C>, "color">, P & { as?: C }>
651
+ import { PolymorphicComponent } from '../types/jsx'
649
652
 
650
- export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
651
-
652
653
  ${pattern.description ? `/** ${pattern.description} */` : ""}
653
- export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
654
+ export declare const ${jsxName}: PolymorphicComponent<"div", ${upperName}Properties>
654
655
  `
655
656
  };
656
657
  }
@@ -658,28 +659,59 @@ function generateReactJsxPattern(ctx) {
658
659
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate2(name, pattern, ctx.jsxFactory));
659
660
  }
660
661
 
661
- // src/generators/jsx/solid-jsx.ts
662
- import { capitalize as capitalize5 } from "@pandacss/shared";
663
- import { outdent as outdent12 } from "outdent";
664
- function generateSolidJsxFactory(ctx) {
662
+ // src/generators/jsx/react-types.ts
663
+ import { capitalize as capitalize6 } from "@pandacss/shared";
664
+ import { outdent as outdent13 } from "outdent";
665
+ function generateReactJsxTypes(ctx) {
665
666
  const name = ctx.jsxFactory;
666
- const upperName = capitalize5(name);
667
+ const upperName = capitalize6(name);
667
668
  return {
668
- dts: outdent12`
669
- import type { JSX } from 'solid-js'
670
- import type { JSXStyleProperties, Assign} from '../types'
671
-
672
- type Element = keyof JSX.IntrinsicElements
673
-
674
- export type HTML${upperName}Props<T extends Element> = Omit<JSX.IntrinsicElements[T], 'color'> | JSXStyleProperties
669
+ jsxFactory: outdent13`
670
+ import { PolymorphicComponents } from '../types/jsx'
671
+ export declare const ${name}: PolymorphicComponents
672
+ `,
673
+ jsxType: outdent13`
674
+ import type { ElementType, ComponentProps } from 'react'
675
+ import type { JsxStyleProps, Assign } from '.'
675
676
 
676
- type JSXFactory = {
677
- [K in Element]: (props: HTML${upperName}Props<K>) => JSX.Element
678
- }
677
+ type Element = keyof JSX.IntrinsicElements
678
+ type As<P = any> = ElementType<P>
679
+ type Dict<T = unknown> = Record<string, T>
679
680
 
680
- export declare const ${name}: JSXFactory
681
- `,
682
- js: outdent12`
681
+ type Clean<T> = Omit<T, 'transition' | 'as' | 'color'>
682
+
683
+ type PolymorphicProps<
684
+ ComponentProps extends Dict,
685
+ AsProps extends Dict,
686
+ AdditionalProps extends Dict = {},
687
+ AsComponent extends As = As,
688
+ > = Assign<Clean<ComponentProps>, AdditionalProps> &
689
+ Assign<Clean<AsProps>, AdditionalProps> & {
690
+ as?: AsComponent
691
+ }
692
+
693
+ export type PolymorphicComponent<C extends As, P extends Dict = {}> = {
694
+ <E extends As = C>(props: PolymorphicProps<ComponentProps<C>, ComponentProps<E>, P, E> & JsxStyleProps<P>): JSX.Element
695
+ displayName?: string
696
+ }
697
+
698
+ export type PolymorphicComponents = {
699
+ [K in Element]: PolymorphicComponent<K, {}>
700
+ }
701
+
702
+ export type HTML${upperName}Props<T extends As> = Clean<ComponentProps<T>> & JsxStyleProps
703
+ `
704
+ };
705
+ }
706
+
707
+ // src/generators/jsx/solid-jsx.ts
708
+ import { capitalize as capitalize7 } from "@pandacss/shared";
709
+ import { outdent as outdent14 } from "outdent";
710
+ function generateSolidJsxFactory(ctx) {
711
+ const name = ctx.jsxFactory;
712
+ const upperName = capitalize7(name);
713
+ return {
714
+ js: outdent14`
683
715
  import { Dynamic } from 'solid-js/web'
684
716
  import { mergeProps, splitProps } from 'solid-js'
685
717
  import { allCssProperties } from './is-valid-prop'
@@ -728,10 +760,10 @@ function generateSolidJsxFactory(ctx) {
728
760
  }
729
761
 
730
762
  // src/generators/jsx/solid-layout-grid.ts
731
- import { outdent as outdent13 } from "outdent";
763
+ import { outdent as outdent15 } from "outdent";
732
764
  function generateSolidLayoutGrid() {
733
765
  return {
734
- dts: outdent13`
766
+ dts: outdent15`
735
767
  export type LayoutGridProps = {
736
768
  count?: number
737
769
  gutter?: string
@@ -741,7 +773,7 @@ function generateSolidLayoutGrid() {
741
773
 
742
774
  export declare const LayoutGrid: React.FC<LayoutGridProps>
743
775
  `,
744
- js: outdent13`
776
+ js: outdent15`
745
777
  export function LayoutGrid(props) {
746
778
  const { count = 12, margin, gutter = '24px', maxWidth } = props
747
779
  const hasMaxWidth = maxWidth != null;
@@ -779,17 +811,17 @@ function generateSolidLayoutGrid() {
779
811
  }
780
812
 
781
813
  // src/generators/jsx/solid-pattern.ts
782
- import { capitalize as capitalize6, dashCase as dashCase3 } from "@pandacss/shared";
783
- import { outdent as outdent14 } from "outdent";
814
+ import { capitalize as capitalize8, dashCase as dashCase3 } from "@pandacss/shared";
815
+ import { outdent as outdent16 } from "outdent";
784
816
  import { match as match3 } from "ts-pattern";
785
817
  function generate3(name, pattern, jsxFactory) {
786
- const upperName = capitalize6(name);
818
+ const upperName = capitalize8(name);
787
819
  const upperFn = `get${upperName}Style`;
788
820
  const jsxName = pattern.jsx ?? upperName;
789
821
  const keys = Object.keys(pattern.properties ?? {});
790
822
  return {
791
823
  name: dashCase3(name),
792
- js: outdent14`
824
+ js: outdent16`
793
825
  import { splitProps } from 'solid-js'
794
826
  import { ${jsxFactory} } from './factory'
795
827
  import { ${upperFn} } from '../patterns/${dashCase3(name)}'
@@ -797,11 +829,11 @@ function generate3(name, pattern, jsxFactory) {
797
829
  export function ${jsxName}(props) {
798
830
  ${match3(keys.length).with(
799
831
  0,
800
- () => outdent14`
832
+ () => outdent16`
801
833
  return <${jsxFactory}.div {...props} />
802
834
  `
803
835
  ).otherwise(
804
- () => outdent14`
836
+ () => outdent16`
805
837
  const [patternProps, restProps] = splitProps(props, [${keys.map((v) => JSON.stringify(v)).join(", ")}]);
806
838
  const styleProps = ${upperFn}(patternProps)
807
839
  return <${jsxFactory}.div {...styleProps} {...restProps} />
@@ -809,20 +841,12 @@ function generate3(name, pattern, jsxFactory) {
809
841
  )}
810
842
  }
811
843
  `,
812
- dts: outdent14`
813
- import { ComponentProps, JSX } from 'solid-js'
844
+ dts: outdent16`
814
845
  import { ${upperName}Properties } from '../patterns/${dashCase3(name)}'
815
- import { Assign, JSXStyleProperties } from '../types'
816
-
817
- type ElementType = keyof JSX.IntrinsicElements
818
-
819
- type Polymorphic<C extends ElementType = 'div', P = {}> = JSXStyleProperties |
820
- Assign<Omit<ComponentProps<C>, 'color'>, P & { as?: C }>
846
+ import { PolymorphicComponent } from '../types/jsx'
821
847
 
822
- export type ${jsxName}Props<C extends ElementType = 'div'> = Polymorphic<C, ${upperName}Properties>
823
-
824
848
  ${pattern.description ? `/** ${pattern.description} */` : ""}
825
- export declare function ${jsxName}<V extends ElementType = 'div'>(props: ${jsxName}Props<V>): JSX.Element
849
+ export declare const ${jsxName}: PolymorphicComponent<"div", ${upperName}Properties>
826
850
  `
827
851
  };
828
852
  }
@@ -830,7 +854,62 @@ function generateSolidJsxPattern(ctx) {
830
854
  return Object.entries(ctx.patterns).map(([name, pattern]) => generate3(name, pattern, ctx.jsxFactory));
831
855
  }
832
856
 
857
+ // src/generators/jsx/solid-types.ts
858
+ import { capitalize as capitalize9 } from "@pandacss/shared";
859
+ import { outdent as outdent17 } from "outdent";
860
+ function generateSolidJsxTypes(ctx) {
861
+ const name = ctx.jsxFactory;
862
+ const upperName = capitalize9(name);
863
+ return {
864
+ jsxFactory: outdent17`
865
+ import { PolymorphicComponents } from '../types/jsx'
866
+ export declare const ${name}: PolymorphicComponents
867
+ `,
868
+ jsxType: outdent17`
869
+ import type { JSX, ComponentProps, Component } from 'solid-js'
870
+ import type { JsxStyleProps, Assign } from '.'
871
+
872
+ type Element = keyof JSX.IntrinsicElements
873
+ type As<P = any> = Element | Component<P>;
874
+ type Dict<T = unknown> = Record<string, T>
875
+
876
+ type Clean<T> = Omit<T, 'transition' | 'as' | 'color'>
877
+
878
+ type PolymorphicProps<
879
+ ComponentProps extends Dict,
880
+ AsProps extends Dict,
881
+ AdditionalProps extends Dict = {},
882
+ AsComponent extends As = As,
883
+ > = Assign<Clean<ComponentProps>, AdditionalProps> &
884
+ Assign<Clean<AsProps>, AdditionalProps> & {
885
+ as?: AsComponent
886
+ }
887
+
888
+ export type PolymorphicComponent<C extends As, P extends Dict = {}> = {
889
+ <E extends As = C>(props: PolymorphicProps<ComponentProps<C>, ComponentProps<E>, P, E> & JsxStyleProps<P>): JSX.Element
890
+ displayName?: string
891
+ }
892
+
893
+ export type PolymorphicComponents = {
894
+ [K in Element]: PolymorphicComponent<K, {}>
895
+ }
896
+
897
+ export type HTML${upperName}Props<T extends As> = Clean<ComponentProps<T>> & JsxStyleProps
898
+ `
899
+ };
900
+ }
901
+
833
902
  // src/generators/jsx/index.ts
903
+ var typesMap = {
904
+ react: generateReactJsxTypes,
905
+ preact: generatePreactJsxTypes,
906
+ solid: generateSolidJsxTypes
907
+ };
908
+ function generateJsxTypes(ctx) {
909
+ if (!ctx.jsxFramework)
910
+ return;
911
+ return typesMap[ctx.jsxFramework](ctx);
912
+ }
834
913
  var factoryMap = {
835
914
  react: generateReactJsxFactory,
836
915
  solid: generateSolidJsxFactory,
@@ -859,22 +938,22 @@ function generateLayoutGrid(ctx) {
859
938
  }
860
939
 
861
940
  // src/generators/pattern.ts
862
- import { capitalize as capitalize7, dashCase as dashCase4, unionType as unionType2 } from "@pandacss/shared";
863
- import { outdent as outdent15 } from "outdent";
941
+ import { capitalize as capitalize10, dashCase as dashCase4, unionType as unionType2 } from "@pandacss/shared";
942
+ import { outdent as outdent18 } from "outdent";
864
943
  import { stringify as stringify2 } from "telejson";
865
944
  import { match as match4 } from "ts-pattern";
866
945
  function generate4(name, pattern) {
867
946
  const { properties, transform, strict, description } = pattern;
868
- const upperName = capitalize7(name);
947
+ const upperName = capitalize10(name);
869
948
  const upperFn = `get${upperName}Style`;
870
949
  return {
871
950
  name: dashCase4(name),
872
- dts: outdent15`
951
+ dts: outdent18`
873
952
  import { SystemStyleObject, ConditionalValue } from "../types"
874
953
  import { Properties } from "../types/csstype"
875
954
  import { Tokens } from "../types/token"
876
955
 
877
- export type ${capitalize7(name)}Properties = {
956
+ export type ${capitalize10(name)}Properties = {
878
957
  ${Object.keys(properties ?? {}).map((key) => {
879
958
  const value = properties[key];
880
959
  return match4(value).with({ type: "property" }, (value2) => {
@@ -892,15 +971,14 @@ function generate4(name, pattern) {
892
971
  }).join("\n ")}
893
972
  }
894
973
 
895
- ${strict ? outdent15`export declare function ${name}(options: ${upperName}Properties): string` : outdent15`
896
- type Merge<T extends Record<string, any>> = SystemStyleObject | T
897
-
974
+ ${strict ? outdent18`export declare function ${name}(options: ${upperName}Properties): string` : outdent18`
975
+
898
976
  ${description ? `/** ${description} */` : ""}
899
- export declare function ${name}(options: Merge<${upperName}Properties>): string
977
+ export declare function ${name}(options: SystemStyleObject<${upperName}Properties>): string
900
978
  `}
901
979
 
902
980
  `,
903
- js: outdent15`
981
+ js: outdent18`
904
982
  import { mapObject } from "../helpers"
905
983
  import { css } from "../css"
906
984
 
@@ -919,10 +997,10 @@ function generatePattern(ctx) {
919
997
  }
920
998
 
921
999
  // src/generators/prop-types.ts
922
- import { outdent as outdent16 } from "outdent";
1000
+ import { outdent as outdent19 } from "outdent";
923
1001
  function generatePropTypes(utility) {
924
1002
  const result = [
925
- outdent16`
1003
+ outdent19`
926
1004
  import { Properties as CSSProperties } from "./csstype"
927
1005
 
928
1006
  type BasePropTypes = {`
@@ -949,15 +1027,15 @@ function generatePropTypes(utility) {
949
1027
  }
950
1028
 
951
1029
  // src/generators/recipe.ts
952
- import { capitalize as capitalize8, unionType as unionType3 } from "@pandacss/shared";
953
- import { outdent as outdent17 } from "outdent";
1030
+ import { capitalize as capitalize11, unionType as unionType3 } from "@pandacss/shared";
1031
+ import { outdent as outdent20 } from "outdent";
954
1032
  function generateRecipes(ctx) {
955
1033
  const { recipes = {}, hash, hasRecipes, utility } = ctx;
956
1034
  const { separator } = utility;
957
1035
  if (!hasRecipes)
958
1036
  return;
959
1037
  const js = [
960
- outdent17`
1038
+ outdent20`
961
1039
  import { createCss, withoutSpace } from "../helpers"
962
1040
 
963
1041
  const createRecipe = (name, defaultVariants) => {
@@ -992,13 +1070,13 @@ function generateRecipes(ctx) {
992
1070
  const dts = [""];
993
1071
  Object.values(recipes).forEach((recipe) => {
994
1072
  const { name, description, defaultVariants, variants } = recipe;
995
- js.push(outdent17`
1073
+ js.push(outdent20`
996
1074
  export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
997
1075
  `);
998
- dts.push(outdent17`
1076
+ dts.push(outdent20`
999
1077
  import { ConditionalValue } from "../types"
1000
1078
 
1001
- export type ${capitalize8(name)}Variants = {
1079
+ export type ${capitalize11(name)}Variants = {
1002
1080
  ${Object.keys(variants ?? {}).map((key) => {
1003
1081
  const value = variants[key];
1004
1082
  const keys = Object.keys(value);
@@ -1007,12 +1085,12 @@ function generateRecipes(ctx) {
1007
1085
  }
1008
1086
 
1009
1087
  ${description ? `/** ${description} */` : ""}
1010
- export declare function ${name}(value?: ${capitalize8(name)}Variants): string
1088
+ export declare function ${name}(value?: ${capitalize11(name)}Variants): string
1011
1089
  `);
1012
1090
  });
1013
1091
  return {
1014
- js: outdent17.string(js.join("\n\n")),
1015
- dts: outdent17.string(dts.join("\n\n"))
1092
+ js: outdent20.string(js.join("\n\n")),
1093
+ dts: outdent20.string(dts.join("\n\n"))
1016
1094
  };
1017
1095
  }
1018
1096
 
@@ -1119,14 +1197,14 @@ function generateReset() {
1119
1197
 
1120
1198
  // src/generators/token-css.ts
1121
1199
  import { prettifyCss, toCss, toKeyframeCss } from "@pandacss/core";
1122
- import { outdent as outdent18 } from "outdent";
1200
+ import { outdent as outdent21 } from "outdent";
1123
1201
  import { match as match5 } from "ts-pattern";
1124
1202
  function generateKeyframes(keyframes) {
1125
1203
  if (!keyframes)
1126
1204
  return;
1127
1205
  return toKeyframeCss(keyframes);
1128
1206
  }
1129
- var getConditionMessage = (value) => outdent18`
1207
+ var getConditionMessage = (value) => outdent21`
1130
1208
  It seems you provided an invalid condition for semantic tokens.
1131
1209
 
1132
1210
  - You provided: \`${value}\`
@@ -1187,8 +1265,8 @@ function generateTokenCss(ctx, varRoot) {
1187
1265
  }
1188
1266
 
1189
1267
  // src/generators/token-dts.ts
1190
- import { unionType as unionType4, capitalize as capitalize9 } from "@pandacss/shared";
1191
- import { outdent as outdent19 } from "outdent";
1268
+ import { unionType as unionType4, capitalize as capitalize12 } from "@pandacss/shared";
1269
+ import { outdent as outdent22 } from "outdent";
1192
1270
  import pluralize from "pluralize";
1193
1271
  function generateTokenDts(dict) {
1194
1272
  const set = /* @__PURE__ */ new Set();
@@ -1198,7 +1276,7 @@ function generateTokenDts(dict) {
1198
1276
  interfaceSet.add("[token: string]: string");
1199
1277
  } else {
1200
1278
  for (const [key, value] of dict.categoryMap.entries()) {
1201
- const typeName = capitalize9(pluralize.singular(key));
1279
+ const typeName = capitalize12(pluralize.singular(key));
1202
1280
  set.add(`export type ${typeName} = ${unionType4(value.keys())}`);
1203
1281
  set.add(`export type ColorPalette = ${unionType4(Object.keys(dict.colorPalettes))}`);
1204
1282
  interfaceSet.add(` ${key}: ${typeName}`);
@@ -1206,11 +1284,11 @@ function generateTokenDts(dict) {
1206
1284
  }
1207
1285
  interfaceSet.add("}");
1208
1286
  set.add(Array.from(interfaceSet).join("\n"));
1209
- return outdent19.string(Array.from(set).join("\n\n"));
1287
+ return outdent22.string(Array.from(set).join("\n\n"));
1210
1288
  }
1211
1289
 
1212
1290
  // src/generators/token-js.ts
1213
- import outdent20 from "outdent";
1291
+ import outdent23 from "outdent";
1214
1292
  function generateTokenJs(dict) {
1215
1293
  const map = /* @__PURE__ */ new Map();
1216
1294
  dict.allTokens.forEach((token) => {
@@ -1220,7 +1298,7 @@ function generateTokenJs(dict) {
1220
1298
  });
1221
1299
  const obj = Object.fromEntries(map);
1222
1300
  return {
1223
- js: outdent20`
1301
+ js: outdent23`
1224
1302
  const tokens = ${JSON.stringify(obj, null, 2)}
1225
1303
 
1226
1304
  function getToken(path) {
@@ -1233,7 +1311,7 @@ function generateTokenJs(dict) {
1233
1311
  return variable
1234
1312
  }
1235
1313
  `,
1236
- dts: outdent20`
1314
+ dts: outdent23`
1237
1315
  import { Token } from "../types/token"
1238
1316
  export declare function getToken(path: Token): string
1239
1317
  export declare function getTokenVar(path: Token): string
@@ -1243,27 +1321,29 @@ function generateTokenJs(dict) {
1243
1321
 
1244
1322
  // src/generators/types.ts
1245
1323
  import { readFileSync as readFileSync2 } from "fs-extra";
1246
- import outdent21 from "outdent";
1324
+ import outdent24 from "outdent";
1247
1325
  function getType(file) {
1248
1326
  const filepath = getEntrypoint("@pandacss/types", { dev: file });
1249
1327
  return readFileSync2(filepath, "utf8");
1250
1328
  }
1251
1329
  function generateCssType(ctx) {
1252
1330
  const strict = ctx.strictTokens;
1331
+ const strictArg = strict ? "true" : "false";
1253
1332
  return {
1254
1333
  cssType: getType("csstype.d.ts"),
1255
1334
  pandaCssType: getType("system-types.d.ts"),
1256
- publicType: outdent21`
1335
+ publicType: outdent24`
1257
1336
  import * as System from './system-types'
1258
1337
  import { PropTypes } from './prop-type'
1259
1338
  import { Conditions } from './conditions'
1260
1339
 
1261
- export type SystemStyleObject = System.StyleObject<Conditions, PropTypes${strict ? ", true" : ""}>
1262
- export type GlobalStyleObject = System.GlobalStyleObject<Conditions, PropTypes${strict ? ", true" : ""}>
1263
- export type JSXStyleProperties = System.JSXStyleProperties<Conditions, PropTypes${strict ? ", true" : ""}>
1340
+ export type SystemStyleObject<Overrides = {}> = System.StyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
1341
+ export type GlobalStyleObject<Overrides = {}> = System.GlobalStyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
1342
+ export type JsxStyleProps<Overrides = {}> = System.JsxStyleProps<Conditions, PropTypes, ${strictArg}, Overrides>
1343
+ export type ConditionalValue<Value> = System.Conditional<Conditions, Value>
1264
1344
 
1265
- export type ConditionalValue<T> = System.Conditional<Conditions, T>
1266
- export type Assign<T, U> = Omit<T, keyof U> & U
1345
+ type DistributiveOmit<T, U> = T extends any ? Pick<T, Exclude<keyof T, U>> : never
1346
+ export type Assign<Target, Override> = DistributiveOmit<Target, keyof Override> & Override
1267
1347
  `
1268
1348
  };
1269
1349
  }
@@ -1312,16 +1392,18 @@ function setupGlobalCss(ctx) {
1312
1392
  function setupTypes(ctx) {
1313
1393
  const code = generateCssType(ctx);
1314
1394
  const conditions = generateConditions(ctx);
1395
+ const jsx = generateJsxTypes(ctx);
1315
1396
  return {
1316
1397
  dir: ctx.paths.types,
1317
1398
  files: [
1399
+ jsx ? { file: "jsx.d.ts", code: jsx.jsxType } : null,
1318
1400
  { file: "csstype.d.ts", code: code.cssType },
1319
1401
  { file: "system-types.d.ts", code: code.pandaCssType },
1320
1402
  { file: "index.d.ts", code: code.publicType },
1321
1403
  { file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
1322
1404
  { file: "prop-type.d.ts", code: generatePropTypes(ctx.utility) },
1323
1405
  { file: "conditions.d.ts", code: conditions.dts }
1324
- ]
1406
+ ].filter(Boolean)
1325
1407
  };
1326
1408
  }
1327
1409
  function setupCss(ctx) {
@@ -1374,11 +1456,11 @@ function setupPatterns(ctx) {
1374
1456
  if (!files) {
1375
1457
  return { files: [] };
1376
1458
  }
1377
- const indexCode = outdent22.string(files.map((file) => `export * from './${file.name}'`).join("\n"));
1459
+ const indexCode = outdent25.string(files.map((file) => `export * from './${file.name}'`).join("\n"));
1378
1460
  return {
1379
1461
  dir: ctx.paths.pattern,
1380
1462
  files: [
1381
- ...files.map((file) => ({ file: `${file.name}.js`, code: file.js })),
1463
+ ...files.map((file) => ({ file: `${file.name}.mjs`, code: file.js })),
1382
1464
  ...files.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
1383
1465
  { file: "index.mjs", code: indexCode },
1384
1466
  { file: "index.d.ts", code: indexCode }
@@ -1389,13 +1471,14 @@ function setupJsx(ctx) {
1389
1471
  if (!ctx.jsxFramework)
1390
1472
  return { files: [] };
1391
1473
  const isValidProp = generateisValidProp(ctx);
1474
+ const types = generateJsxTypes(ctx);
1392
1475
  const factory = generateJsxFactory(ctx);
1393
1476
  const patterns = generateJsxPatterns(ctx);
1394
1477
  const layoutGrid = generateLayoutGrid(ctx);
1395
- const indexCode = outdent22`
1478
+ const indexCode = outdent25`
1396
1479
  export * from './factory'
1397
1480
  export * from './layout-grid'
1398
- ${outdent22.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
1481
+ ${outdent25.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
1399
1482
  `;
1400
1483
  return {
1401
1484
  dir: ctx.paths.jsx,
@@ -1405,7 +1488,7 @@ function setupJsx(ctx) {
1405
1488
  { file: "layout-grid.jsx", code: layoutGrid.js },
1406
1489
  { file: "layout-grid.d.ts", code: layoutGrid.dts },
1407
1490
  { file: "is-valid-prop.mjs", code: isValidProp.js },
1408
- { file: "factory.d.ts", code: factory.dts },
1491
+ { file: "factory.d.ts", code: types.jsxFactory },
1409
1492
  { file: "factory.jsx", code: factory.js },
1410
1493
  { file: "index.d.ts", code: indexCode },
1411
1494
  { file: "index.jsx", code: indexCode }
@@ -1413,7 +1496,7 @@ function setupJsx(ctx) {
1413
1496
  };
1414
1497
  }
1415
1498
  function setupCssIndex(ctx) {
1416
- const code = outdent22`
1499
+ const code = outdent25`
1417
1500
  export * from './css'
1418
1501
  export * from './cx'
1419
1502
  export * from './global-css'
@@ -1453,30 +1536,30 @@ function generateSystem(ctx) {
1453
1536
 
1454
1537
  // src/messages.ts
1455
1538
  import { colors, logger as logger3, quote as quote2 } from "@pandacss/logger";
1456
- import { outdent as outdent23 } from "outdent";
1539
+ import { outdent as outdent26 } from "outdent";
1457
1540
  var tick = colors.green().bold("\u2714\uFE0F");
1458
1541
  function artifactsGeneratedMessage(ctx) {
1459
1542
  return [
1460
- outdent23`
1543
+ outdent26`
1461
1544
  ${tick} ${quote2(ctx.outdir, "/css")}: the css function to author styles
1462
1545
  `,
1463
- ctx.hasTokens && outdent23`
1546
+ ctx.hasTokens && outdent26`
1464
1547
  ${tick} ${quote2(ctx.outdir, "/tokens")}: the css variables and js function to query your tokens
1465
1548
  `,
1466
- ctx.hasPatterns && outdent23`
1549
+ ctx.hasPatterns && outdent26`
1467
1550
  ${tick} ${quote2(ctx.outdir, "/patterns")}: functions to implement common css patterns
1468
1551
  `,
1469
- ctx.hasRecipes && outdent23`
1552
+ ctx.hasRecipes && outdent26`
1470
1553
  ${tick} ${quote2(ctx.outdir, "/recipes")}: functions to create multi-variant styles
1471
1554
  `,
1472
- ctx.jsxFramework && outdent23`
1555
+ ctx.jsxFramework && outdent26`
1473
1556
  ${tick} ${quote2(ctx.outdir, "/jsx")}: style prop powered elements for ${ctx.jsxFramework}
1474
1557
  `,
1475
1558
  "\n"
1476
1559
  ].filter(Boolean).join("\n");
1477
1560
  }
1478
1561
  function configExistsMessage(cmd) {
1479
- return outdent23`
1562
+ return outdent26`
1480
1563
  \n
1481
1564
  It looks like you already have panda created\`.
1482
1565
 
@@ -1485,7 +1568,7 @@ function configExistsMessage(cmd) {
1485
1568
  `;
1486
1569
  }
1487
1570
  function thankYouMessage() {
1488
- return outdent23`
1571
+ return outdent26`
1489
1572
 
1490
1573
  🚀 Thanks for choosing ${colors.cyan("Panda")} to write your css.
1491
1574
 
@@ -1497,7 +1580,7 @@ var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
1497
1580
  var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
1498
1581
  function scaffoldCompleteMessage() {
1499
1582
  return logger3.box(
1500
- outdent23`
1583
+ outdent26`
1501
1584
 
1502
1585
  ${colors.bold().cyan("Next steps:")}
1503
1586
 
@@ -1513,12 +1596,12 @@ function scaffoldCompleteMessage() {
1513
1596
  );
1514
1597
  }
1515
1598
  function watchMessage() {
1516
- return outdent23`
1599
+ return outdent26`
1517
1600
  Watching for file changes...
1518
1601
  `;
1519
1602
  }
1520
1603
  function buildCompleteMessage(ctx) {
1521
- return outdent23`
1604
+ return outdent26`
1522
1605
  Successfully extracted css from ${ctx.files.length} file(s) ✨
1523
1606
  `;
1524
1607
  }
@@ -1574,7 +1657,7 @@ import {
1574
1657
  import { isCssProperty } from "@pandacss/is-valid-prop";
1575
1658
  import { logger as logger4 } from "@pandacss/logger";
1576
1659
  import { createParser, createProject } from "@pandacss/parser";
1577
- import { capitalize as capitalize10, compact, mapObject, uncapitalize } from "@pandacss/shared";
1660
+ import { capitalize as capitalize13, compact, mapObject, uncapitalize } from "@pandacss/shared";
1578
1661
  import { TokenDictionary } from "@pandacss/token-dictionary";
1579
1662
  import glob from "fast-glob";
1580
1663
  import { readdirSync, readFileSync as readFileSync4 } from "fs";
@@ -1679,7 +1762,7 @@ function createContext(conf, io = fileSystem) {
1679
1762
  }
1680
1763
  const patternNodes = Object.entries(patterns).map(([name, pattern]) => ({
1681
1764
  type: "pattern",
1682
- name: pattern.jsx ?? capitalize10(name),
1765
+ name: pattern.jsx ?? capitalize13(name),
1683
1766
  props: Object.keys(pattern.properties),
1684
1767
  baseName: name
1685
1768
  }));
@@ -1692,7 +1775,7 @@ function createContext(conf, io = fileSystem) {
1692
1775
  }
1693
1776
  const recipeNodes = Object.entries(recipes).map(([name, recipe]) => ({
1694
1777
  type: "recipe",
1695
- name: recipe.jsx ?? capitalize10(name),
1778
+ name: recipe.jsx ?? capitalize13(name),
1696
1779
  props: Object.keys(recipe.variants ?? {}),
1697
1780
  baseName: name
1698
1781
  }));
@@ -1713,7 +1796,7 @@ function createContext(conf, io = fileSystem) {
1713
1796
  }));
1714
1797
  }
1715
1798
  const hasRecipes = Object.keys(recipes).length > 0;
1716
- const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
1799
+ const properties = Array.from(/* @__PURE__ */ new Set(["css", "sx", ...utility.keys(), ...conditions.keys()]));
1717
1800
  function isCustomCssProperty(prop) {
1718
1801
  const regex = new RegExp("^(?:" + properties.join("|") + ")$");
1719
1802
  return regex.test(prop);
@@ -2259,9 +2342,9 @@ async function generate5(config, configPath) {
2259
2342
  // src/git-ignore.ts
2260
2343
  import { appendFileSync, readFileSync as readFileSync6, writeFileSync } from "fs";
2261
2344
  import { lookItUpSync as lookItUpSync2 } from "look-it-up";
2262
- import outdent24 from "outdent";
2345
+ import outdent27 from "outdent";
2263
2346
  function setupGitIgnore(ctx) {
2264
- const txt = outdent24`## CSS Panda
2347
+ const txt = outdent27`## CSS Panda
2265
2348
  ${ctx.outdir}
2266
2349
  ${ctx.outdir}-static
2267
2350
  `;
@@ -2279,7 +2362,7 @@ function setupGitIgnore(ctx) {
2279
2362
  import { logger as logger9, quote as quote3 } from "@pandacss/logger";
2280
2363
  import { writeFile as writeFile2 } from "fs-extra";
2281
2364
  import { lookItUpSync as lookItUpSync3 } from "look-it-up";
2282
- import { outdent as outdent25 } from "outdent";
2365
+ import { outdent as outdent28 } from "outdent";
2283
2366
  import { join as join4 } from "path";
2284
2367
  import getPackageManager2 from "preferred-pm";
2285
2368
  async function setupConfig(cwd, { force }) {
@@ -2293,7 +2376,7 @@ async function setupConfig(cwd, { force }) {
2293
2376
  if (!force && configFile) {
2294
2377
  logger9.warn("config exists", configExistsMessage(cmd));
2295
2378
  } else {
2296
- const content = outdent25`
2379
+ const content = outdent28`
2297
2380
  import { defineConfig } from "css-panda"
2298
2381
 
2299
2382
  export default defineConfig({
@@ -2319,7 +2402,7 @@ async function setupConfig(cwd, { force }) {
2319
2402
  }
2320
2403
  async function setupPostcss(cwd) {
2321
2404
  logger9.info({ type: "init", msg: `creating postcss config file: ${quote3("postcss.config.cjs")}` });
2322
- const content = outdent25`
2405
+ const content = outdent28`
2323
2406
  module.exports = {
2324
2407
  plugins: {
2325
2408
  'css-panda/postcss': {},