@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.js
CHANGED
|
@@ -130,20 +130,19 @@ var import_fs2 = require("fs");
|
|
|
130
130
|
var import_outdent23 = __toESM(require("outdent"));
|
|
131
131
|
|
|
132
132
|
// src/generators/conditions.ts
|
|
133
|
-
var import_shared = require("@pandacss/shared");
|
|
134
133
|
var import_outdent = __toESM(require("outdent"));
|
|
135
134
|
function generateConditions(ctx) {
|
|
136
135
|
const keys = Object.keys(ctx.conditions.values).concat("base");
|
|
137
136
|
return {
|
|
138
137
|
js: import_outdent.default`
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
import { withoutSpace } from '../helpers'
|
|
139
|
+
const conditions = new Set([${keys.map((key) => JSON.stringify(key))}])
|
|
140
|
+
|
|
141
|
+
export function isCondition(value){
|
|
143
142
|
return conditions.has(value) || /^@|&|&$/.test(value)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function finalizeConditions(paths){
|
|
147
146
|
return paths.map((path) => {
|
|
148
147
|
if (conditions.has(path)){
|
|
149
148
|
return path.replace(/^_/, '')
|
|
@@ -152,11 +151,11 @@ function generateConditions(ctx) {
|
|
|
152
151
|
if (/&|@/.test(path)){
|
|
153
152
|
return \`[\${withoutSpace(path.trim())}]\`
|
|
154
153
|
}
|
|
155
|
-
|
|
154
|
+
|
|
156
155
|
return path
|
|
157
156
|
})}
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
|
|
158
|
+
export function sortConditions(paths){
|
|
160
159
|
return paths.sort((a, b) => {
|
|
161
160
|
const aa = isCondition(a)
|
|
162
161
|
const bb = isCondition(b)
|
|
@@ -164,12 +163,34 @@ function generateConditions(ctx) {
|
|
|
164
163
|
if (!aa && bb) return -1
|
|
165
164
|
return 0
|
|
166
165
|
})
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
}
|
|
167
|
+
`,
|
|
169
168
|
dts: import_outdent.default`
|
|
170
|
-
|
|
169
|
+
import type { AnySelector, Selectors } from './selectors'
|
|
170
|
+
|
|
171
|
+
export type Conditions = {
|
|
172
|
+
${keys.map((key) => ` ${JSON.stringify(key)}: string`).join("\n")}
|
|
173
|
+
}
|
|
171
174
|
|
|
172
|
-
|
|
175
|
+
export type Condition = keyof Conditions
|
|
176
|
+
|
|
177
|
+
export type Conditional<V> =
|
|
178
|
+
| V
|
|
179
|
+
| Array<V | null>
|
|
180
|
+
| {
|
|
181
|
+
[K in keyof Conditions]?: Conditional<V>
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type ConditionalValue<T> = Conditional<T>
|
|
185
|
+
|
|
186
|
+
export type Nested<P> = P & {
|
|
187
|
+
[K in Selectors]?: Nested<P>
|
|
188
|
+
} & {
|
|
189
|
+
[K in AnySelector]?: Nested<P>
|
|
190
|
+
} & {
|
|
191
|
+
[K in keyof Conditions]?: Nested<P>
|
|
192
|
+
}
|
|
193
|
+
|
|
173
194
|
`
|
|
174
195
|
};
|
|
175
196
|
}
|
|
@@ -367,7 +388,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
367
388
|
function createJsxFactory() {
|
|
368
389
|
const cache = new Map()
|
|
369
390
|
|
|
370
|
-
return new Proxy(
|
|
391
|
+
return new Proxy(styled, {
|
|
371
392
|
apply(_, __, args) {
|
|
372
393
|
return styled(...args)
|
|
373
394
|
},
|
|
@@ -442,8 +463,8 @@ function generatePreactLayoutGrid() {
|
|
|
442
463
|
var import_outdent7 = require("outdent");
|
|
443
464
|
var import_ts_pattern = require("ts-pattern");
|
|
444
465
|
function generate(ctx, name, pattern) {
|
|
445
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
446
|
-
const {
|
|
466
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
467
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
447
468
|
return {
|
|
448
469
|
name: dashName,
|
|
449
470
|
js: import_outdent7.outdent`
|
|
@@ -467,11 +488,14 @@ function generate(ctx, name, pattern) {
|
|
|
467
488
|
})
|
|
468
489
|
`,
|
|
469
490
|
dts: import_outdent7.outdent`
|
|
491
|
+
import { FunctionComponent } from 'preact'
|
|
470
492
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
471
|
-
import { ${
|
|
493
|
+
import { ${typeName} } from '../types/jsx'
|
|
494
|
+
|
|
495
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
472
496
|
|
|
473
497
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
474
|
-
export declare const ${jsxName}:
|
|
498
|
+
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
475
499
|
`
|
|
476
500
|
};
|
|
477
501
|
}
|
|
@@ -501,32 +525,20 @@ type AdditionalHtmlProps = {
|
|
|
501
525
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
502
526
|
}
|
|
503
527
|
|
|
504
|
-
type Polyfill<
|
|
505
|
-
ComponentProps,
|
|
506
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
507
|
-
> &
|
|
508
|
-
AdditionalHtmlProps
|
|
528
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
509
529
|
|
|
510
|
-
type Props<
|
|
511
|
-
Polyfill<ComponentProps>,
|
|
512
|
-
AdditionalProps
|
|
513
|
-
>
|
|
530
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
514
531
|
|
|
515
|
-
export type ${componentName}<
|
|
516
|
-
(
|
|
517
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
518
|
-
): JSX.Element
|
|
532
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
533
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
519
534
|
displayName?: string
|
|
520
535
|
}
|
|
521
536
|
|
|
522
537
|
export type ${upperName} = {
|
|
523
|
-
<
|
|
524
|
-
Component,
|
|
525
|
-
AdditionalProps
|
|
526
|
-
>
|
|
538
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
527
539
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
528
540
|
|
|
529
|
-
export type ${typeName}<
|
|
541
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
530
542
|
`
|
|
531
543
|
};
|
|
532
544
|
}
|
|
@@ -584,7 +596,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
584
596
|
function createJsxFactory() {
|
|
585
597
|
const cache = new Map()
|
|
586
598
|
|
|
587
|
-
return new Proxy(
|
|
599
|
+
return new Proxy(styled, {
|
|
588
600
|
apply(_, __, args) {
|
|
589
601
|
return styled(...args)
|
|
590
602
|
},
|
|
@@ -660,8 +672,8 @@ function generateReactLayoutGrid() {
|
|
|
660
672
|
var import_outdent11 = require("outdent");
|
|
661
673
|
var import_ts_pattern2 = require("ts-pattern");
|
|
662
674
|
function generate2(ctx, name, pattern) {
|
|
663
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
664
|
-
const {
|
|
675
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
676
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
665
677
|
return {
|
|
666
678
|
name: dashName,
|
|
667
679
|
js: import_outdent11.outdent`
|
|
@@ -686,11 +698,14 @@ function generate2(ctx, name, pattern) {
|
|
|
686
698
|
})
|
|
687
699
|
`,
|
|
688
700
|
dts: import_outdent11.outdent`
|
|
701
|
+
import { FunctionComponent } from 'react'
|
|
689
702
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
690
|
-
import { ${
|
|
703
|
+
import { ${typeName} } from '../types/jsx'
|
|
704
|
+
|
|
705
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
691
706
|
|
|
692
707
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
693
|
-
export declare const ${jsxName}:
|
|
708
|
+
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
694
709
|
`
|
|
695
710
|
};
|
|
696
711
|
}
|
|
@@ -720,32 +735,20 @@ type AdditionalHtmlProps = {
|
|
|
720
735
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
721
736
|
}
|
|
722
737
|
|
|
723
|
-
type Polyfill<
|
|
724
|
-
ComponentProps,
|
|
725
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
726
|
-
> &
|
|
727
|
-
AdditionalHtmlProps
|
|
738
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
728
739
|
|
|
729
|
-
type Props<
|
|
730
|
-
Polyfill<ComponentProps>,
|
|
731
|
-
AdditionalProps
|
|
732
|
-
>
|
|
740
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
733
741
|
|
|
734
|
-
export type ${componentName}<
|
|
735
|
-
(
|
|
736
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
737
|
-
): JSX.Element
|
|
742
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
743
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
738
744
|
displayName?: string
|
|
739
745
|
}
|
|
740
746
|
|
|
741
747
|
export type ${upperName} = {
|
|
742
|
-
<
|
|
743
|
-
Component,
|
|
744
|
-
AdditionalProps
|
|
745
|
-
>
|
|
748
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
746
749
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
747
750
|
|
|
748
|
-
export type ${typeName}<
|
|
751
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
749
752
|
`
|
|
750
753
|
};
|
|
751
754
|
}
|
|
@@ -799,7 +802,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
799
802
|
function createJsxFactory() {
|
|
800
803
|
const cache = new Map()
|
|
801
804
|
|
|
802
|
-
return new Proxy(
|
|
805
|
+
return new Proxy(styled, {
|
|
803
806
|
apply(_, __, args) {
|
|
804
807
|
return styled(...args)
|
|
805
808
|
},
|
|
@@ -874,8 +877,8 @@ function generateSolidLayoutGrid() {
|
|
|
874
877
|
var import_outdent15 = require("outdent");
|
|
875
878
|
var import_ts_pattern3 = require("ts-pattern");
|
|
876
879
|
function generate3(ctx, name, pattern) {
|
|
877
|
-
const { upperName, styleFn, dashName, jsxName, props } = ctx.getPatternDetails(name, pattern);
|
|
878
|
-
const {
|
|
880
|
+
const { upperName, styleFn, dashName, jsxName, props, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
881
|
+
const { typeName } = ctx.jsxFactoryDetails;
|
|
879
882
|
return {
|
|
880
883
|
name: dashName,
|
|
881
884
|
js: import_outdent15.outdent`
|
|
@@ -899,11 +902,14 @@ function generate3(ctx, name, pattern) {
|
|
|
899
902
|
}
|
|
900
903
|
`,
|
|
901
904
|
dts: import_outdent15.outdent`
|
|
905
|
+
import { Component } from 'solid-js'
|
|
902
906
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
903
|
-
import { ${
|
|
907
|
+
import { ${typeName} } from '../types/jsx'
|
|
908
|
+
|
|
909
|
+
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'div'>, keyof ${upperName}Properties ${blocklistType}>
|
|
904
910
|
|
|
905
911
|
${pattern.description ? `/** ${pattern.description} */` : ""}
|
|
906
|
-
export declare const ${jsxName}:
|
|
912
|
+
export declare const ${jsxName}: Component<${upperName}Props>
|
|
907
913
|
`
|
|
908
914
|
};
|
|
909
915
|
}
|
|
@@ -926,7 +932,7 @@ import type { JsxStyleProps, Assign } from '.'
|
|
|
926
932
|
|
|
927
933
|
type Dict = Record<string, unknown>
|
|
928
934
|
|
|
929
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P
|
|
935
|
+
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
930
936
|
|
|
931
937
|
type AdditionalHtmlProps = {
|
|
932
938
|
htmlSize?: string | number
|
|
@@ -935,33 +941,20 @@ type AdditionalHtmlProps = {
|
|
|
935
941
|
htmlTranslate?: 'yes' | 'no' | undefined
|
|
936
942
|
}
|
|
937
943
|
|
|
938
|
-
type Polyfill<
|
|
939
|
-
ComponentProps,
|
|
940
|
-
'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'
|
|
941
|
-
> &
|
|
942
|
-
AdditionalHtmlProps
|
|
944
|
+
type Polyfill<T> = Omit<T, 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size'> & AdditionalHtmlProps
|
|
943
945
|
|
|
944
|
-
type Props<
|
|
945
|
-
Polyfill<ComponentProps>,
|
|
946
|
-
AdditionalProps
|
|
947
|
-
>
|
|
946
|
+
type Props<T extends Dict, P extends Dict = {}> = Assign<Polyfill<T>, P>
|
|
948
947
|
|
|
949
|
-
export type ${componentName}<
|
|
950
|
-
(
|
|
951
|
-
props: Props<ComponentProps<ComponentType>, AdditionalProps> & JsxStyleProps<AdditionalProps>,
|
|
952
|
-
): JSX.Element
|
|
948
|
+
export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
949
|
+
(props: Props<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
953
950
|
displayName?: string
|
|
954
951
|
}
|
|
955
952
|
|
|
956
|
-
|
|
957
953
|
export type ${upperName} = {
|
|
958
|
-
<
|
|
959
|
-
Component,
|
|
960
|
-
AdditionalProps
|
|
961
|
-
>
|
|
954
|
+
<T extends ElementType, P extends Dict = {}>(component: T): ${componentName}<T, P>
|
|
962
955
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
963
956
|
|
|
964
|
-
export type ${typeName}<
|
|
957
|
+
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
965
958
|
`
|
|
966
959
|
};
|
|
967
960
|
}
|
|
@@ -1005,33 +998,33 @@ function generateLayoutGrid(ctx) {
|
|
|
1005
998
|
}
|
|
1006
999
|
|
|
1007
1000
|
// src/generators/pattern.ts
|
|
1008
|
-
var
|
|
1001
|
+
var import_shared = require("@pandacss/shared");
|
|
1009
1002
|
var import_outdent17 = require("outdent");
|
|
1010
1003
|
var import_telejson = require("telejson");
|
|
1011
1004
|
var import_ts_pattern4 = require("ts-pattern");
|
|
1012
|
-
function generate4(name, pattern) {
|
|
1005
|
+
function generate4(ctx, name, pattern) {
|
|
1013
1006
|
const { properties, transform, strict, description } = pattern;
|
|
1014
|
-
const upperName = (
|
|
1015
|
-
const upperFn = `get${upperName}Style`;
|
|
1007
|
+
const { upperName, styleFn, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
1016
1008
|
return {
|
|
1017
|
-
name: (0,
|
|
1009
|
+
name: (0, import_shared.dashCase)(name),
|
|
1018
1010
|
dts: import_outdent17.outdent`
|
|
1019
|
-
import { SystemStyleObject, ConditionalValue } from
|
|
1020
|
-
import {
|
|
1021
|
-
import {
|
|
1011
|
+
import { SystemStyleObject, ConditionalValue } from '../types'
|
|
1012
|
+
import { PropertyValue } from '../types/prop-type'
|
|
1013
|
+
import { Properties } from '../types/csstype'
|
|
1014
|
+
import { Tokens } from '../types/token'
|
|
1022
1015
|
|
|
1023
|
-
export type ${(0,
|
|
1016
|
+
export type ${(0, import_shared.capitalize)(name)}Properties = {
|
|
1024
1017
|
${Object.keys(properties ?? {}).map((key) => {
|
|
1025
1018
|
const value = properties[key];
|
|
1026
1019
|
return (0, import_ts_pattern4.match)(value).with({ type: "property" }, (value2) => {
|
|
1027
|
-
return `${key}?:
|
|
1020
|
+
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
1028
1021
|
}).with({ type: "token" }, (value2) => {
|
|
1029
1022
|
if (value2.property) {
|
|
1030
1023
|
return `${key}?: ConditionalValue<Tokens["${value2.value}"] | Properties["${value2.property}"]>`;
|
|
1031
1024
|
}
|
|
1032
1025
|
return `${key}?: ConditionalValue<Tokens["${value2.value}"]>`;
|
|
1033
1026
|
}).with({ type: "enum" }, (value2) => {
|
|
1034
|
-
return `${key}?: ConditionalValue<${(0,
|
|
1027
|
+
return `${key}?: ConditionalValue<${(0, import_shared.unionType)(value2.value)}>`;
|
|
1035
1028
|
}).otherwise(() => {
|
|
1036
1029
|
return `${key}?: ConditionalValue<${value.type}>`;
|
|
1037
1030
|
});
|
|
@@ -1039,39 +1032,43 @@ function generate4(name, pattern) {
|
|
|
1039
1032
|
}
|
|
1040
1033
|
|
|
1041
1034
|
${strict ? import_outdent17.outdent`export declare function ${name}(options: ${upperName}Properties): string` : import_outdent17.outdent`
|
|
1042
|
-
|
|
1035
|
+
|
|
1036
|
+
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
1037
|
+
|
|
1043
1038
|
${description ? `/** ${description} */` : ""}
|
|
1044
|
-
export declare function ${name}(options:
|
|
1039
|
+
export declare function ${name}(options: ${upperName}Options): string
|
|
1045
1040
|
`}
|
|
1046
1041
|
|
|
1047
1042
|
`,
|
|
1048
1043
|
js: import_outdent17.outdent`
|
|
1049
|
-
import { mapObject } from
|
|
1050
|
-
import { css } from
|
|
1044
|
+
import { mapObject } from '../helpers'
|
|
1045
|
+
import { css } from '../css'
|
|
1051
1046
|
|
|
1052
1047
|
const config = ${(0, import_telejson.stringify)({ transform })}
|
|
1053
1048
|
|
|
1054
|
-
export const ${
|
|
1049
|
+
export const ${styleFn} = (styles) => config.transform(styles, { map: mapObject })
|
|
1055
1050
|
|
|
1056
|
-
export const ${name} = (styles) => css(${
|
|
1057
|
-
`.replace(/"_function_([^|]*)\|(.*)"/, "$2").replace(/\\"/g, '"').replace("return", "; return").replace(";;", ";")
|
|
1051
|
+
export const ${name} = (styles) => css(${styleFn}(styles))
|
|
1052
|
+
`.replace(/"_function_([^|]*)\|(.*)"/, "$2").replace(/\\"/g, '"').replace("return", "; return").replace(";;", ";").replace("{;", "{")
|
|
1058
1053
|
};
|
|
1059
1054
|
}
|
|
1060
1055
|
function generatePattern(ctx) {
|
|
1061
1056
|
if (!ctx.hasPatterns)
|
|
1062
1057
|
return;
|
|
1063
|
-
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(name, pattern));
|
|
1058
|
+
return Object.entries(ctx.patterns).map(([name, pattern]) => generate4(ctx, name, pattern));
|
|
1064
1059
|
}
|
|
1065
1060
|
|
|
1066
1061
|
// src/generators/prop-types.ts
|
|
1067
1062
|
var import_outdent18 = require("outdent");
|
|
1068
|
-
function generatePropTypes(utility) {
|
|
1063
|
+
function generatePropTypes(utility, strict) {
|
|
1064
|
+
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1069
1065
|
const result = [
|
|
1070
1066
|
import_outdent18.outdent`
|
|
1067
|
+
import { ConditionalValue } from './conditions';
|
|
1071
1068
|
import { Properties as CSSProperties } from './csstype'
|
|
1072
1069
|
import { Tokens } from './token'
|
|
1073
1070
|
|
|
1074
|
-
type
|
|
1071
|
+
type PropertyValueTypes = {`
|
|
1075
1072
|
];
|
|
1076
1073
|
const types = utility.getTypes();
|
|
1077
1074
|
for (const [prop, values] of types.entries()) {
|
|
@@ -1079,23 +1076,29 @@ function generatePropTypes(utility) {
|
|
|
1079
1076
|
}
|
|
1080
1077
|
result.push("}", "\n");
|
|
1081
1078
|
result.push(`
|
|
1082
|
-
type
|
|
1083
|
-
|
|
1084
|
-
type
|
|
1085
|
-
|
|
1086
|
-
type Shorthand<T> = CssProp<T> | BaseProp<T>
|
|
1079
|
+
type NativeValue<T> = T extends keyof CSSProperties ? CSSProperties[T] : never
|
|
1080
|
+
|
|
1081
|
+
type Shorthand<T> = T extends keyof PropertyValueTypes ? PropertyValueTypes[T]${strictText} : NativeValue<T>
|
|
1087
1082
|
|
|
1088
|
-
export type
|
|
1083
|
+
export type PropertyTypes = PropertyValueTypes & {
|
|
1089
1084
|
`);
|
|
1090
1085
|
utility.shorthands.forEach((value, key) => {
|
|
1091
1086
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1092
1087
|
});
|
|
1093
1088
|
result.push("}");
|
|
1094
|
-
return
|
|
1089
|
+
return import_outdent18.outdent`
|
|
1090
|
+
${result.join("\n")}
|
|
1091
|
+
|
|
1092
|
+
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
1093
|
+
? ConditionalValue<PropertyTypes[T]${strictText}>
|
|
1094
|
+
: T extends keyof CSSProperties
|
|
1095
|
+
? ConditionalValue<CSSProperties[T]>
|
|
1096
|
+
: never
|
|
1097
|
+
`;
|
|
1095
1098
|
}
|
|
1096
1099
|
|
|
1097
1100
|
// src/generators/recipe.ts
|
|
1098
|
-
var
|
|
1101
|
+
var import_shared2 = require("@pandacss/shared");
|
|
1099
1102
|
var import_outdent19 = require("outdent");
|
|
1100
1103
|
function generateRecipes(ctx) {
|
|
1101
1104
|
const { recipes = {}, hash, hasRecipes, utility } = ctx;
|
|
@@ -1146,16 +1149,16 @@ function generateRecipes(ctx) {
|
|
|
1146
1149
|
export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
|
|
1147
1150
|
`);
|
|
1148
1151
|
dts.push(import_outdent19.outdent`
|
|
1149
|
-
export type ${(0,
|
|
1152
|
+
export type ${(0, import_shared2.capitalize)(name)}Variants = {
|
|
1150
1153
|
${Object.keys(variants ?? {}).map((key) => {
|
|
1151
1154
|
const value = variants[key];
|
|
1152
1155
|
const keys = Object.keys(value);
|
|
1153
|
-
return `${key}?: ConditionalValue<${(0,
|
|
1156
|
+
return `${key}?: ConditionalValue<${(0, import_shared2.unionType)(keys)}>`;
|
|
1154
1157
|
}).join("\n")}
|
|
1155
1158
|
}
|
|
1156
1159
|
|
|
1157
1160
|
${description ? `/** ${description} */` : ""}
|
|
1158
|
-
export declare function ${name}(
|
|
1161
|
+
export declare function ${name}(variants?: ${(0, import_shared2.capitalize)(name)}Variants): string
|
|
1159
1162
|
`);
|
|
1160
1163
|
});
|
|
1161
1164
|
return {
|
|
@@ -1338,20 +1341,20 @@ function cleanupSelectors(css2, varSelector) {
|
|
|
1338
1341
|
}
|
|
1339
1342
|
|
|
1340
1343
|
// src/generators/token-dts.ts
|
|
1341
|
-
var
|
|
1344
|
+
var import_shared3 = require("@pandacss/shared");
|
|
1342
1345
|
var import_outdent20 = require("outdent");
|
|
1343
1346
|
var import_pluralize = __toESM(require("pluralize"));
|
|
1344
1347
|
function generateTokenDts(dict) {
|
|
1345
1348
|
const set = /* @__PURE__ */ new Set();
|
|
1346
|
-
set.add(`export type Token = ${dict.isEmpty ? "string" : (0,
|
|
1349
|
+
set.add(`export type Token = ${dict.isEmpty ? "string" : (0, import_shared3.unionType)(dict.allNames)}`);
|
|
1347
1350
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
1348
1351
|
if (dict.isEmpty) {
|
|
1349
1352
|
result.add("[token: string]: string");
|
|
1350
1353
|
} else {
|
|
1351
1354
|
for (const [key, value] of dict.categoryMap.entries()) {
|
|
1352
|
-
const typeName = (0,
|
|
1353
|
-
set.add(`export type ${typeName} = ${(0,
|
|
1354
|
-
set.add(`export type ColorPalette = ${(0,
|
|
1355
|
+
const typeName = (0, import_shared3.capitalize)(import_pluralize.default.singular(key));
|
|
1356
|
+
set.add(`export type ${typeName} = ${(0, import_shared3.unionType)(value.keys())}`);
|
|
1357
|
+
set.add(`export type ColorPalette = ${(0, import_shared3.unionType)(Object.keys(dict.colorPalettes))}`);
|
|
1355
1358
|
result.add(` ${key}: ${typeName}`);
|
|
1356
1359
|
}
|
|
1357
1360
|
}
|
|
@@ -1393,6 +1396,7 @@ function generateTokenJs(dict) {
|
|
|
1393
1396
|
}
|
|
1394
1397
|
|
|
1395
1398
|
// src/generators/types.ts
|
|
1399
|
+
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
1396
1400
|
var import_fs_extra = require("fs-extra");
|
|
1397
1401
|
var import_outdent22 = __toESM(require("outdent"));
|
|
1398
1402
|
function getType(file) {
|
|
@@ -1400,27 +1404,23 @@ function getType(file) {
|
|
|
1400
1404
|
return (0, import_fs_extra.readFileSync)(filepath, "utf8");
|
|
1401
1405
|
}
|
|
1402
1406
|
function generateCssType(ctx) {
|
|
1403
|
-
const
|
|
1404
|
-
const strictArg = strict ? "true" : "false";
|
|
1407
|
+
const propList = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()));
|
|
1405
1408
|
return {
|
|
1406
1409
|
cssType: getType("csstype.d.ts"),
|
|
1407
1410
|
pandaCssType: getType("system-types.d.ts"),
|
|
1411
|
+
selectorType: getType("selectors.d.ts"),
|
|
1408
1412
|
publicType: import_outdent22.default`
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
import { Conditions } from './conditions'
|
|
1412
|
-
|
|
1413
|
-
export type SystemStyleObject<Overrides extends Record<string, unknown> = {}> = System.StyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
|
|
1414
|
-
|
|
1415
|
-
export type GlobalStyleObject<Overrides extends Record<string, unknown> = {}> = System.GlobalStyleObject<Conditions, PropTypes, ${strictArg}, Overrides>
|
|
1416
|
-
|
|
1417
|
-
export type JsxStyleProps<Overrides extends Record<string, unknown> = {}> = System.JsxStyleProps<Conditions, PropTypes, ${strictArg}, Overrides>
|
|
1418
|
-
|
|
1419
|
-
export type ConditionalValue<Value> = System.Conditional<Conditions, Value>
|
|
1420
|
-
|
|
1421
|
-
type DistributiveOmit<T, U> = T extends any ? Pick<T, Exclude<keyof T, U>> : never
|
|
1413
|
+
export { ConditionalValue } from './conditions'
|
|
1414
|
+
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1422
1415
|
|
|
1423
|
-
export type Assign<Target, Override> =
|
|
1416
|
+
export type Assign<Target, Override> = Omit<Target, keyof Override> & Override
|
|
1417
|
+
`,
|
|
1418
|
+
styleProps: import_outdent22.default`
|
|
1419
|
+
import { PropertyValue } from './prop-type'
|
|
1420
|
+
|
|
1421
|
+
export type SystemProperties = {
|
|
1422
|
+
${Array.from(propList).map((v) => ` ${v}?: PropertyValue<'${v}'>`).join("\n")}
|
|
1423
|
+
}
|
|
1424
1424
|
`
|
|
1425
1425
|
};
|
|
1426
1426
|
}
|
|
@@ -1466,9 +1466,11 @@ function setupTypes(ctx) {
|
|
|
1466
1466
|
jsx ? { file: "jsx.d.ts", code: jsx.jsxType } : null,
|
|
1467
1467
|
{ file: "csstype.d.ts", code: code.cssType },
|
|
1468
1468
|
{ file: "system-types.d.ts", code: code.pandaCssType },
|
|
1469
|
+
{ file: "selectors.d.ts", code: code.selectorType },
|
|
1469
1470
|
{ file: "index.d.ts", code: code.publicType },
|
|
1470
1471
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
1471
1472
|
{ file: "prop-type.d.ts", code: generatePropTypes(ctx.utility) },
|
|
1473
|
+
{ file: "style-props.d.ts", code: code.styleProps },
|
|
1472
1474
|
{ file: "conditions.d.ts", code: conditions.dts }
|
|
1473
1475
|
].filter(Boolean)
|
|
1474
1476
|
};
|
|
@@ -1707,7 +1709,7 @@ function getBaseCss(ctx) {
|
|
|
1707
1709
|
var import_core4 = require("@pandacss/core");
|
|
1708
1710
|
var import_error = require("@pandacss/error");
|
|
1709
1711
|
var import_logger5 = require("@pandacss/logger");
|
|
1710
|
-
var
|
|
1712
|
+
var import_shared5 = require("@pandacss/shared");
|
|
1711
1713
|
var import_fs4 = require("fs");
|
|
1712
1714
|
var import_fs_extra3 = require("fs-extra");
|
|
1713
1715
|
var import_path4 = require("path");
|
|
@@ -1718,10 +1720,10 @@ var import_look_it_up = require("look-it-up");
|
|
|
1718
1720
|
|
|
1719
1721
|
// src/context.ts
|
|
1720
1722
|
var import_core3 = require("@pandacss/core");
|
|
1721
|
-
var
|
|
1723
|
+
var import_is_valid_prop3 = require("@pandacss/is-valid-prop");
|
|
1722
1724
|
var import_logger4 = require("@pandacss/logger");
|
|
1723
1725
|
var import_parser = require("@pandacss/parser");
|
|
1724
|
-
var
|
|
1726
|
+
var import_shared4 = require("@pandacss/shared");
|
|
1725
1727
|
var import_token_dictionary = require("@pandacss/token-dictionary");
|
|
1726
1728
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
1727
1729
|
var import_fs3 = require("fs");
|
|
@@ -1732,7 +1734,7 @@ var import_postcss2 = __toESM(require("postcss"));
|
|
|
1732
1734
|
var import_ts_morph = require("ts-morph");
|
|
1733
1735
|
var import_ts_pattern5 = require("ts-pattern");
|
|
1734
1736
|
var helpers = {
|
|
1735
|
-
map:
|
|
1737
|
+
map: import_shared4.mapObject
|
|
1736
1738
|
};
|
|
1737
1739
|
var fileSystem = {
|
|
1738
1740
|
read: (path) => {
|
|
@@ -1774,9 +1776,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
1774
1776
|
} = theme;
|
|
1775
1777
|
const jsxFactoryDetails = {
|
|
1776
1778
|
name: jsxFactory,
|
|
1777
|
-
upperName: (0,
|
|
1778
|
-
typeName: `HTML${(0,
|
|
1779
|
-
componentName: `${(0,
|
|
1779
|
+
upperName: (0, import_shared4.capitalize)(jsxFactory),
|
|
1780
|
+
typeName: `HTML${(0, import_shared4.capitalize)(jsxFactory)}Props`,
|
|
1781
|
+
componentName: `${(0, import_shared4.capitalize)(jsxFactory)}Component`,
|
|
1780
1782
|
framework: jsxFramework
|
|
1781
1783
|
};
|
|
1782
1784
|
const cwd = (0, import_path2.resolve)(cwdProp);
|
|
@@ -1800,7 +1802,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1800
1802
|
import_logger4.logger.debug({ type: "ctx:conditions", msg: conditions });
|
|
1801
1803
|
(0, import_core3.assignCompositions)(
|
|
1802
1804
|
{ conditions, utility },
|
|
1803
|
-
(0,
|
|
1805
|
+
(0, import_shared4.compact)({
|
|
1804
1806
|
textStyle: textStyles,
|
|
1805
1807
|
layerStyle: layerStyles
|
|
1806
1808
|
})
|
|
@@ -1820,24 +1822,25 @@ function createContext(conf, io = fileSystem) {
|
|
|
1820
1822
|
return pattern?.transform?.(data, helpers) ?? {};
|
|
1821
1823
|
}
|
|
1822
1824
|
function getPatternDetails(name, pattern) {
|
|
1823
|
-
const upperName = (0,
|
|
1825
|
+
const upperName = (0, import_shared4.capitalize)(name);
|
|
1824
1826
|
return {
|
|
1825
1827
|
name,
|
|
1826
1828
|
props: Object.keys(pattern?.properties ?? {}),
|
|
1827
|
-
dashName: (0,
|
|
1829
|
+
dashName: (0, import_shared4.dashCase)(name),
|
|
1828
1830
|
upperName,
|
|
1829
1831
|
styleFn: `get${upperName}Style`,
|
|
1830
|
-
jsxName: pattern?.jsx ?? upperName
|
|
1832
|
+
jsxName: pattern?.jsx ?? upperName,
|
|
1833
|
+
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : ""
|
|
1831
1834
|
};
|
|
1832
1835
|
}
|
|
1833
1836
|
const patternNodes = Object.entries(patterns).map(([name, pattern]) => ({
|
|
1834
1837
|
type: "pattern",
|
|
1835
|
-
name: pattern.jsx ?? (0,
|
|
1838
|
+
name: pattern.jsx ?? (0, import_shared4.capitalize)(name),
|
|
1836
1839
|
props: Object.keys(pattern.properties),
|
|
1837
1840
|
baseName: name
|
|
1838
1841
|
}));
|
|
1839
1842
|
function getPatternFnName(jsx) {
|
|
1840
|
-
return patternNodes.find((node) => node.name === jsx)?.baseName ?? (0,
|
|
1843
|
+
return patternNodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared4.uncapitalize)(jsx);
|
|
1841
1844
|
}
|
|
1842
1845
|
const hasPatterns = Object.keys(patterns).length > 0;
|
|
1843
1846
|
function getRecipe(name) {
|
|
@@ -1845,18 +1848,18 @@ function createContext(conf, io = fileSystem) {
|
|
|
1845
1848
|
}
|
|
1846
1849
|
const recipeNodes = Object.entries(recipes).map(([name, recipe]) => ({
|
|
1847
1850
|
type: "recipe",
|
|
1848
|
-
name: recipe.jsx ?? (0,
|
|
1851
|
+
name: recipe.jsx ?? (0, import_shared4.capitalize)(name),
|
|
1849
1852
|
props: Object.keys(recipe.variants ?? {}),
|
|
1850
1853
|
baseName: name
|
|
1851
1854
|
}));
|
|
1852
1855
|
function getRecipeFnName(jsx) {
|
|
1853
|
-
return recipeNodes.find((node) => node.name === jsx)?.baseName ?? (0,
|
|
1856
|
+
return recipeNodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared4.uncapitalize)(jsx);
|
|
1854
1857
|
}
|
|
1855
1858
|
function splitRecipeProps(name, props) {
|
|
1856
1859
|
const recipe = recipeNodes.find((node) => node.name === name);
|
|
1857
1860
|
if (!recipe)
|
|
1858
1861
|
return [{}, props];
|
|
1859
|
-
return (0,
|
|
1862
|
+
return (0, import_shared4.splitObject)(props, (key) => recipe.props.includes(key));
|
|
1860
1863
|
}
|
|
1861
1864
|
function getRecipeDetails() {
|
|
1862
1865
|
return Object.entries(recipes).map(([name, recipe]) => ({
|
|
@@ -1872,7 +1875,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1872
1875
|
return regex.test(prop);
|
|
1873
1876
|
}
|
|
1874
1877
|
function isStyleProp(prop) {
|
|
1875
|
-
return (0,
|
|
1878
|
+
return (0, import_is_valid_prop3.isCssProperty)(prop) || isCustomCssProperty(prop);
|
|
1876
1879
|
}
|
|
1877
1880
|
function getPath(...str) {
|
|
1878
1881
|
return (0, import_path2.join)(cwd, outdir, ...str);
|
|
@@ -2200,7 +2203,7 @@ function getConfigHash() {
|
|
|
2200
2203
|
if (!file) {
|
|
2201
2204
|
throw new import_error.ConfigNotFoundError();
|
|
2202
2205
|
}
|
|
2203
|
-
return (0,
|
|
2206
|
+
return (0, import_shared5.toHash)((0, import_fs4.readFileSync)(file, "utf-8"));
|
|
2204
2207
|
}
|
|
2205
2208
|
var setupCount = 0;
|
|
2206
2209
|
var Builder = class {
|