@pandacss/generator 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +37 -44
- package/dist/index.mjs +37 -44
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -629,7 +629,7 @@ function generateCssFn(ctx) {
|
|
|
629
629
|
import type { SystemStyleObject } from '../types'
|
|
630
630
|
|
|
631
631
|
interface CssFunction {
|
|
632
|
-
(styles: SystemStyleObject): string
|
|
632
|
+
(...styles: SystemStyleObject[]): string
|
|
633
633
|
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
634
634
|
}
|
|
635
635
|
|
|
@@ -696,12 +696,7 @@ function generateCssFn(ctx) {
|
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
const cssFn = createCss(context)
|
|
699
|
-
export const
|
|
700
|
-
export const css = (styles) => {
|
|
701
|
-
const classNames = cssFn(styles)
|
|
702
|
-
cssCache.set(classNames, styles)
|
|
703
|
-
return classNames
|
|
704
|
-
}
|
|
699
|
+
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
705
700
|
css.raw = (styles) => styles
|
|
706
701
|
|
|
707
702
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
@@ -767,7 +762,7 @@ function generateCvaFn(ctx) {
|
|
|
767
762
|
export function cva(config) {
|
|
768
763
|
const { base = {}, variants = {}, defaultVariants = {}, compoundVariants = [] } = config
|
|
769
764
|
|
|
770
|
-
function resolve(props) {
|
|
765
|
+
function resolve(props = {}) {
|
|
771
766
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
772
767
|
let variantCss = { ...base }
|
|
773
768
|
for (const [key, value] of Object.entries(computedVariants)) {
|
|
@@ -782,7 +777,7 @@ function generateCvaFn(ctx) {
|
|
|
782
777
|
function cvaFn(props) {
|
|
783
778
|
return css(resolve(props))
|
|
784
779
|
}
|
|
785
|
-
|
|
780
|
+
|
|
786
781
|
const variantKeys = Object.keys(variants)
|
|
787
782
|
|
|
788
783
|
function splitVariantProps(props) {
|
|
@@ -795,7 +790,7 @@ function generateCvaFn(ctx) {
|
|
|
795
790
|
__cva__: true,
|
|
796
791
|
variantMap,
|
|
797
792
|
variantKeys,
|
|
798
|
-
resolve,
|
|
793
|
+
raw: resolve,
|
|
799
794
|
config,
|
|
800
795
|
splitVariantProps,
|
|
801
796
|
})
|
|
@@ -823,7 +818,7 @@ function generateCvaFn(ctx) {
|
|
|
823
818
|
if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
|
|
824
819
|
throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
|
|
825
820
|
}
|
|
826
|
-
}
|
|
821
|
+
}
|
|
827
822
|
|
|
828
823
|
`,
|
|
829
824
|
dts: import_outdent6.outdent`
|
|
@@ -839,32 +834,21 @@ function generateCvaFn(ctx) {
|
|
|
839
834
|
|
|
840
835
|
// src/artifacts/js/cx.ts
|
|
841
836
|
var import_outdent7 = __toESM(require("outdent"));
|
|
842
|
-
function generateCx(
|
|
837
|
+
function generateCx() {
|
|
843
838
|
return {
|
|
844
839
|
js: import_outdent7.default`
|
|
845
|
-
${ctx.file.import("cssCache, css, mergeCss", "./css")}
|
|
846
|
-
|
|
847
840
|
function cx() {
|
|
848
|
-
const objs = []
|
|
849
841
|
let str = '',
|
|
850
842
|
i = 0,
|
|
851
843
|
arg
|
|
852
844
|
|
|
853
845
|
for (; i < arguments.length; ) {
|
|
854
|
-
arg = arguments[i++]
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
if (cssCache.has(arg)) {
|
|
858
|
-
objs.push(cssCache.get(arg))
|
|
859
|
-
continue
|
|
846
|
+
if ((arg = arguments[i++]) && typeof arg === 'string') {
|
|
847
|
+
str && (str += ' ')
|
|
848
|
+
str += arg
|
|
860
849
|
}
|
|
861
|
-
|
|
862
|
-
str && (str += ' ')
|
|
863
|
-
str += arg.toString()
|
|
864
850
|
}
|
|
865
|
-
|
|
866
|
-
const merged = mergeCss(...objs)
|
|
867
|
-
return [css(merged), str].join(' ')
|
|
851
|
+
return str
|
|
868
852
|
}
|
|
869
853
|
|
|
870
854
|
export { cx }
|
|
@@ -1003,7 +987,7 @@ function generatePattern(ctx) {
|
|
|
1003
987
|
|
|
1004
988
|
interface ${upperName}PatternFn {
|
|
1005
989
|
(styles?: ${upperName}Styles): string
|
|
1006
|
-
raw: (styles: ${upperName}Styles) =>
|
|
990
|
+
raw: (styles: ${upperName}Styles) => SystemStyleObject
|
|
1007
991
|
}
|
|
1008
992
|
|
|
1009
993
|
${description ? `/** ${description} */` : ""}
|
|
@@ -1021,7 +1005,7 @@ transform`)}
|
|
|
1021
1005
|
export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
|
|
1022
1006
|
|
|
1023
1007
|
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
1024
|
-
${baseName}.raw =
|
|
1008
|
+
${baseName}.raw = ${styleFnName}
|
|
1025
1009
|
`
|
|
1026
1010
|
};
|
|
1027
1011
|
});
|
|
@@ -1187,7 +1171,7 @@ var import_outdent12 = require("outdent");
|
|
|
1187
1171
|
function generateSvaFn(ctx) {
|
|
1188
1172
|
return {
|
|
1189
1173
|
js: import_outdent12.outdent`
|
|
1190
|
-
${ctx.file.import("getSlotRecipes", "../helpers")}
|
|
1174
|
+
${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
|
|
1191
1175
|
${ctx.file.import("cva", "./cva")}
|
|
1192
1176
|
|
|
1193
1177
|
export function sva(config) {
|
|
@@ -1198,13 +1182,22 @@ function generateSvaFn(ctx) {
|
|
|
1198
1182
|
return Object.fromEntries(result)
|
|
1199
1183
|
}
|
|
1200
1184
|
|
|
1201
|
-
const
|
|
1185
|
+
const variants = config.variants ?? {};
|
|
1186
|
+
const variantKeys = Object.keys(variants);
|
|
1187
|
+
|
|
1188
|
+
function splitVariantProps(props) {
|
|
1189
|
+
return splitProps(props, variantKeys);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
const variantMap = Object.fromEntries(
|
|
1193
|
+
Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
|
|
1194
|
+
);
|
|
1202
1195
|
|
|
1203
1196
|
return Object.assign(svaFn, {
|
|
1204
1197
|
__cva__: false,
|
|
1205
|
-
variantMap
|
|
1206
|
-
variantKeys
|
|
1207
|
-
splitVariantProps
|
|
1198
|
+
variantMap,
|
|
1199
|
+
variantKeys,
|
|
1200
|
+
splitVariantProps,
|
|
1208
1201
|
})
|
|
1209
1202
|
}
|
|
1210
1203
|
`,
|
|
@@ -1285,7 +1278,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1285
1278
|
|
|
1286
1279
|
function cvaClass() {
|
|
1287
1280
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1288
|
-
const cvaStyles = cvaFn.
|
|
1281
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1289
1282
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1290
1283
|
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1291
1284
|
}
|
|
@@ -1527,7 +1520,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1527
1520
|
}
|
|
1528
1521
|
|
|
1529
1522
|
function cvaClass() {
|
|
1530
|
-
const cvaStyles = cvaFn.
|
|
1523
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1531
1524
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1532
1525
|
return cx(css(styles), elementProps.class)
|
|
1533
1526
|
}
|
|
@@ -1779,7 +1772,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1779
1772
|
|
|
1780
1773
|
function cvaClass() {
|
|
1781
1774
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1782
|
-
const cvaStyles = cvaFn.
|
|
1775
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1783
1776
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1784
1777
|
return cx(css(styles), elementProps.className)
|
|
1785
1778
|
}`;
|
|
@@ -1794,7 +1787,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1794
1787
|
}
|
|
1795
1788
|
|
|
1796
1789
|
function cvaClass() {
|
|
1797
|
-
const cvaStyles = cvaFn.
|
|
1790
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1798
1791
|
const styles = assignCss(cvaStyles, elementProps.css)
|
|
1799
1792
|
return cx(css(styles), elementProps.className)
|
|
1800
1793
|
}`;
|
|
@@ -1809,7 +1802,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1809
1802
|
}
|
|
1810
1803
|
|
|
1811
1804
|
function cvaClass() {
|
|
1812
|
-
const cvaStyles = cvaFn.
|
|
1805
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1813
1806
|
const styles = assignCss(cvaStyles)
|
|
1814
1807
|
return cx(css(styles), elementProps.className)
|
|
1815
1808
|
}`;
|
|
@@ -2065,7 +2058,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2065
2058
|
|
|
2066
2059
|
function cvaClass() {
|
|
2067
2060
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2068
|
-
const cvaStyles = cvaFn.
|
|
2061
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
2069
2062
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
2070
2063
|
return cx(css(styles), localProps.class)
|
|
2071
2064
|
}
|
|
@@ -2904,7 +2897,7 @@ var composition_d_ts_default = {
|
|
|
2904
2897
|
|
|
2905
2898
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2906
2899
|
var recipe_d_ts_default = {
|
|
2907
|
-
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n
|
|
2900
|
+
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type RecipeDefinition<T extends RecipeVariantRecord> = {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | RecipeVariantRecord\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype RecipeConfigMeta = {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & RecipeConfigMeta\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> = {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | SlotRecipeVariantRecord<S>\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<SlotRecipeCompoundVariant<S, T>>\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
|
|
2908
2901
|
};
|
|
2909
2902
|
|
|
2910
2903
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -3078,8 +3071,8 @@ function generateTokenTypes(ctx) {
|
|
|
3078
3071
|
set.add(`export type ${typeName}Token = ${(0, import_shared3.unionType)(value.keys())}`);
|
|
3079
3072
|
result.add(` ${key}: ${typeName}Token`);
|
|
3080
3073
|
}
|
|
3081
|
-
|
|
3082
|
-
|
|
3074
|
+
if (theme?.keyframes)
|
|
3075
|
+
set.add(`export type AnimationName = ${(0, import_shared3.unionType)(Object.keys(theme.keyframes))}`);
|
|
3083
3076
|
result.add(` animationName: AnimationName`);
|
|
3084
3077
|
}
|
|
3085
3078
|
result.add("} & { [token: string]: never }");
|
|
@@ -3179,7 +3172,7 @@ function setupSva(ctx) {
|
|
|
3179
3172
|
};
|
|
3180
3173
|
}
|
|
3181
3174
|
function setupCx(ctx) {
|
|
3182
|
-
const code = generateCx(
|
|
3175
|
+
const code = generateCx();
|
|
3183
3176
|
return {
|
|
3184
3177
|
dir: ctx.paths.css,
|
|
3185
3178
|
files: [
|
package/dist/index.mjs
CHANGED
|
@@ -598,7 +598,7 @@ function generateCssFn(ctx) {
|
|
|
598
598
|
import type { SystemStyleObject } from '../types'
|
|
599
599
|
|
|
600
600
|
interface CssFunction {
|
|
601
|
-
(styles: SystemStyleObject): string
|
|
601
|
+
(...styles: SystemStyleObject[]): string
|
|
602
602
|
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
603
603
|
}
|
|
604
604
|
|
|
@@ -665,12 +665,7 @@ function generateCssFn(ctx) {
|
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
const cssFn = createCss(context)
|
|
668
|
-
export const
|
|
669
|
-
export const css = (styles) => {
|
|
670
|
-
const classNames = cssFn(styles)
|
|
671
|
-
cssCache.set(classNames, styles)
|
|
672
|
-
return classNames
|
|
673
|
-
}
|
|
668
|
+
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
674
669
|
css.raw = (styles) => styles
|
|
675
670
|
|
|
676
671
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
@@ -736,7 +731,7 @@ function generateCvaFn(ctx) {
|
|
|
736
731
|
export function cva(config) {
|
|
737
732
|
const { base = {}, variants = {}, defaultVariants = {}, compoundVariants = [] } = config
|
|
738
733
|
|
|
739
|
-
function resolve(props) {
|
|
734
|
+
function resolve(props = {}) {
|
|
740
735
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
741
736
|
let variantCss = { ...base }
|
|
742
737
|
for (const [key, value] of Object.entries(computedVariants)) {
|
|
@@ -751,7 +746,7 @@ function generateCvaFn(ctx) {
|
|
|
751
746
|
function cvaFn(props) {
|
|
752
747
|
return css(resolve(props))
|
|
753
748
|
}
|
|
754
|
-
|
|
749
|
+
|
|
755
750
|
const variantKeys = Object.keys(variants)
|
|
756
751
|
|
|
757
752
|
function splitVariantProps(props) {
|
|
@@ -764,7 +759,7 @@ function generateCvaFn(ctx) {
|
|
|
764
759
|
__cva__: true,
|
|
765
760
|
variantMap,
|
|
766
761
|
variantKeys,
|
|
767
|
-
resolve,
|
|
762
|
+
raw: resolve,
|
|
768
763
|
config,
|
|
769
764
|
splitVariantProps,
|
|
770
765
|
})
|
|
@@ -792,7 +787,7 @@ function generateCvaFn(ctx) {
|
|
|
792
787
|
if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
|
|
793
788
|
throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
|
|
794
789
|
}
|
|
795
|
-
}
|
|
790
|
+
}
|
|
796
791
|
|
|
797
792
|
`,
|
|
798
793
|
dts: outdent6`
|
|
@@ -808,32 +803,21 @@ function generateCvaFn(ctx) {
|
|
|
808
803
|
|
|
809
804
|
// src/artifacts/js/cx.ts
|
|
810
805
|
import outdent7 from "outdent";
|
|
811
|
-
function generateCx(
|
|
806
|
+
function generateCx() {
|
|
812
807
|
return {
|
|
813
808
|
js: outdent7`
|
|
814
|
-
${ctx.file.import("cssCache, css, mergeCss", "./css")}
|
|
815
|
-
|
|
816
809
|
function cx() {
|
|
817
|
-
const objs = []
|
|
818
810
|
let str = '',
|
|
819
811
|
i = 0,
|
|
820
812
|
arg
|
|
821
813
|
|
|
822
814
|
for (; i < arguments.length; ) {
|
|
823
|
-
arg = arguments[i++]
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
if (cssCache.has(arg)) {
|
|
827
|
-
objs.push(cssCache.get(arg))
|
|
828
|
-
continue
|
|
815
|
+
if ((arg = arguments[i++]) && typeof arg === 'string') {
|
|
816
|
+
str && (str += ' ')
|
|
817
|
+
str += arg
|
|
829
818
|
}
|
|
830
|
-
|
|
831
|
-
str && (str += ' ')
|
|
832
|
-
str += arg.toString()
|
|
833
819
|
}
|
|
834
|
-
|
|
835
|
-
const merged = mergeCss(...objs)
|
|
836
|
-
return [css(merged), str].join(' ')
|
|
820
|
+
return str
|
|
837
821
|
}
|
|
838
822
|
|
|
839
823
|
export { cx }
|
|
@@ -972,7 +956,7 @@ function generatePattern(ctx) {
|
|
|
972
956
|
|
|
973
957
|
interface ${upperName}PatternFn {
|
|
974
958
|
(styles?: ${upperName}Styles): string
|
|
975
|
-
raw: (styles: ${upperName}Styles) =>
|
|
959
|
+
raw: (styles: ${upperName}Styles) => SystemStyleObject
|
|
976
960
|
}
|
|
977
961
|
|
|
978
962
|
${description ? `/** ${description} */` : ""}
|
|
@@ -990,7 +974,7 @@ transform`)}
|
|
|
990
974
|
export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
|
|
991
975
|
|
|
992
976
|
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
993
|
-
${baseName}.raw =
|
|
977
|
+
${baseName}.raw = ${styleFnName}
|
|
994
978
|
`
|
|
995
979
|
};
|
|
996
980
|
});
|
|
@@ -1156,7 +1140,7 @@ import { outdent as outdent12 } from "outdent";
|
|
|
1156
1140
|
function generateSvaFn(ctx) {
|
|
1157
1141
|
return {
|
|
1158
1142
|
js: outdent12`
|
|
1159
|
-
${ctx.file.import("getSlotRecipes", "../helpers")}
|
|
1143
|
+
${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
|
|
1160
1144
|
${ctx.file.import("cva", "./cva")}
|
|
1161
1145
|
|
|
1162
1146
|
export function sva(config) {
|
|
@@ -1167,13 +1151,22 @@ function generateSvaFn(ctx) {
|
|
|
1167
1151
|
return Object.fromEntries(result)
|
|
1168
1152
|
}
|
|
1169
1153
|
|
|
1170
|
-
const
|
|
1154
|
+
const variants = config.variants ?? {};
|
|
1155
|
+
const variantKeys = Object.keys(variants);
|
|
1156
|
+
|
|
1157
|
+
function splitVariantProps(props) {
|
|
1158
|
+
return splitProps(props, variantKeys);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
const variantMap = Object.fromEntries(
|
|
1162
|
+
Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
|
|
1163
|
+
);
|
|
1171
1164
|
|
|
1172
1165
|
return Object.assign(svaFn, {
|
|
1173
1166
|
__cva__: false,
|
|
1174
|
-
variantMap
|
|
1175
|
-
variantKeys
|
|
1176
|
-
splitVariantProps
|
|
1167
|
+
variantMap,
|
|
1168
|
+
variantKeys,
|
|
1169
|
+
splitVariantProps,
|
|
1177
1170
|
})
|
|
1178
1171
|
}
|
|
1179
1172
|
`,
|
|
@@ -1254,7 +1247,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1254
1247
|
|
|
1255
1248
|
function cvaClass() {
|
|
1256
1249
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1257
|
-
const cvaStyles = cvaFn.
|
|
1250
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1258
1251
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1259
1252
|
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1260
1253
|
}
|
|
@@ -1496,7 +1489,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1496
1489
|
}
|
|
1497
1490
|
|
|
1498
1491
|
function cvaClass() {
|
|
1499
|
-
const cvaStyles = cvaFn.
|
|
1492
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1500
1493
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1501
1494
|
return cx(css(styles), elementProps.class)
|
|
1502
1495
|
}
|
|
@@ -1748,7 +1741,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1748
1741
|
|
|
1749
1742
|
function cvaClass() {
|
|
1750
1743
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1751
|
-
const cvaStyles = cvaFn.
|
|
1744
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1752
1745
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1753
1746
|
return cx(css(styles), elementProps.className)
|
|
1754
1747
|
}`;
|
|
@@ -1763,7 +1756,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1763
1756
|
}
|
|
1764
1757
|
|
|
1765
1758
|
function cvaClass() {
|
|
1766
|
-
const cvaStyles = cvaFn.
|
|
1759
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1767
1760
|
const styles = assignCss(cvaStyles, elementProps.css)
|
|
1768
1761
|
return cx(css(styles), elementProps.className)
|
|
1769
1762
|
}`;
|
|
@@ -1778,7 +1771,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1778
1771
|
}
|
|
1779
1772
|
|
|
1780
1773
|
function cvaClass() {
|
|
1781
|
-
const cvaStyles = cvaFn.
|
|
1774
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
1782
1775
|
const styles = assignCss(cvaStyles)
|
|
1783
1776
|
return cx(css(styles), elementProps.className)
|
|
1784
1777
|
}`;
|
|
@@ -2034,7 +2027,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2034
2027
|
|
|
2035
2028
|
function cvaClass() {
|
|
2036
2029
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2037
|
-
const cvaStyles = cvaFn.
|
|
2030
|
+
const cvaStyles = cvaFn.raw(variantProps)
|
|
2038
2031
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
2039
2032
|
return cx(css(styles), localProps.class)
|
|
2040
2033
|
}
|
|
@@ -2873,7 +2866,7 @@ var composition_d_ts_default = {
|
|
|
2873
2866
|
|
|
2874
2867
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2875
2868
|
var recipe_d_ts_default = {
|
|
2876
|
-
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n
|
|
2869
|
+
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]>\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type RecipeDefinition<T extends RecipeVariantRecord> = {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | RecipeVariantRecord\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype RecipeConfigMeta = {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & RecipeConfigMeta\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> = {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | SlotRecipeVariantRecord<S>\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Array<SlotRecipeCompoundVariant<S, T>>\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
|
|
2877
2870
|
};
|
|
2878
2871
|
|
|
2879
2872
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -3047,8 +3040,8 @@ function generateTokenTypes(ctx) {
|
|
|
3047
3040
|
set.add(`export type ${typeName}Token = ${unionType3(value.keys())}`);
|
|
3048
3041
|
result.add(` ${key}: ${typeName}Token`);
|
|
3049
3042
|
}
|
|
3050
|
-
|
|
3051
|
-
|
|
3043
|
+
if (theme?.keyframes)
|
|
3044
|
+
set.add(`export type AnimationName = ${unionType3(Object.keys(theme.keyframes))}`);
|
|
3052
3045
|
result.add(` animationName: AnimationName`);
|
|
3053
3046
|
}
|
|
3054
3047
|
result.add("} & { [token: string]: never }");
|
|
@@ -3148,7 +3141,7 @@ function setupSva(ctx) {
|
|
|
3148
3141
|
};
|
|
3149
3142
|
}
|
|
3150
3143
|
function setupCx(ctx) {
|
|
3151
|
-
const code = generateCx(
|
|
3144
|
+
const code = generateCx();
|
|
3152
3145
|
return {
|
|
3153
3146
|
dir: ctx.paths.css,
|
|
3154
3147
|
files: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"pluralize": "8.0.0",
|
|
21
21
|
"postcss": "8.4.27",
|
|
22
22
|
"ts-pattern": "5.0.4",
|
|
23
|
-
"@pandacss/core": "0.12.
|
|
24
|
-
"@pandacss/is-valid-prop": "0.12.
|
|
25
|
-
"@pandacss/logger": "0.12.
|
|
26
|
-
"@pandacss/shared": "0.12.
|
|
27
|
-
"@pandacss/token-dictionary": "0.12.
|
|
28
|
-
"@pandacss/types": "0.12.
|
|
23
|
+
"@pandacss/core": "0.12.2",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.12.2",
|
|
25
|
+
"@pandacss/logger": "0.12.2",
|
|
26
|
+
"@pandacss/shared": "0.12.2",
|
|
27
|
+
"@pandacss/token-dictionary": "0.12.2",
|
|
28
|
+
"@pandacss/types": "0.12.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.30",
|
|
32
32
|
"hookable": "5.5.3",
|
|
33
|
-
"@pandacss/fixture": "0.12.
|
|
33
|
+
"@pandacss/fixture": "0.12.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|