@pandacss/generator 1.6.1 → 1.7.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 CHANGED
@@ -37,8 +37,8 @@ module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/generator.ts
39
39
  var import_core5 = require("@pandacss/core");
40
- var import_shared7 = require("@pandacss/shared");
41
- var import_ts_pattern15 = require("ts-pattern");
40
+ var import_shared11 = require("@pandacss/shared");
41
+ var import_ts_pattern14 = require("ts-pattern");
42
42
 
43
43
  // src/artifacts/setup-artifacts.ts
44
44
  var import_outdent48 = __toESM(require("outdent"));
@@ -553,7 +553,6 @@ function generatedJsxHelpers(ctx) {
553
553
  var import_shared = require("@pandacss/shared");
554
554
  var import_javascript_stringify = require("javascript-stringify");
555
555
  var import_outdent10 = require("outdent");
556
- var import_ts_pattern3 = require("ts-pattern");
557
556
  function generatePattern(ctx, filters) {
558
557
  if (ctx.patterns.isEmpty()) return;
559
558
  const details = ctx.patterns.filterDetails(filters);
@@ -580,18 +579,8 @@ function generatePattern(ctx, filters) {
580
579
  export interface ${upperName}Properties {
581
580
  ${Object.keys(properties ?? {}).map((key) => {
582
581
  const value = properties[key];
583
- return (0, import_ts_pattern3.match)(value).with({ type: "property" }, (value2) => {
584
- return `${key}?: SystemProperties["${value2.value}"]`;
585
- }).with({ type: "token" }, (value2) => {
586
- if (value2.property) {
587
- return `${key}?: ConditionalValue<Tokens["${value2.value}"] | Properties["${value2.property}"]>`;
588
- }
589
- return `${key}?: ConditionalValue<Tokens["${value2.value}"]>`;
590
- }).with({ type: "enum" }, (value2) => {
591
- return `${key}?: ConditionalValue<${(0, import_shared.unionType)(value2.value)}>`;
592
- }).otherwise(() => {
593
- return `${key}?: ConditionalValue<${value.type}>`;
594
- });
582
+ const typeString = ctx.patterns.getPropertyType(value);
583
+ return `${key}?: ${typeString}`;
595
584
  }).join("\n ")}
596
585
  }
597
586
 
@@ -642,7 +631,7 @@ defaultValues`)}
642
631
  var import_core = require("@pandacss/core");
643
632
  var import_shared2 = require("@pandacss/shared");
644
633
  var import_outdent11 = require("outdent");
645
- var import_ts_pattern4 = require("ts-pattern");
634
+ var import_ts_pattern3 = require("ts-pattern");
646
635
  var stringify2 = (value) => JSON.stringify(value, null, 2);
647
636
  var isBooleanValue = (value) => value === "true" || value === "false";
648
637
  var hasOwn = (obj, key) => {
@@ -759,7 +748,7 @@ function generateRecipes(ctx, filters) {
759
748
  }
760
749
  return ctx.file.jsDocComment("", { default: defaultValue });
761
750
  };
762
- const jsCode = (0, import_ts_pattern4.match)(config).when(
751
+ const jsCode = (0, import_ts_pattern3.match)(config).when(
763
752
  import_core.Recipes.isSlotRecipeConfig,
764
753
  (config2) => import_outdent11.outdent`
765
754
  ${ctx.file.import("compact, getSlotCompoundVariant, memo, splitProps", "../helpers")}
@@ -1069,7 +1058,7 @@ function generatePreactJsxFactory(ctx) {
1069
1058
 
1070
1059
  // src/artifacts/preact-jsx/pattern.ts
1071
1060
  var import_outdent15 = require("outdent");
1072
- var import_ts_pattern5 = require("ts-pattern");
1061
+ var import_ts_pattern4 = require("ts-pattern");
1073
1062
  function generatePreactJsxPattern(ctx, filters) {
1074
1063
  const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
1075
1064
  const details = ctx.patterns.filterDetails(filters);
@@ -1087,7 +1076,7 @@ function generatePreactJsxPattern(ctx, filters) {
1087
1076
  ${ctx.file.import(factoryName, "./factory")}
1088
1077
 
1089
1078
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1090
- ${(0, import_ts_pattern5.match)(jsxStyleProps2).with(
1079
+ ${(0, import_ts_pattern4.match)(jsxStyleProps2).with(
1091
1080
  "none",
1092
1081
  () => import_outdent15.outdent`
1093
1082
  const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
@@ -1221,7 +1210,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
1221
1210
 
1222
1211
  // src/artifacts/preact-jsx/create-style-context.ts
1223
1212
  var import_outdent17 = require("outdent");
1224
- var import_ts_pattern6 = require("ts-pattern");
1213
+ var import_ts_pattern5 = require("ts-pattern");
1225
1214
  function generatePreactCreateStyleContext(ctx) {
1226
1215
  const { factoryName } = ctx.jsx;
1227
1216
  return {
@@ -1265,7 +1254,7 @@ function generatePreactCreateStyleContext(ctx) {
1265
1254
  return { ...restProps, className: cx(slotStyles, restProps.className) }
1266
1255
  }
1267
1256
  ${import_outdent17.outdent.string(
1268
- (0, import_ts_pattern6.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
1257
+ (0, import_ts_pattern5.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
1269
1258
  )}
1270
1259
  }
1271
1260
 
@@ -1618,7 +1607,7 @@ function generateQwikJsxFactory(ctx) {
1618
1607
 
1619
1608
  // src/artifacts/qwik-jsx/pattern.ts
1620
1609
  var import_outdent21 = require("outdent");
1621
- var import_ts_pattern7 = require("ts-pattern");
1610
+ var import_ts_pattern6 = require("ts-pattern");
1622
1611
  function generateQwikJsxPattern(ctx, filters) {
1623
1612
  const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
1624
1613
  const details = ctx.patterns.filterDetails(filters);
@@ -1635,7 +1624,7 @@ function generateQwikJsxPattern(ctx, filters) {
1635
1624
  ${ctx.file.import(factoryName, "./factory")}
1636
1625
 
1637
1626
  export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
1638
- ${(0, import_ts_pattern7.match)(jsxStyleProps2).with(
1627
+ ${(0, import_ts_pattern6.match)(jsxStyleProps2).with(
1639
1628
  "none",
1640
1629
  () => import_outdent21.outdent`
1641
1630
  const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
@@ -1985,7 +1974,7 @@ function generateReactJsxFactory(ctx) {
1985
1974
 
1986
1975
  // src/artifacts/react-jsx/pattern.ts
1987
1976
  var import_outdent26 = require("outdent");
1988
- var import_ts_pattern8 = require("ts-pattern");
1977
+ var import_ts_pattern7 = require("ts-pattern");
1989
1978
  function generateReactJsxPattern(ctx, filters) {
1990
1979
  const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
1991
1980
  const details = ctx.patterns.filterDetails(filters);
@@ -2002,7 +1991,7 @@ function generateReactJsxPattern(ctx, filters) {
2002
1991
  ${ctx.file.import(factoryName, "./factory")}
2003
1992
 
2004
1993
  export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
2005
- ${(0, import_ts_pattern8.match)(jsxStyleProps2).with(
1994
+ ${(0, import_ts_pattern7.match)(jsxStyleProps2).with(
2006
1995
  "none",
2007
1996
  () => import_outdent26.outdent`
2008
1997
  const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
@@ -2138,7 +2127,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
2138
2127
 
2139
2128
  // src/artifacts/react-jsx/create-style-context.ts
2140
2129
  var import_outdent28 = require("outdent");
2141
- var import_ts_pattern9 = require("ts-pattern");
2130
+ var import_ts_pattern8 = require("ts-pattern");
2142
2131
  function generateReactCreateStyleContext(ctx) {
2143
2132
  const { factoryName } = ctx.jsx;
2144
2133
  return {
@@ -2180,7 +2169,7 @@ function generateReactCreateStyleContext(ctx) {
2180
2169
  return { ...restProps, className: cx(slotStyles, restProps.className) }
2181
2170
  }
2182
2171
  ${import_outdent28.outdent.string(
2183
- (0, import_ts_pattern9.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
2172
+ (0, import_ts_pattern8.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
2184
2173
  )}
2185
2174
  }
2186
2175
 
@@ -2582,7 +2571,7 @@ function generateSolidJsxFactory(ctx) {
2582
2571
 
2583
2572
  // src/artifacts/solid-jsx/pattern.ts
2584
2573
  var import_outdent32 = require("outdent");
2585
- var import_ts_pattern10 = require("ts-pattern");
2574
+ var import_ts_pattern9 = require("ts-pattern");
2586
2575
  function generateSolidJsxPattern(ctx, filters) {
2587
2576
  const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
2588
2577
  const details = ctx.patterns.filterDetails(filters);
@@ -2599,7 +2588,7 @@ function generateSolidJsxPattern(ctx, filters) {
2599
2588
  ${ctx.file.import(factoryName, "./factory")}
2600
2589
 
2601
2590
  export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
2602
- ${(0, import_ts_pattern10.match)(jsxStyleProps2).with(
2591
+ ${(0, import_ts_pattern9.match)(jsxStyleProps2).with(
2603
2592
  "none",
2604
2593
  () => import_outdent32.outdent`
2605
2594
  const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
@@ -2739,7 +2728,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
2739
2728
 
2740
2729
  // src/artifacts/solid-jsx/create-style-context.ts
2741
2730
  var import_outdent34 = require("outdent");
2742
- var import_ts_pattern11 = require("ts-pattern");
2731
+ var import_ts_pattern10 = require("ts-pattern");
2743
2732
  function generateSolidCreateStyleContext(ctx) {
2744
2733
  const { factoryName } = ctx.jsx;
2745
2734
  return {
@@ -2782,7 +2771,7 @@ function generateSolidCreateStyleContext(ctx) {
2782
2771
  return { ...restProps, class: cx(slotStyles, restProps.class) }
2783
2772
  }
2784
2773
  ${import_outdent34.outdent.string(
2785
- (0, import_ts_pattern11.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
2774
+ (0, import_ts_pattern10.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
2786
2775
  )}
2787
2776
  }
2788
2777
 
@@ -3228,7 +3217,7 @@ function generateVueJsxFactory(ctx) {
3228
3217
 
3229
3218
  // src/artifacts/vue-jsx/pattern.ts
3230
3219
  var import_outdent38 = require("outdent");
3231
- var import_ts_pattern12 = require("ts-pattern");
3220
+ var import_ts_pattern11 = require("ts-pattern");
3232
3221
  function generateVueJsxPattern(ctx, filters) {
3233
3222
  const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
3234
3223
  const details = ctx.patterns.filterDetails(filters);
@@ -3248,7 +3237,7 @@ function generateVueJsxPattern(ctx, filters) {
3248
3237
  inheritAttrs: false,
3249
3238
  props: ${JSON.stringify(props)},
3250
3239
  setup(props, { attrs, slots }) {
3251
- ${(0, import_ts_pattern12.match)(jsxStyleProps2).with(
3240
+ ${(0, import_ts_pattern11.match)(jsxStyleProps2).with(
3252
3241
  "none",
3253
3242
  () => import_outdent38.outdent`
3254
3243
  const cssProps = computed(() => {
@@ -3397,7 +3386,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
3397
3386
 
3398
3387
  // src/artifacts/vue-jsx/create-style-context.ts
3399
3388
  var import_outdent40 = require("outdent");
3400
- var import_ts_pattern13 = require("ts-pattern");
3389
+ var import_ts_pattern12 = require("ts-pattern");
3401
3390
  function generateVueCreateStyleContext(ctx) {
3402
3391
  const { factoryName } = ctx.jsx;
3403
3392
  return {
@@ -3434,7 +3423,7 @@ function generateVueCreateStyleContext(ctx) {
3434
3423
  return { ...restProps, class: cx(slotStyles, restProps.class) }
3435
3424
  }
3436
3425
  ${import_outdent40.outdent.string(
3437
- (0, import_ts_pattern13.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
3426
+ (0, import_ts_pattern12.match)(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
3438
3427
  )}
3439
3428
  }
3440
3429
 
@@ -3823,7 +3812,7 @@ function generateJsxCreateStyleContext(ctx) {
3823
3812
  }
3824
3813
 
3825
3814
  // src/artifacts/types/generated.ts
3826
- var import_ts_pattern14 = require("ts-pattern");
3815
+ var import_ts_pattern13 = require("ts-pattern");
3827
3816
 
3828
3817
  // src/artifacts/generated/composition.d.ts.json
3829
3818
  var composition_d_ts_default = {
@@ -4532,7 +4521,7 @@ var parts_d_ts_default = {
4532
4521
 
4533
4522
  // src/artifacts/generated/pattern.d.ts.json
4534
4523
  var pattern_d_ts_default = {
4535
- content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
4524
+ content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
4536
4525
  };
4537
4526
 
4538
4527
  // src/artifacts/generated/recipe.d.ts.json
@@ -4571,7 +4560,7 @@ var jsxStyleProps = "export type JsxStyleProps = SystemStyleObject & WithCss";
4571
4560
  function getGeneratedSystemTypes(ctx) {
4572
4561
  return {
4573
4562
  system: ctx.file.rewriteTypeImport(
4574
- (0, import_ts_pattern14.match)(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
4563
+ (0, import_ts_pattern13.match)(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
4575
4564
  "minimal",
4576
4565
  () => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
4577
4566
  ).with(
@@ -5738,6 +5727,424 @@ var generateStaticCss = (ctx, sheet) => {
5738
5727
  }
5739
5728
  };
5740
5729
 
5730
+ // src/spec/animation-styles.ts
5731
+ var import_shared7 = require("@pandacss/shared");
5732
+ var collectAnimationStyles = (values) => {
5733
+ const result = [];
5734
+ (0, import_shared7.walkObject)(
5735
+ values,
5736
+ (token, paths) => {
5737
+ if (token && (0, import_shared7.isObject)(token) && "value" in token) {
5738
+ const filteredPaths = paths.filter((item) => item !== "DEFAULT");
5739
+ result.push({
5740
+ name: filteredPaths.join("."),
5741
+ description: token.description
5742
+ });
5743
+ }
5744
+ },
5745
+ {
5746
+ stop: (v) => (0, import_shared7.isObject)(v) && "value" in v
5747
+ }
5748
+ );
5749
+ return result;
5750
+ };
5751
+ var generateAnimationStylesSpec = (ctx) => {
5752
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
5753
+ const animationStyles = collectAnimationStyles(ctx.config.theme?.animationStyles ?? {});
5754
+ const animationStylesSpec = animationStyles.map((style) => {
5755
+ const functionExamples = [`css({ animationStyle: '${style.name}' })`];
5756
+ const jsxExamples = [];
5757
+ if (jsxStyleProps2 === "all") {
5758
+ jsxExamples.push(`<Box animationStyle="${style.name}" />`);
5759
+ } else if (jsxStyleProps2 === "minimal") {
5760
+ jsxExamples.push(`<Box css={{ animationStyle: '${style.name}' }} />`);
5761
+ }
5762
+ return {
5763
+ name: style.name,
5764
+ description: style.description,
5765
+ functionExamples,
5766
+ jsxExamples
5767
+ };
5768
+ });
5769
+ return {
5770
+ type: "animation-styles",
5771
+ data: animationStylesSpec
5772
+ };
5773
+ };
5774
+
5775
+ // src/spec/color-palette.ts
5776
+ var generateColorPaletteSpec = (ctx) => {
5777
+ const colorPaletteConfig = ctx.config.theme?.colorPalette;
5778
+ if (colorPaletteConfig?.enabled === false) {
5779
+ return null;
5780
+ }
5781
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
5782
+ const values = Array.from(ctx.tokens.view.colorPalettes.keys()).sort();
5783
+ if (!values.length) {
5784
+ return null;
5785
+ }
5786
+ const functionExamples = [
5787
+ `css({ colorPalette: 'blue' })`,
5788
+ `css({ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' })`
5789
+ ];
5790
+ const jsxExamples = [];
5791
+ if (jsxStyleProps2 === "all") {
5792
+ jsxExamples.push(`<Box colorPalette="blue" />`);
5793
+ jsxExamples.push(`<Box colorPalette="blue" bg="colorPalette.500" color="colorPalette.50" />`);
5794
+ } else if (jsxStyleProps2 === "minimal") {
5795
+ jsxExamples.push(`<Box css={{ colorPalette: 'blue' }} />`);
5796
+ jsxExamples.push(`<Box css={{ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' }} />`);
5797
+ }
5798
+ return {
5799
+ type: "color-palette",
5800
+ data: {
5801
+ values,
5802
+ functionExamples,
5803
+ jsxExamples
5804
+ }
5805
+ };
5806
+ };
5807
+
5808
+ // src/spec/conditions.ts
5809
+ var generateConditionsSpec = (ctx) => {
5810
+ const breakpointKeys = new Set(Object.keys(ctx.conditions.breakpoints.conditions));
5811
+ const conditions = Object.entries(ctx.conditions.values).map(([name, detail]) => {
5812
+ const value = Array.isArray(detail.raw) ? detail.raw.join(", ") : detail.raw;
5813
+ const nameWithoutUnderscore = name.startsWith("_") ? name.slice(1) : name;
5814
+ const isBreakpoint = breakpointKeys.has(name) || breakpointKeys.has(nameWithoutUnderscore);
5815
+ const conditionName = isBreakpoint ? nameWithoutUnderscore : name;
5816
+ return {
5817
+ name: conditionName,
5818
+ value: value ?? "",
5819
+ functionExamples: [
5820
+ `css({ margin: { base: '2', ${conditionName}: '4' } })`,
5821
+ `css({ margin: '2', ${conditionName}: { margin: '4' } })`
5822
+ ],
5823
+ jsxExamples: [
5824
+ `<Box margin={{ base: '2', ${conditionName}: '4'}} />`,
5825
+ `<Box margin='2' ${conditionName}={{ margin: '4' }} />`
5826
+ ]
5827
+ };
5828
+ });
5829
+ return {
5830
+ type: "conditions",
5831
+ data: conditions
5832
+ };
5833
+ };
5834
+
5835
+ // src/spec/keyframes.ts
5836
+ var generateKeyframesSpec = (ctx) => {
5837
+ const keyframes = Object.keys(ctx.config.theme?.keyframes ?? {}).map((name) => ({
5838
+ name,
5839
+ functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`],
5840
+ jsxExamples: [`<Box animationName="${name}" />`, `<Box animation="${name} 1s ease-in-out infinite" />`]
5841
+ }));
5842
+ return {
5843
+ type: "keyframes",
5844
+ data: keyframes
5845
+ };
5846
+ };
5847
+
5848
+ // src/spec/layer-styles.ts
5849
+ var import_shared8 = require("@pandacss/shared");
5850
+ var collectLayerStyles = (values) => {
5851
+ const result = [];
5852
+ (0, import_shared8.walkObject)(
5853
+ values,
5854
+ (token, paths) => {
5855
+ if (token && (0, import_shared8.isObject)(token) && "value" in token) {
5856
+ const filteredPaths = paths.filter((item) => item !== "DEFAULT");
5857
+ result.push({
5858
+ name: filteredPaths.join("."),
5859
+ description: token.description
5860
+ });
5861
+ }
5862
+ },
5863
+ {
5864
+ stop: (v) => (0, import_shared8.isObject)(v) && "value" in v
5865
+ }
5866
+ );
5867
+ return result;
5868
+ };
5869
+ var generateLayerStylesSpec = (ctx) => {
5870
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
5871
+ const layerStyles = collectLayerStyles(ctx.config.theme?.layerStyles ?? {});
5872
+ const layerStylesSpec = layerStyles.map((style) => {
5873
+ const functionExamples = [`css({ layerStyle: '${style.name}' })`];
5874
+ const jsxExamples = [];
5875
+ if (jsxStyleProps2 === "all") {
5876
+ jsxExamples.push(`<Box layerStyle="${style.name}" />`);
5877
+ } else if (jsxStyleProps2 === "minimal") {
5878
+ jsxExamples.push(`<Box css={{ layerStyle: '${style.name}' }} />`);
5879
+ }
5880
+ return {
5881
+ name: style.name,
5882
+ description: style.description,
5883
+ functionExamples,
5884
+ jsxExamples
5885
+ };
5886
+ });
5887
+ return {
5888
+ type: "layer-styles",
5889
+ data: layerStylesSpec
5890
+ };
5891
+ };
5892
+
5893
+ // src/spec/patterns.ts
5894
+ var generatePatternsSpec = (ctx) => {
5895
+ const patterns = ctx.patterns.details.map((node) => {
5896
+ const patternName = node.baseName;
5897
+ const jsxName = node.jsxName;
5898
+ const properties = Object.entries(node.config.properties ?? {});
5899
+ const functionExamples = [];
5900
+ const jsxExamples = [];
5901
+ if (properties.length === 0) {
5902
+ functionExamples.push(`${patternName}()`);
5903
+ jsxExamples.push(`<${jsxName} />`);
5904
+ } else {
5905
+ properties.forEach(([propName, prop]) => {
5906
+ let exampleValue = "<value>";
5907
+ if (prop.type === "enum" && prop.value?.length > 0) {
5908
+ exampleValue = `"${prop.value[0]}"`;
5909
+ } else if (prop.type === "boolean") {
5910
+ exampleValue = "true";
5911
+ } else if (prop.type === "number") {
5912
+ exampleValue = "4";
5913
+ } else if (prop.type === "token") {
5914
+ exampleValue = '"md"';
5915
+ }
5916
+ functionExamples.push(`${patternName}({ ${propName}: ${exampleValue} })`);
5917
+ jsxExamples.push(`<${jsxName} ${propName}={${exampleValue}} />`);
5918
+ });
5919
+ }
5920
+ const defaultValues = typeof node.config.defaultValues === "object" ? node.config.defaultValues : {};
5921
+ return {
5922
+ name: patternName,
5923
+ description: node.config.description,
5924
+ properties: properties.map(([name, prop]) => ({
5925
+ name,
5926
+ type: ctx.patterns.getPropertyType(prop),
5927
+ description: prop.description,
5928
+ defaultValue: defaultValues[name]
5929
+ })),
5930
+ jsx: jsxName,
5931
+ functionExamples,
5932
+ jsxExamples
5933
+ };
5934
+ });
5935
+ return {
5936
+ type: "patterns",
5937
+ data: patterns
5938
+ };
5939
+ };
5940
+
5941
+ // src/spec/recipes.ts
5942
+ var getFirstVariantValue = (variantKeyMap, key) => {
5943
+ const values = variantKeyMap[key];
5944
+ return values && values.length > 0 ? values[0] : null;
5945
+ };
5946
+ var buildVariantProps = (variantKeys, variantKeyMap, formatFn, separator) => {
5947
+ return variantKeys.map((key) => {
5948
+ const value = getFirstVariantValue(variantKeyMap, key);
5949
+ return value ? formatFn(key, value) : null;
5950
+ }).filter(Boolean).join(separator);
5951
+ };
5952
+ var generateRecipesSpec = (ctx) => {
5953
+ const recipes = ctx.recipes.details.map((node) => {
5954
+ const recipeName = node.baseName;
5955
+ const jsxName = node.jsxName;
5956
+ const variantKeys = Object.keys(node.variantKeyMap);
5957
+ const functionExamples = [];
5958
+ const jsxExamples = [];
5959
+ if (variantKeys.length === 0) {
5960
+ functionExamples.push(`${recipeName}()`);
5961
+ jsxExamples.push(`<${jsxName} />`);
5962
+ } else {
5963
+ variantKeys.forEach((variantKey) => {
5964
+ const firstValue = getFirstVariantValue(node.variantKeyMap, variantKey);
5965
+ if (firstValue) {
5966
+ functionExamples.push(`${recipeName}({ ${variantKey}: '${firstValue}' })`);
5967
+ jsxExamples.push(`<${jsxName} ${variantKey}="${firstValue}" />`);
5968
+ }
5969
+ });
5970
+ if (variantKeys.length > 1) {
5971
+ const props = buildVariantProps(variantKeys, node.variantKeyMap, (key, value) => `${key}: '${value}'`, ", ");
5972
+ const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap, (key, value) => `${key}="${value}"`, " ");
5973
+ if (props && jsxProps) {
5974
+ functionExamples.push(`${recipeName}({ ${props} })`);
5975
+ jsxExamples.push(`<${jsxName} ${jsxProps} />`);
5976
+ }
5977
+ }
5978
+ }
5979
+ return {
5980
+ name: recipeName,
5981
+ description: node.config.description,
5982
+ variants: node.variantKeyMap,
5983
+ defaultVariants: node.config.defaultVariants ?? {},
5984
+ functionExamples,
5985
+ jsxExamples
5986
+ };
5987
+ });
5988
+ return {
5989
+ type: "recipes",
5990
+ data: recipes
5991
+ };
5992
+ };
5993
+
5994
+ // src/spec/text-styles.ts
5995
+ var import_shared9 = require("@pandacss/shared");
5996
+ var collectTextStyles = (values) => {
5997
+ const result = [];
5998
+ (0, import_shared9.walkObject)(
5999
+ values,
6000
+ (token, paths) => {
6001
+ if (token && (0, import_shared9.isObject)(token) && "value" in token) {
6002
+ const filteredPaths = paths.filter((item) => item !== "DEFAULT");
6003
+ result.push({
6004
+ name: filteredPaths.join("."),
6005
+ description: token.description
6006
+ });
6007
+ }
6008
+ },
6009
+ {
6010
+ stop: (v) => (0, import_shared9.isObject)(v) && "value" in v
6011
+ }
6012
+ );
6013
+ return result;
6014
+ };
6015
+ var generateTextStylesSpec = (ctx) => {
6016
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
6017
+ const textStyles = collectTextStyles(ctx.config.theme?.textStyles ?? {});
6018
+ const textStylesSpec = textStyles.map((style) => {
6019
+ const functionExamples = [`css({ textStyle: '${style.name}' })`];
6020
+ const jsxExamples = [];
6021
+ if (jsxStyleProps2 === "all") {
6022
+ jsxExamples.push(`<Box textStyle="${style.name}" />`);
6023
+ } else if (jsxStyleProps2 === "minimal") {
6024
+ jsxExamples.push(`<Box css={{ textStyle: '${style.name}' }} />`);
6025
+ }
6026
+ return {
6027
+ name: style.name,
6028
+ description: style.description,
6029
+ functionExamples,
6030
+ jsxExamples
6031
+ };
6032
+ });
6033
+ return {
6034
+ type: "text-styles",
6035
+ data: textStylesSpec
6036
+ };
6037
+ };
6038
+
6039
+ // src/spec/tokens.ts
6040
+ var import_shared10 = require("@pandacss/shared");
6041
+ var CATEGORY_PROPERTY_MAP = {
6042
+ colors: "color",
6043
+ spacing: "padding",
6044
+ sizes: "width",
6045
+ fonts: "fontFamily",
6046
+ fontSizes: "fontSize",
6047
+ fontWeights: "fontWeight",
6048
+ letterSpacings: "letterSpacing",
6049
+ lineHeights: "lineHeight",
6050
+ shadows: "boxShadow",
6051
+ radii: "borderRadius",
6052
+ durations: "transitionDuration",
6053
+ easings: "transitionTimingFunction",
6054
+ gradients: "backgroundImage",
6055
+ aspectRatios: "aspectRatio",
6056
+ cursor: "cursor",
6057
+ borderWidths: "borderWidth",
6058
+ borders: "border",
6059
+ zIndex: "zIndex",
6060
+ opacity: "opacity",
6061
+ blurs: "filter"
6062
+ };
6063
+ var getCategoryProperty = (category) => {
6064
+ return category ? CATEGORY_PROPERTY_MAP[category] ?? "color" : "color";
6065
+ };
6066
+ var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
6067
+ const prop = getCategoryProperty(token.extensions?.category);
6068
+ const tokenName = token.extensions.prop;
6069
+ const fullTokenName = token.name;
6070
+ const functionExamples = [`css({ ${prop}: '${tokenName}' })`];
6071
+ const tokenFunctionExamples = [`token('${fullTokenName}')`];
6072
+ const jsxExamples = [];
6073
+ if (jsxStyleProps2 === "all") {
6074
+ jsxExamples.push(`<Box ${prop}="${tokenName}" />`);
6075
+ } else if (jsxStyleProps2 === "minimal") {
6076
+ jsxExamples.push(`<Box css={{ ${prop}: '${tokenName}' }} />`);
6077
+ }
6078
+ if (token.extensions.varRef) {
6079
+ tokenFunctionExamples.push(`token.var('${fullTokenName}')`);
6080
+ }
6081
+ return { functionExamples, tokenFunctionExamples, jsxExamples };
6082
+ };
6083
+ var generateTokensSpec = (ctx) => {
6084
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
6085
+ const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
6086
+ const typeTokens = Array.from(tokenMap.values()).filter(
6087
+ (token) => !token.extensions.isSemantic && !token.extensions.isVirtual && !token.extensions.conditions && !token.extensions.isNegative
6088
+ );
6089
+ if (!typeTokens.length) return null;
6090
+ const firstToken = typeTokens[0];
6091
+ const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
6092
+ const values = typeTokens.map((token) => ({
6093
+ name: token.extensions.prop || token.name,
6094
+ value: token.value,
6095
+ description: token.description,
6096
+ deprecated: token.deprecated,
6097
+ cssVar: token.extensions.varRef
6098
+ }));
6099
+ return {
6100
+ type: category,
6101
+ values,
6102
+ tokenFunctionExamples,
6103
+ functionExamples,
6104
+ jsxExamples
6105
+ };
6106
+ }).filter(Boolean);
6107
+ return {
6108
+ type: "tokens",
6109
+ data: groupedData
6110
+ };
6111
+ };
6112
+ var generateSemanticTokensSpec = (ctx) => {
6113
+ const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
6114
+ const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
6115
+ const typeTokens = Array.from(tokenMap.values()).filter(
6116
+ (token) => (token.extensions.isSemantic || token.extensions.conditions) && !token.extensions.isVirtual
6117
+ );
6118
+ if (!typeTokens.length) return null;
6119
+ const firstToken = typeTokens[0];
6120
+ const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
6121
+ const values = typeTokens.map((token) => {
6122
+ const conditions = [];
6123
+ (0, import_shared10.walkObject)(token.extensions.rawValue, (value, path) => {
6124
+ conditions.push({ value, condition: path.map((p) => p.replace(/^_/, "")).join(".") });
6125
+ });
6126
+ return {
6127
+ name: token.extensions.prop || token.name,
6128
+ values: conditions,
6129
+ description: token.description,
6130
+ deprecated: token.deprecated,
6131
+ cssVar: token.extensions.varRef
6132
+ };
6133
+ });
6134
+ return {
6135
+ type: category,
6136
+ values,
6137
+ tokenFunctionExamples,
6138
+ functionExamples,
6139
+ jsxExamples
6140
+ };
6141
+ }).filter(Boolean);
6142
+ return {
6143
+ type: "semantic-tokens",
6144
+ data: groupedData
6145
+ };
6146
+ };
6147
+
5741
6148
  // src/generator.ts
5742
6149
  var Generator = class extends import_core5.Context {
5743
6150
  constructor(conf) {
@@ -5747,8 +6154,8 @@ var Generator = class extends import_core5.Context {
5747
6154
  return generateArtifacts(this, ids);
5748
6155
  };
5749
6156
  appendCssOfType = (type, sheet) => {
5750
- (0, import_ts_pattern15.match)(type).with("preflight", () => generateResetCss(this, sheet)).with("tokens", () => generateTokenCss(this, sheet)).with("static", () => generateStaticCss(this, sheet)).with("global", () => generateGlobalCss(this, sheet)).with("keyframes", () => generateKeyframeCss(this, sheet)).otherwise(() => {
5751
- throw new import_shared7.PandaError(
6157
+ (0, import_ts_pattern14.match)(type).with("preflight", () => generateResetCss(this, sheet)).with("tokens", () => generateTokenCss(this, sheet)).with("static", () => generateStaticCss(this, sheet)).with("global", () => generateGlobalCss(this, sheet)).with("keyframes", () => generateKeyframeCss(this, sheet)).otherwise(() => {
6158
+ throw new import_shared11.PandaError(
5752
6159
  "UNKNOWN_ARTIFACT",
5753
6160
  `Unknown CSS artifact type: "${type}". Expected one of: preflight, tokens, static, global, keyframes`
5754
6161
  );
@@ -5821,7 +6228,7 @@ var Generator = class extends import_core5.Context {
5821
6228
  code: l.css
5822
6229
  }));
5823
6230
  const recipes = [];
5824
- for (const recipeName of decoder.recipes.keys()) {
6231
+ for (const recipeName of this.recipes.keys) {
5825
6232
  const recipeSheet = this.createSheet();
5826
6233
  recipeSheet.processDecoderForRecipe(decoder, recipeName);
5827
6234
  const code = recipeSheet.getLayerCss("recipes");
@@ -5829,7 +6236,7 @@ var Generator = class extends import_core5.Context {
5829
6236
  recipes.push({
5830
6237
  type: "recipe",
5831
6238
  name: recipeName,
5832
- file: `${(0, import_shared7.dashCase)(recipeName)}.css`,
6239
+ file: `${(0, import_shared11.dashCase)(recipeName)}.css`,
5833
6240
  code,
5834
6241
  dir: "recipes"
5835
6242
  });
@@ -5843,7 +6250,7 @@ var Generator = class extends import_core5.Context {
5843
6250
  themes.push({
5844
6251
  type: "theme",
5845
6252
  name: themeName,
5846
- file: `${(0, import_shared7.dashCase)(themeName)}.css`,
6253
+ file: `${(0, import_shared11.dashCase)(themeName)}.css`,
5847
6254
  code: `@layer ${layerNames.tokens} {
5848
6255
  ${css}
5849
6256
  }`,
@@ -5869,6 +6276,24 @@ ${css}
5869
6276
  index: imports.join("\n")
5870
6277
  };
5871
6278
  };
6279
+ getSpec = () => {
6280
+ const specs = [
6281
+ generateTokensSpec(this),
6282
+ generateRecipesSpec(this),
6283
+ generatePatternsSpec(this),
6284
+ generateConditionsSpec(this),
6285
+ generateKeyframesSpec(this),
6286
+ generateSemanticTokensSpec(this),
6287
+ generateTextStylesSpec(this),
6288
+ generateLayerStylesSpec(this),
6289
+ generateAnimationStylesSpec(this)
6290
+ ];
6291
+ const colorPaletteSpec = generateColorPaletteSpec(this);
6292
+ if (colorPaletteSpec) {
6293
+ specs.push(colorPaletteSpec);
6294
+ }
6295
+ return specs;
6296
+ };
5872
6297
  };
5873
6298
  // Annotate the CommonJS export names for ESM import in node:
5874
6299
  0 && (module.exports = {