@pandacss/generator 0.13.1 → 0.14.0
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 +26 -14
- package/dist/index.mjs +26 -14
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -558,7 +558,9 @@ function generateConditions(ctx) {
|
|
|
558
558
|
${ctx.file.importType("AnySelector, Selectors", "./selectors")}
|
|
559
559
|
|
|
560
560
|
export type Conditions = {
|
|
561
|
-
${keys.map(
|
|
561
|
+
${keys.map(
|
|
562
|
+
(key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */` : ctx.conditions.get(key) ? `/** \`${ctx.conditions.get(key)}\` */` : ""}${JSON.stringify(key)}: string`
|
|
563
|
+
).join("\n")}
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
export type Condition = keyof Conditions
|
|
@@ -629,8 +631,8 @@ function generateCssFn(ctx) {
|
|
|
629
631
|
${ctx.file.importType("SystemStyleObject", "../types/index")}
|
|
630
632
|
|
|
631
633
|
interface CssFunction {
|
|
632
|
-
(...styles: SystemStyleObject
|
|
633
|
-
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
634
|
+
(...styles: Array<SystemStyleObject | undefined | null | false>): string
|
|
635
|
+
raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
|
|
634
636
|
}
|
|
635
637
|
|
|
636
638
|
export declare const css: CssFunction;
|
|
@@ -697,7 +699,7 @@ function generateCssFn(ctx) {
|
|
|
697
699
|
|
|
698
700
|
const cssFn = createCss(context)
|
|
699
701
|
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
700
|
-
css.raw = (styles) => styles
|
|
702
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
701
703
|
|
|
702
704
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
703
705
|
`
|
|
@@ -986,7 +988,7 @@ function generatePattern(ctx) {
|
|
|
986
988
|
|
|
987
989
|
interface ${upperName}PatternFn {
|
|
988
990
|
(styles?: ${upperName}Styles): string
|
|
989
|
-
raw: (styles
|
|
991
|
+
raw: (styles?: ${upperName}Styles) => SystemStyleObject
|
|
990
992
|
}
|
|
991
993
|
|
|
992
994
|
${description ? `/** ${description} */` : ""}
|
|
@@ -1175,12 +1177,17 @@ function generateSvaFn(ctx) {
|
|
|
1175
1177
|
|
|
1176
1178
|
export function sva(config) {
|
|
1177
1179
|
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1178
|
-
|
|
1180
|
+
|
|
1179
1181
|
function svaFn(props) {
|
|
1180
1182
|
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1181
1183
|
return Object.fromEntries(result)
|
|
1182
1184
|
}
|
|
1183
1185
|
|
|
1186
|
+
function raw(props) {
|
|
1187
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
|
|
1188
|
+
return Object.fromEntries(result)
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1184
1191
|
const variants = config.variants ?? {};
|
|
1185
1192
|
const variantKeys = Object.keys(variants);
|
|
1186
1193
|
|
|
@@ -1194,6 +1201,7 @@ function generateSvaFn(ctx) {
|
|
|
1194
1201
|
|
|
1195
1202
|
return Object.assign(svaFn, {
|
|
1196
1203
|
__cva__: false,
|
|
1204
|
+
raw,
|
|
1197
1205
|
variantMap,
|
|
1198
1206
|
variantKeys,
|
|
1199
1207
|
splitVariantProps,
|
|
@@ -2899,7 +2907,7 @@ var composition_d_ts_default = {
|
|
|
2899
2907
|
|
|
2900
2908
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2901
2909
|
var recipe_d_ts_default = {
|
|
2902
|
-
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"
|
|
2910
|
+
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 raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\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"
|
|
2903
2911
|
};
|
|
2904
2912
|
|
|
2905
2913
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2958,9 +2966,12 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2958
2966
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2959
2967
|
}
|
|
2960
2968
|
`,
|
|
2969
|
+
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
|
|
2961
2970
|
index: import_outdent39.outdent`
|
|
2962
2971
|
import '${ctx.file.extDts("./global")}'
|
|
2963
2972
|
${ctx.file.exportType("ConditionalValue", "./conditions")}
|
|
2973
|
+
${ctx.file.exportType("PatternConfig, PatternProperties", "./pattern")}
|
|
2974
|
+
${ctx.file.exportType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
2964
2975
|
${ctx.file.exportType("GlobalStyleObject, JsxStyleProps, SystemStyleObject", "./system-types")}
|
|
2965
2976
|
|
|
2966
2977
|
`,
|
|
@@ -3005,9 +3016,9 @@ function generatePropTypes(ctx) {
|
|
|
3005
3016
|
${result.join("\n")}
|
|
3006
3017
|
|
|
3007
3018
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
3008
|
-
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
3019
|
+
? ConditionalValue<PropertyTypes[T]${strictText}${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
3009
3020
|
: T extends keyof CssProperties
|
|
3010
|
-
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
3021
|
+
? ConditionalValue<CssProperties[T]${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
3011
3022
|
: ConditionalValue<string | number>
|
|
3012
3023
|
`;
|
|
3013
3024
|
}
|
|
@@ -3242,12 +3253,12 @@ function setupJsx(ctx) {
|
|
|
3242
3253
|
`,
|
|
3243
3254
|
dts: import_outdent43.default`
|
|
3244
3255
|
${ctx.file.exportTypeStar("./factory")}
|
|
3245
|
-
|
|
3256
|
+
|
|
3246
3257
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3247
|
-
|
|
3258
|
+
|
|
3248
3259
|
${import_outdent43.default.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3249
|
-
|
|
3250
|
-
${ctx.file.exportType(ctx.jsx.typeName, "../types/jsx")}
|
|
3260
|
+
|
|
3261
|
+
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3251
3262
|
`
|
|
3252
3263
|
};
|
|
3253
3264
|
return {
|
|
@@ -3486,7 +3497,8 @@ var getBaseEngine = (conf) => {
|
|
|
3486
3497
|
tokens,
|
|
3487
3498
|
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3488
3499
|
separator: config.separator,
|
|
3489
|
-
shorthands: config.shorthands
|
|
3500
|
+
shorthands: config.shorthands,
|
|
3501
|
+
strictTokens: config.strictTokens
|
|
3490
3502
|
});
|
|
3491
3503
|
const conditions = new import_core5.Conditions({
|
|
3492
3504
|
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
package/dist/index.mjs
CHANGED
|
@@ -527,7 +527,9 @@ function generateConditions(ctx) {
|
|
|
527
527
|
${ctx.file.importType("AnySelector, Selectors", "./selectors")}
|
|
528
528
|
|
|
529
529
|
export type Conditions = {
|
|
530
|
-
${keys.map(
|
|
530
|
+
${keys.map(
|
|
531
|
+
(key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */` : ctx.conditions.get(key) ? `/** \`${ctx.conditions.get(key)}\` */` : ""}${JSON.stringify(key)}: string`
|
|
532
|
+
).join("\n")}
|
|
531
533
|
}
|
|
532
534
|
|
|
533
535
|
export type Condition = keyof Conditions
|
|
@@ -598,8 +600,8 @@ function generateCssFn(ctx) {
|
|
|
598
600
|
${ctx.file.importType("SystemStyleObject", "../types/index")}
|
|
599
601
|
|
|
600
602
|
interface CssFunction {
|
|
601
|
-
(...styles: SystemStyleObject
|
|
602
|
-
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
603
|
+
(...styles: Array<SystemStyleObject | undefined | null | false>): string
|
|
604
|
+
raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
|
|
603
605
|
}
|
|
604
606
|
|
|
605
607
|
export declare const css: CssFunction;
|
|
@@ -666,7 +668,7 @@ function generateCssFn(ctx) {
|
|
|
666
668
|
|
|
667
669
|
const cssFn = createCss(context)
|
|
668
670
|
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
669
|
-
css.raw = (styles) => styles
|
|
671
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
670
672
|
|
|
671
673
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
672
674
|
`
|
|
@@ -955,7 +957,7 @@ function generatePattern(ctx) {
|
|
|
955
957
|
|
|
956
958
|
interface ${upperName}PatternFn {
|
|
957
959
|
(styles?: ${upperName}Styles): string
|
|
958
|
-
raw: (styles
|
|
960
|
+
raw: (styles?: ${upperName}Styles) => SystemStyleObject
|
|
959
961
|
}
|
|
960
962
|
|
|
961
963
|
${description ? `/** ${description} */` : ""}
|
|
@@ -1144,12 +1146,17 @@ function generateSvaFn(ctx) {
|
|
|
1144
1146
|
|
|
1145
1147
|
export function sva(config) {
|
|
1146
1148
|
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1147
|
-
|
|
1149
|
+
|
|
1148
1150
|
function svaFn(props) {
|
|
1149
1151
|
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1150
1152
|
return Object.fromEntries(result)
|
|
1151
1153
|
}
|
|
1152
1154
|
|
|
1155
|
+
function raw(props) {
|
|
1156
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
|
|
1157
|
+
return Object.fromEntries(result)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1153
1160
|
const variants = config.variants ?? {};
|
|
1154
1161
|
const variantKeys = Object.keys(variants);
|
|
1155
1162
|
|
|
@@ -1163,6 +1170,7 @@ function generateSvaFn(ctx) {
|
|
|
1163
1170
|
|
|
1164
1171
|
return Object.assign(svaFn, {
|
|
1165
1172
|
__cva__: false,
|
|
1173
|
+
raw,
|
|
1166
1174
|
variantMap,
|
|
1167
1175
|
variantKeys,
|
|
1168
1176
|
splitVariantProps,
|
|
@@ -2868,7 +2876,7 @@ var composition_d_ts_default = {
|
|
|
2868
2876
|
|
|
2869
2877
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2870
2878
|
var recipe_d_ts_default = {
|
|
2871
|
-
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"
|
|
2879
|
+
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 raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\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"
|
|
2872
2880
|
};
|
|
2873
2881
|
|
|
2874
2882
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2927,9 +2935,12 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2927
2935
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2928
2936
|
}
|
|
2929
2937
|
`,
|
|
2938
|
+
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
|
|
2930
2939
|
index: outdent39`
|
|
2931
2940
|
import '${ctx.file.extDts("./global")}'
|
|
2932
2941
|
${ctx.file.exportType("ConditionalValue", "./conditions")}
|
|
2942
|
+
${ctx.file.exportType("PatternConfig, PatternProperties", "./pattern")}
|
|
2943
|
+
${ctx.file.exportType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
2933
2944
|
${ctx.file.exportType("GlobalStyleObject, JsxStyleProps, SystemStyleObject", "./system-types")}
|
|
2934
2945
|
|
|
2935
2946
|
`,
|
|
@@ -2974,9 +2985,9 @@ function generatePropTypes(ctx) {
|
|
|
2974
2985
|
${result.join("\n")}
|
|
2975
2986
|
|
|
2976
2987
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2977
|
-
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2988
|
+
? ConditionalValue<PropertyTypes[T]${strictText}${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
2978
2989
|
: T extends keyof CssProperties
|
|
2979
|
-
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2990
|
+
? ConditionalValue<CssProperties[T]${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
2980
2991
|
: ConditionalValue<string | number>
|
|
2981
2992
|
`;
|
|
2982
2993
|
}
|
|
@@ -3211,12 +3222,12 @@ function setupJsx(ctx) {
|
|
|
3211
3222
|
`,
|
|
3212
3223
|
dts: outdent43`
|
|
3213
3224
|
${ctx.file.exportTypeStar("./factory")}
|
|
3214
|
-
|
|
3225
|
+
|
|
3215
3226
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3216
|
-
|
|
3227
|
+
|
|
3217
3228
|
${outdent43.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3218
|
-
|
|
3219
|
-
${ctx.file.exportType(ctx.jsx.typeName, "../types/jsx")}
|
|
3229
|
+
|
|
3230
|
+
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3220
3231
|
`
|
|
3221
3232
|
};
|
|
3222
3233
|
return {
|
|
@@ -3461,7 +3472,8 @@ var getBaseEngine = (conf) => {
|
|
|
3461
3472
|
tokens,
|
|
3462
3473
|
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3463
3474
|
separator: config.separator,
|
|
3464
|
-
shorthands: config.shorthands
|
|
3475
|
+
shorthands: config.shorthands,
|
|
3476
|
+
strictTokens: config.strictTokens
|
|
3465
3477
|
});
|
|
3466
3478
|
const conditions = new Conditions({
|
|
3467
3479
|
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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.
|
|
24
|
-
"@pandacss/is-valid-prop": "0.
|
|
25
|
-
"@pandacss/logger": "0.
|
|
26
|
-
"@pandacss/shared": "0.
|
|
27
|
-
"@pandacss/
|
|
28
|
-
"@pandacss/
|
|
23
|
+
"@pandacss/core": "0.14.0",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.14.0",
|
|
25
|
+
"@pandacss/logger": "0.14.0",
|
|
26
|
+
"@pandacss/shared": "0.14.0",
|
|
27
|
+
"@pandacss/token-dictionary": "0.14.0",
|
|
28
|
+
"@pandacss/types": "0.14.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.30",
|
|
32
32
|
"hookable": "5.5.3",
|
|
33
|
-
"@pandacss/fixture": "0.
|
|
33
|
+
"@pandacss/fixture": "0.14.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|