@pandacss/node 0.0.0-dev-20230109182737 → 0.0.0-dev-20230110151021
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 +15 -12
- package/dist/index.js +160 -157
- package/dist/index.mjs +139 -136
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -84,20 +84,19 @@ import { readFileSync as readFileSync3 } from "fs";
|
|
|
84
84
|
import outdent23 from "outdent";
|
|
85
85
|
|
|
86
86
|
// src/generators/conditions.ts
|
|
87
|
-
import { unionType } from "@pandacss/shared";
|
|
88
87
|
import outdent from "outdent";
|
|
89
88
|
function generateConditions(ctx) {
|
|
90
89
|
const keys = Object.keys(ctx.conditions.values).concat("base");
|
|
91
90
|
return {
|
|
92
91
|
js: outdent`
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
import { withoutSpace } from '../helpers'
|
|
93
|
+
const conditions = new Set([${keys.map((key) => JSON.stringify(key))}])
|
|
94
|
+
|
|
95
|
+
export function isCondition(value){
|
|
97
96
|
return conditions.has(value) || /^@|&|&$/.test(value)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function finalizeConditions(paths){
|
|
101
100
|
return paths.map((path) => {
|
|
102
101
|
if (conditions.has(path)){
|
|
103
102
|
return path.replace(/^_/, '')
|
|
@@ -106,11 +105,11 @@ function generateConditions(ctx) {
|
|
|
106
105
|
if (/&|@/.test(path)){
|
|
107
106
|
return \`[\${withoutSpace(path.trim())}]\`
|
|
108
107
|
}
|
|
109
|
-
|
|
108
|
+
|
|
110
109
|
return path
|
|
111
110
|
})}
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
|
|
112
|
+
export function sortConditions(paths){
|
|
114
113
|
return paths.sort((a, b) => {
|
|
115
114
|
const aa = isCondition(a)
|
|
116
115
|
const bb = isCondition(b)
|
|
@@ -118,12 +117,34 @@ function generateConditions(ctx) {
|
|
|
118
117
|
if (!aa && bb) return -1
|
|
119
118
|
return 0
|
|
120
119
|
})
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
}
|
|
121
|
+
`,
|
|
123
122
|
dts: outdent`
|
|
124
|
-
|
|
123
|
+
import type { AnySelector, Selectors } from './selectors'
|
|
124
|
+
|
|
125
|
+
export type Conditions = {
|
|
126
|
+
${keys.map((key) => ` ${JSON.stringify(key)}: string`).join("\n")}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type Condition = keyof Conditions
|
|
125
130
|
|
|
126
|
-
|
|
131
|
+
export type Conditional<V> =
|
|
132
|
+
| V
|
|
133
|
+
| Array<V | null>
|
|
134
|
+
| {
|
|
135
|
+
[K in keyof Conditions]?: Conditional<V>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type ConditionalValue<T> = Conditional<T>
|
|
139
|
+
|
|
140
|
+
export type Nested<P> = P & {
|
|
141
|
+
[K in Selectors]?: Nested<P>
|
|
142
|
+
} & {
|
|
143
|
+
[K in AnySelector]?: Nested<P>
|
|
144
|
+
} & {
|
|
145
|
+
[K in keyof Conditions]?: Nested<P>
|
|
146
|
+
}
|
|
147
|
+
|
|
127
148
|
`
|
|
128
149
|
};
|
|
129
150
|
}
|
|
@@ -321,7 +342,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
321
342
|
function createJsxFactory() {
|
|
322
343
|
const cache = new Map()
|
|
323
344
|
|
|
324
|
-
return new Proxy(
|
|
345
|
+
return new Proxy(styled, {
|
|
325
346
|
apply(_, __, args) {
|
|
326
347
|
return styled(...args)
|
|
327
348
|
},
|
|
@@ -396,8 +417,8 @@ function generatePreactLayoutGrid() {
|
|
|
396
417
|
import { outdent as outdent7 } from "outdent";
|
|
397
418
|
import { match } from "ts-pattern";
|
|
398
419
|
function generate(ctx, name, pattern) {
|
|
399
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
400
|
-
const {
|
|
420
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
421
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
401
422
|
return {
|
|
402
423
|
name: dashName,
|
|
403
424
|
js: outdent7`
|
|
@@ -421,11 +442,14 @@ function generate(ctx, name, pattern) {
|
|
|
421
442
|
})
|
|
422
443
|
`,
|
|
423
444
|
dts: outdent7`
|
|
445
|
+
import { FunctionComponent } from 'preact'
|
|
424
446
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
425
|
-
import { ${
|
|
447
|
+
import { ${typeName} } from '../types/jsx'
|
|
448
|
+
|
|
449
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
426
450
|
|
|
427
451
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
428
|
-
export declare const ${jsxName}:
|
|
452
|
+
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
429
453
|
`
|
|
430
454
|
};
|
|
431
455
|
}
|
|
@@ -455,32 +479,20 @@ type AdditionalHtmlProps = {
|
|
|
455
479
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
456
480
|
}
|
|
457
481
|
|
|
458
|
-
type Polyfill<
|
|
459
|
-
ComponentProps,
|
|
460
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
461
|
-
> &
|
|
462
|
-
AdditionalHtmlProps
|
|
482
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
463
483
|
|
|
464
|
-
type Props<
|
|
465
|
-
Polyfill<ComponentProps>,
|
|
466
|
-
AdditionalProps
|
|
467
|
-
>
|
|
484
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
468
485
|
|
|
469
|
-
export type ${componentName}<
|
|
470
|
-
(
|
|
471
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
472
|
-
): JSX.Element
|
|
486
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
487
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
473
488
|
displayName?: string
|
|
474
489
|
}
|
|
475
490
|
|
|
476
491
|
export type ${upperName} = {
|
|
477
|
-
<
|
|
478
|
-
Component,
|
|
479
|
-
AdditionalProps
|
|
480
|
-
>
|
|
492
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
481
493
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
482
494
|
|
|
483
|
-
export type ${typeName}<
|
|
495
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
484
496
|
`
|
|
485
497
|
};
|
|
486
498
|
}
|
|
@@ -538,7 +550,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
538
550
|
function createJsxFactory() {
|
|
539
551
|
const cache = new Map()
|
|
540
552
|
|
|
541
|
-
return new Proxy(
|
|
553
|
+
return new Proxy(styled, {
|
|
542
554
|
apply(_, __, args) {
|
|
543
555
|
return styled(...args)
|
|
544
556
|
},
|
|
@@ -614,8 +626,8 @@ function generateReactLayoutGrid() {
|
|
|
614
626
|
import { outdent as outdent11 } from "outdent";
|
|
615
627
|
import { match as match2 } from "ts-pattern";
|
|
616
628
|
function generate2(ctx, name, pattern) {
|
|
617
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
618
|
-
const {
|
|
629
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
630
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
619
631
|
return {
|
|
620
632
|
name: dashName,
|
|
621
633
|
js: outdent11`
|
|
@@ -640,11 +652,14 @@ function generate2(ctx, name, pattern) {
|
|
|
640
652
|
})
|
|
641
653
|
`,
|
|
642
654
|
dts: outdent11`
|
|
655
|
+
import { FunctionComponent } from 'react'
|
|
643
656
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
644
|
-
import { ${
|
|
657
|
+
import { ${typeName} } from '../types/jsx'
|
|
658
|
+
|
|
659
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
645
660
|
|
|
646
661
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
647
|
-
export declare const ${jsxName}:
|
|
662
|
+
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
648
663
|
`
|
|
649
664
|
};
|
|
650
665
|
}
|
|
@@ -674,32 +689,20 @@ type AdditionalHtmlProps = {
|
|
|
674
689
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
675
690
|
}
|
|
676
691
|
|
|
677
|
-
type Polyfill<
|
|
678
|
-
ComponentProps,
|
|
679
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
680
|
-
> &
|
|
681
|
-
AdditionalHtmlProps
|
|
692
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
682
693
|
|
|
683
|
-
type Props<
|
|
684
|
-
Polyfill<ComponentProps>,
|
|
685
|
-
AdditionalProps
|
|
686
|
-
>
|
|
694
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
687
695
|
|
|
688
|
-
export type ${componentName}<
|
|
689
|
-
(
|
|
690
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
691
|
-
): JSX.Element
|
|
696
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
697
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
692
698
|
displayName?: string
|
|
693
699
|
}
|
|
694
700
|
|
|
695
701
|
export type ${upperName} = {
|
|
696
|
-
<
|
|
697
|
-
Component,
|
|
698
|
-
AdditionalProps
|
|
699
|
-
>
|
|
702
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
700
703
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
701
704
|
|
|
702
|
-
export type ${typeName}<
|
|
705
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
703
706
|
`
|
|
704
707
|
};
|
|
705
708
|
}
|
|
@@ -753,7 +756,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
753
756
|
function createJsxFactory() {
|
|
754
757
|
const cache = new Map()
|
|
755
758
|
|
|
756
|
-
return new Proxy(
|
|
759
|
+
return new Proxy(styled, {
|
|
757
760
|
apply(_, __, args) {
|
|
758
761
|
return styled(...args)
|
|
759
762
|
},
|
|
@@ -828,8 +831,8 @@ function generateSolidLayoutGrid() {
|
|
|
828
831
|
import { outdent as outdent15 } from "outdent";
|
|
829
832
|
import { match as match3 } from "ts-pattern";
|
|
830
833
|
function generate3(ctx, name, pattern) {
|
|
831
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
832
|
-
const {
|
|
834
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
835
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
833
836
|
return {
|
|
834
837
|
name: dashName,
|
|
835
838
|
js: outdent15`
|
|
@@ -853,11 +856,14 @@ function generate3(ctx, name, pattern) {
|
|
|
853
856
|
}
|
|
854
857
|
`,
|
|
855
858
|
dts: outdent15`
|
|
859
|
+
import { Component } from 'solid-js'
|
|
856
860
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
857
|
-
import { ${
|
|
861
|
+
import { ${typeName} } from '../types/jsx'
|
|
862
|
+
|
|
863
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
858
864
|
|
|
859
865
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
860
|
-
export declare const ${jsxName}:
|
|
866
|
+
export declare const ${jsxName}: Component<${upperName}Props>
|
|
861
867
|
`
|
|
862
868
|
};
|
|
863
869
|
}
|
|
@@ -880,7 +886,7 @@ import type { JsxStyleProps, Assign } from '.'
|
|
|
880
886
|
|
|
881
887
|
type Dict = Record<string, unknown>
|
|
882
888
|
|
|
883
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P
|
|
889
|
+
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
884
890
|
|
|
885
891
|
type AdditionalHtmlProps = {
|
|
886
892
|
htmlSize?: string | number
|
|
@@ -889,33 +895,20 @@ type AdditionalHtmlProps = {
|
|
|
889
895
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
890
896
|
}
|
|
891
897
|
|
|
892
|
-
type Polyfill<
|
|
893
|
-
ComponentProps,
|
|
894
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
895
|
-
> &
|
|
896
|
-
AdditionalHtmlProps
|
|
898
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
897
899
|
|
|
898
|
-
type Props<
|
|
899
|
-
Polyfill<ComponentProps>,
|
|
900
|
-
AdditionalProps
|
|
901
|
-
>
|
|
900
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
902
901
|
|
|
903
|
-
export type ${componentName}<
|
|
904
|
-
(
|
|
905
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
906
|
-
): JSX.Element
|
|
902
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
903
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
907
904
|
displayName?: string
|
|
908
905
|
}
|
|
909
906
|
|
|
910
|
-
|
|
911
907
|
export type ${upperName} = {
|
|
912
|
-
<
|
|
913
|
-
Component,
|
|
914
|
-
AdditionalProps
|
|
915
|
-
>
|
|
908
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
916
909
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
917
910
|
|
|
918
|
-
export type ${typeName}<
|
|
911
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
919
912
|
`
|
|
920
913
|
};
|
|
921
914
|
}
|
|
@@ -959,33 +952,33 @@ function generateLayoutGrid(ctx) {
|
|
|
959
952
|
}
|
|
960
953
|
|
|
961
954
|
// src/generators/pattern.ts
|
|
962
|
-
import { capitalize, dashCase, unionType
|
|
955
|
+
import { capitalize, dashCase, unionType } from "@pandacss/shared";
|
|
963
956
|
import { outdent as outdent17 } from "outdent";
|
|
964
957
|
import { stringify as stringify2 } from "telejson";
|
|
965
958
|
import { match as match4 } from "ts-pattern";
|
|
966
|
-
function generate4(name, pattern) {
|
|
959
|
+
function generate4(ctx, name, pattern) {
|
|
967
960
|
const { properties, transform, strict, description } = pattern;
|
|
968
|
-
const upperName =
|
|
969
|
-
const upperFn = `get${upperName}Style`;
|
|
961
|
+
const { upperName, styleFn, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
970
962
|
return {
|
|
971
963
|
name: dashCase(name),
|
|
972
964
|
dts: outdent17`
|
|
973
|
-
import { SystemStyleObject, ConditionalValue } from
|
|
974
|
-
import {
|
|
975
|
-
import {
|
|
965
|
+
import { SystemStyleObject, ConditionalValue } from '../types'
|
|
966
|
+
import { PropertyValue } from '../types/prop-type'
|
|
967
|
+
import { Properties } from '../types/csstype'
|
|
968
|
+
import { Tokens } from '../types/token'
|
|
976
969
|
|
|
977
970
|
export type ${capitalize(name)}Properties = {
|
|
978
971
|
${Object.keys(properties ?? {}).map((key) => {
|
|
979
972
|
const value = properties[key];
|
|
980
973
|
return match4(value).with({ type: "property" }, (value2) => {
|
|
981
|
-
return `${key}?:
|
|
974
|
+
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
982
975
|
}).with({ type: "token" }, (value2) => {
|
|
983
976
|
if (value2.property) {
|
|
984
977
|
return `${key}?: ConditionalValue<Tokens["${value2.value}"] | Properties["${value2.property}"]>`;
|
|
985
978
|
}
|
|
986
979
|
return `${key}?: ConditionalValue<Tokens["${value2.value}"]>`;
|
|
987
980
|
}).with({ type: "enum" }, (value2) => {
|
|
988
|
-
return `${key}?: ConditionalValue<${
|
|
981
|
+
return `${key}?: ConditionalValue<${unionType(value2.value)}>`;
|
|
989
982
|
}).otherwise(() => {
|
|
990
983
|
return `${key}?: ConditionalValue<${value.type}>`;
|
|
991
984
|
});
|
|
@@ -993,39 +986,43 @@ function generate4(name, pattern) {
|
|
|
993
986
|
}
|
|
994
987
|
|
|
995
988
|
${strict ? outdent17`export declare function ${name}(options: ${upperName}Properties): string` : outdent17`
|
|
996
|
-
|
|
989
|
+
|
|
990
|
+
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
991
|
+
|
|
997
992
|
${description ? `/** ${description} */` : ""}
|
|
998
|
-
export declare function ${name}(options:
|
|
993
|
+
export declare function ${name}(options: ${upperName}Options): string
|
|
999
994
|
`}
|
|
1000
995
|
|
|
1001
996
|
`,
|
|
1002
997
|
js: outdent17`
|
|
1003
|
-
import { mapObject } from
|
|
1004
|
-
import { css } from
|
|
998
|
+
import { mapObject } from '../helpers'
|
|
999
|
+
import { css } from '../css'
|
|
1005
1000
|
|
|
1006
1001
|
const config = ${stringify2({ transform })}
|
|
1007
1002
|
|
|
1008
|
-
export const ${
|
|
1003
|
+
export const ${styleFn} = (styles) => config.transform(styles, { map: mapObject })
|
|
1009
1004
|
|
|
1010
|
-
export const ${name} = (styles) => css(${
|
|
1011
|
-
`.replace(/"_function_([^|]*)\|(.*)"/, "$2").replace(/\\"/g, '"').replace("return", "; return").replace(";;", ";")
|
|
1005
|
+
export const ${name} = (styles) => css(${styleFn}(styles))
|
|
1006
|
+
`.replace(/"_function_([^|]*)\|(.*)"/, "$2").replace(/\\"/g, '"').replace("return", "; return").replace(";;", ";").replace("{;", "{")
|
|
1012
1007
|
};
|
|
1013
1008
|
}
|
|
1014
1009
|
function generatePattern(ctx) {
|
|
1015
1010
|
if (!ctx.hasPatterns)
|
|
1016
1011
|
return;
|
|
1017
|
-
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(name, pattern));
|
|
1012
|
+
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(ctx, name, pattern));
|
|
1018
1013
|
}
|
|
1019
1014
|
|
|
1020
1015
|
// src/generators/prop-types.ts
|
|
1021
1016
|
import { outdent as outdent18 } from "outdent";
|
|
1022
|
-
function generatePropTypes(utility) {
|
|
1017
|
+
function generatePropTypes(utility, strict) {
|
|
1018
|
+
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1023
1019
|
const result = [
|
|
1024
1020
|
outdent18`
|
|
1021
|
+
import { ConditionalValue } from './conditions';
|
|
1025
1022
|
import { Properties as CSSProperties } from './csstype'
|
|
1026
1023
|
import { Tokens } from './token'
|
|
1027
1024
|
|
|
1028
|
-
type
|
|
1025
|
+
type PropertyValueTypes = {`
|
|
1029
1026
|
];
|
|
1030
1027
|
const types = utility.getTypes();
|
|
1031
1028
|
for (const [prop, values] of types.entries()) {
|
|
@@ -1033,23 +1030,29 @@ function generatePropTypes(utility) {
|
|
|
1033
1030
|
}
|
|
1034
1031
|
result.push("}", "\n");
|
|
1035
1032
|
result.push(`
|
|
1036
|
-
type
|
|
1037
|
-
|
|
1038
|
-
type
|
|
1039
|
-
|
|
1040
|
-
type Shorthand<T> = CssProp<T> | BaseProp<T>
|
|
1033
|
+
type NativeValue<T> = T extends keyof CSSProperties ? CSSProperties[T] : never
|
|
1034
|
+
|
|
1035
|
+
type Shorthand<T> = T extends keyof PropertyValueTypes ? PropertyValueTypes[T]${strictText} : NativeValue<T>
|
|
1041
1036
|
|
|
1042
|
-
export type
|
|
1037
|
+
export type PropertyTypes = PropertyValueTypes & {
|
|
1043
1038
|
`);
|
|
1044
1039
|
utility.shorthands.forEach((value, key) => {
|
|
1045
1040
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1046
1041
|
});
|
|
1047
1042
|
result.push("}");
|
|
1048
|
-
return
|
|
1043
|
+
return outdent18`
|
|
1044
|
+
${result.join("\n")}
|
|
1045
|
+
|
|
1046
|
+
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
1047
|
+
? ConditionalValue<PropertyTypes[T]${strictText}>
|
|
1048
|
+
: T extends keyof CSSProperties
|
|
1049
|
+
? ConditionalValue<CSSProperties[T]>
|
|
1050
|
+
: never
|
|
1051
|
+
`;
|
|
1049
1052
|
}
|
|
1050
1053
|
|
|
1051
1054
|
// src/generators/recipe.ts
|
|
1052
|
-
import { capitalize as capitalize2, unionType as
|
|
1055
|
+
import { capitalize as capitalize2, unionType as unionType2 } from "@pandacss/shared";
|
|
1053
1056
|
import { outdent as outdent19 } from "outdent";
|
|
1054
1057
|
function generateRecipes(ctx) {
|
|
1055
1058
|
const { recipes = {}, hash, hasRecipes, utility } = ctx;
|
|
@@ -1104,12 +1107,12 @@ function generateRecipes(ctx) {
|
|
|
1104
1107
|
${Object.keys(variants ?? {}).map((key) => {
|
|
1105
1108
|
const value = variants[key];
|
|
1106
1109
|
const keys = Object.keys(value);
|
|
1107
|
-
return `${key}?: ConditionalValue<${
|
|
1110
|
+
return `${key}?: ConditionalValue<${unionType2(keys)}>`;
|
|
1108
1111
|
}).join("\n")}
|
|
1109
1112
|
}
|
|
1110
1113
|
|
|
1111
1114
|
${description ? `/** ${description} */` : ""}
|
|
1112
|
-
export declare function ${name}(
|
|
1115
|
+
export declare function ${name}(variants?: ${capitalize2(name)}Variants): string
|
|
1113
1116
|
`);
|
|
1114
1117
|
});
|
|
1115
1118
|
return {
|
|
@@ -1292,20 +1295,20 @@ function cleanupSelectors(css2, varSelector) {
|
|
|
1292
1295
|
}
|
|
1293
1296
|
|
|
1294
1297
|
// src/generators/token-dts.ts
|
|
1295
|
-
import { unionType as
|
|
1298
|
+
import { unionType as unionType3, capitalize as capitalize3 } from "@pandacss/shared";
|
|
1296
1299
|
import { outdent as outdent20 } from "outdent";
|
|
1297
1300
|
import pluralize from "pluralize";
|
|
1298
1301
|
function generateTokenDts(dict) {
|
|
1299
1302
|
const set = /* @__PURE__ */ new Set();
|
|
1300
|
-
set.add(`export type Token = ${dict.isEmpty ? "string" :
|
|
1303
|
+
set.add(`export type Token = ${dict.isEmpty ? "string" : unionType3(dict.allNames)}`);
|
|
1301
1304
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
1302
1305
|
if (dict.isEmpty) {
|
|
1303
1306
|
result.add("[token: string]: string");
|
|
1304
1307
|
} else {
|
|
1305
1308
|
for (const [key, value] of dict.categoryMap.entries()) {
|
|
1306
1309
|
const typeName = capitalize3(pluralize.singular(key));
|
|
1307
|
-
set.add(`export type ${typeName} = ${
|
|
1308
|
-
set.add(`export type ColorPalette = ${
|
|
1310
|
+
set.add(`export type ${typeName} = ${unionType3(value.keys())}`);
|
|
1311
|
+
set.add(`export type ColorPalette = ${unionType3(Object.keys(dict.colorPalettes))}`);
|
|
1309
1312
|
result.add(` ${key}: ${typeName}`);
|
|
1310
1313
|
}
|
|
1311
1314
|
}
|
|
@@ -1347,6 +1350,7 @@ function generateTokenJs(dict) {
|
|
|
1347
1350
|
}
|
|
1348
1351
|
|
|
1349
1352
|
// src/generators/types.ts
|
|
1353
|
+
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
1350
1354
|
import { readFileSync as readFileSync2 } from "fs-extra";
|
|
1351
1355
|
import outdent22 from "outdent";
|
|
1352
1356
|
function getType(file) {
|
|
@@ -1354,27 +1358,23 @@ function getType(file) {
|
|
|
1354
1358
|
return readFileSync2(filepath, "utf8");
|
|
1355
1359
|
}
|
|
1356
1360
|
function generateCssType(ctx) {
|
|
1357
|
-
const
|
|
1358
|
-
const strictArg = strict ? "true" : "false";
|
|
1361
|
+
const propList = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
1359
1362
|
return {
|
|
1360
1363
|
cssType: getType("csstype.d.ts"),
|
|
1361
1364
|
pandaCssType: getType("system-types.d.ts"),
|
|
1365
|
+
selectorType: getType("selectors.d.ts"),
|
|
1362
1366
|
publicType: outdent22`
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
import { Conditions } from './conditions'
|
|
1366
|
-
|
|
1367
|
-
export type SystemStyleObject<Overrides extends Record<string, unknown> = {}> = System.StyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
|
|
1368
|
-
|
|
1369
|
-
export type GlobalStyleObject<Overrides extends Record<string, unknown> = {}> = System.GlobalStyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
|
|
1367
|
+
export { ConditionalValue } from './conditions'
|
|
1368
|
+
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1370
1369
|
|
|
1371
|
-
export type
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1370
|
+
export type Assign<Target, Override> = Omit<Target, keyof Override> & Override
|
|
1371
|
+
`,
|
|
1372
|
+
styleProps: outdent22`
|
|
1373
|
+
import { PropertyValue } from './prop-type'
|
|
1374
|
+
|
|
1375
|
+
export type SystemProperties = {
|
|
1376
|
+
${Array.from(propList).map((v) => ` ${v}?: PropertyValue<'${v}'>`).join("\n")}
|
|
1377
|
+
}
|
|
1378
1378
|
`
|
|
1379
1379
|
};
|
|
1380
1380
|
}
|
|
@@ -1420,9 +1420,11 @@ function setupTypes(ctx) {
|
|
|
1420
1420
|
jsx ? { file: "jsx.d.ts", code: jsx.jsxType } : null,
|
|
1421
1421
|
{ file: "csstype.d.ts", code: code.cssType },
|
|
1422
1422
|
{ file: "system-types.d.ts", code: code.pandaCssType },
|
|
1423
|
+
{ file: "selectors.d.ts", code: code.selectorType },
|
|
1423
1424
|
{ file: "index.d.ts", code: code.publicType },
|
|
1424
1425
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
1425
1426
|
{ file: "prop-type.d.ts", code: generatePropTypes(ctx.utility) },
|
|
1427
|
+
{ file: "style-props.d.ts", code: code.styleProps },
|
|
1426
1428
|
{ file: "conditions.d.ts", code: conditions.dts }
|
|
1427
1429
|
].filter(Boolean)
|
|
1428
1430
|
};
|
|
@@ -1788,7 +1790,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
1788
1790
|
dashName: dashCase2(name),
|
|
1789
1791
|
upperName,
|
|
1790
1792
|
styleFn: `get${upperName}Style`,
|
|
1791
|
-
jsxName: pattern?.jsx ?? upperName
|
|
1793
|
+
jsxName: pattern?.jsx ?? upperName,
|
|
1794
|
+
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : ""
|
|
1792
1795
|
};
|
|
1793
1796
|
}
|
|
1794
1797
|
const patternNodes = Object.entries(patterns).map(([name, pattern]) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230110151021",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"telejson": "7.0.4",
|
|
31
31
|
"ts-pattern": "4.1.2",
|
|
32
32
|
"ts-morph": "17.0.1",
|
|
33
|
-
"@pandacss/types": "0.0.0-dev-
|
|
34
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
35
|
-
"@pandacss/error": "0.0.0-dev-
|
|
36
|
-
"@pandacss/parser": "0.0.0-dev-
|
|
37
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
38
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
39
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
40
|
-
"@pandacss/core": "0.0.0-dev-
|
|
41
|
-
"@pandacss/config": "0.0.0-dev-
|
|
33
|
+
"@pandacss/types": "0.0.0-dev-20230110151021",
|
|
34
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230110151021",
|
|
35
|
+
"@pandacss/error": "0.0.0-dev-20230110151021",
|
|
36
|
+
"@pandacss/parser": "0.0.0-dev-20230110151021",
|
|
37
|
+
"@pandacss/shared": "0.0.0-dev-20230110151021",
|
|
38
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230110151021",
|
|
39
|
+
"@pandacss/logger": "0.0.0-dev-20230110151021",
|
|
40
|
+
"@pandacss/core": "0.0.0-dev-20230110151021",
|
|
41
|
+
"@pandacss/config": "0.0.0-dev-20230110151021"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/fs-extra": "11.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/glob-parent": "^5.1.1",
|
|
47
47
|
"@types/pluralize": "0.0.29",
|
|
48
48
|
"@types/lodash.merge": "4.6.7",
|
|
49
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
49
|
+
"@pandacss/fixture": "0.0.0-dev-20230110151021"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|