@pandacss/parser 0.8.0 → 0.10.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.d.mts CHANGED
@@ -1,16 +1,19 @@
1
1
  import * as ts_morph from 'ts-morph';
2
2
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
3
- import { ResultItem, RecipeConfig, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
3
+ import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
+ import { Generator } from '@pandacss/generator';
4
5
 
5
6
  declare class ParserResult {
6
7
  jsx: Set<ResultItem>;
7
8
  css: Set<ResultItem>;
8
9
  cva: Set<ResultItem>;
10
+ sva: Set<ResultItem>;
9
11
  recipe: Map<string, Set<ResultItem>>;
10
12
  pattern: Map<string, Set<ResultItem>>;
11
13
  filePath: string | undefined;
12
- set(name: 'cva' | 'css', result: ResultItem): void;
14
+ set(name: 'cva' | 'css' | 'sva', result: ResultItem): void;
13
15
  setCva(result: ResultItem): void;
16
+ setSva(result: ResultItem): void;
14
17
  setJsx(result: ResultItem): void;
15
18
  setPattern(name: string, result: ResultItem): void;
16
19
  setRecipe(name: string, result: ResultItem): void;
@@ -20,41 +23,33 @@ declare class ParserResult {
20
23
  toJSON(): {
21
24
  css: ResultItem[];
22
25
  cva: ResultItem[];
26
+ sva: ResultItem[];
27
+ jsx: ResultItem[];
23
28
  recipe: {
24
29
  [k: string]: ResultItem[];
25
30
  };
26
31
  pattern: {
27
32
  [k: string]: ResultItem[];
28
33
  };
29
- jsx: ResultItem[];
30
34
  };
31
35
  merge(result: ParserResult): this;
32
36
  static fromJSON(json: string): ParserResult;
33
37
  }
34
38
  declare const createParserResult: () => ParserResult;
35
39
 
36
- type ParserPatternNode = {
37
- name: string;
38
- type: 'pattern';
39
- props?: string[];
40
- baseName: string;
41
- };
42
- type ParserRecipeNode = {
43
- name: string;
44
- type: 'recipe';
45
- props: string[];
46
- baseName: string;
47
- jsx: RecipeConfig['jsx'];
48
- };
40
+ type ParserPatternNode = Generator['patterns']['details'][number];
41
+ type ParserRecipeNode = Generator['recipes']['details'][number];
49
42
  type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
50
43
  type ParserOptions = {
51
44
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
52
45
  jsx?: {
53
46
  factory: string;
47
+ styleProps: Exclude<Config['jsxStyleProps'], undefined>;
54
48
  nodes: ParserNodeOptions[];
55
49
  isStyleProp: (prop: string) => boolean;
56
50
  };
57
- getRecipesByJsxName: (jsxName: string) => RecipeConfig[];
51
+ getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
52
+ getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
58
53
  tsOptions?: ConfigTsOptions;
59
54
  join: Runtime['path']['join'];
60
55
  };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import * as ts_morph from 'ts-morph';
2
2
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
3
- import { ResultItem, RecipeConfig, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
3
+ import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
+ import { Generator } from '@pandacss/generator';
4
5
 
5
6
  declare class ParserResult {
6
7
  jsx: Set<ResultItem>;
7
8
  css: Set<ResultItem>;
8
9
  cva: Set<ResultItem>;
10
+ sva: Set<ResultItem>;
9
11
  recipe: Map<string, Set<ResultItem>>;
10
12
  pattern: Map<string, Set<ResultItem>>;
11
13
  filePath: string | undefined;
12
- set(name: 'cva' | 'css', result: ResultItem): void;
14
+ set(name: 'cva' | 'css' | 'sva', result: ResultItem): void;
13
15
  setCva(result: ResultItem): void;
16
+ setSva(result: ResultItem): void;
14
17
  setJsx(result: ResultItem): void;
15
18
  setPattern(name: string, result: ResultItem): void;
16
19
  setRecipe(name: string, result: ResultItem): void;
@@ -20,41 +23,33 @@ declare class ParserResult {
20
23
  toJSON(): {
21
24
  css: ResultItem[];
22
25
  cva: ResultItem[];
26
+ sva: ResultItem[];
27
+ jsx: ResultItem[];
23
28
  recipe: {
24
29
  [k: string]: ResultItem[];
25
30
  };
26
31
  pattern: {
27
32
  [k: string]: ResultItem[];
28
33
  };
29
- jsx: ResultItem[];
30
34
  };
31
35
  merge(result: ParserResult): this;
32
36
  static fromJSON(json: string): ParserResult;
33
37
  }
34
38
  declare const createParserResult: () => ParserResult;
35
39
 
36
- type ParserPatternNode = {
37
- name: string;
38
- type: 'pattern';
39
- props?: string[];
40
- baseName: string;
41
- };
42
- type ParserRecipeNode = {
43
- name: string;
44
- type: 'recipe';
45
- props: string[];
46
- baseName: string;
47
- jsx: RecipeConfig['jsx'];
48
- };
40
+ type ParserPatternNode = Generator['patterns']['details'][number];
41
+ type ParserRecipeNode = Generator['recipes']['details'][number];
49
42
  type ParserNodeOptions = ParserPatternNode | ParserRecipeNode;
50
43
  type ParserOptions = {
51
44
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
52
45
  jsx?: {
53
46
  factory: string;
47
+ styleProps: Exclude<Config['jsxStyleProps'], undefined>;
54
48
  nodes: ParserNodeOptions[];
55
49
  isStyleProp: (prop: string) => boolean;
56
50
  };
57
- getRecipesByJsxName: (jsxName: string) => RecipeConfig[];
51
+ getRecipesByJsxName: (jsxName: string) => ParserRecipeNode[];
52
+ getPatternsByJsxName: (jsxName: string) => ParserPatternNode[];
58
53
  tsOptions?: ConfigTsOptions;
59
54
  join: Runtime['path']['join'];
60
55
  };
package/dist/index.js CHANGED
@@ -102,6 +102,7 @@ var ParserResult = class _ParserResult {
102
102
  jsx = /* @__PURE__ */ new Set();
103
103
  css = /* @__PURE__ */ new Set();
104
104
  cva = /* @__PURE__ */ new Set();
105
+ sva = /* @__PURE__ */ new Set();
105
106
  recipe = /* @__PURE__ */ new Map();
106
107
  pattern = /* @__PURE__ */ new Map();
107
108
  filePath;
@@ -111,6 +112,9 @@ var ParserResult = class _ParserResult {
111
112
  setCva(result) {
112
113
  this.cva.add({ type: "cva", ...result });
113
114
  }
115
+ setSva(result) {
116
+ this.sva.add({ type: "sva", ...result });
117
+ }
114
118
  setJsx(result) {
115
119
  this.jsx.add({ type: "jsx", ...result });
116
120
  }
@@ -123,7 +127,7 @@ var ParserResult = class _ParserResult {
123
127
  this.recipe.get(name)?.add({ type: "recipe", ...result });
124
128
  }
125
129
  isEmpty() {
126
- return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
130
+ return this.css.size === 0 && this.cva.size === 0 && this.sva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
127
131
  }
128
132
  setFilePath(filePath) {
129
133
  this.filePath = filePath;
@@ -133,23 +137,27 @@ var ParserResult = class _ParserResult {
133
137
  const result = [];
134
138
  this.css.forEach((item) => result.push(item));
135
139
  this.cva.forEach((item) => result.push(item));
140
+ this.sva.forEach((item) => result.push(item));
141
+ this.jsx.forEach((item) => result.push(item));
136
142
  this.recipe.forEach((items) => items.forEach((item) => result.push(item)));
137
143
  this.pattern.forEach((items) => items.forEach((item) => result.push(item)));
138
- this.jsx.forEach((item) => result.push(item));
139
144
  return result;
140
145
  }
141
146
  toJSON() {
142
147
  return {
143
148
  css: Array.from(this.css),
144
149
  cva: Array.from(this.cva),
150
+ sva: Array.from(this.sva),
151
+ jsx: Array.from(this.jsx),
145
152
  recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
146
- pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)])),
147
- jsx: Array.from(this.jsx)
153
+ pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)]))
148
154
  };
149
155
  }
150
156
  merge(result) {
151
157
  result.css.forEach((item) => this.css.add(item));
152
158
  result.cva.forEach((item) => this.cva.add(item));
159
+ result.sva.forEach((item) => this.sva.add(item));
160
+ result.jsx.forEach((item) => this.jsx.add(item));
153
161
  result.recipe.forEach((items, name) => {
154
162
  this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
155
163
  items.forEach((item) => this.recipe.get(name)?.add(item));
@@ -158,7 +166,6 @@ var ParserResult = class _ParserResult {
158
166
  this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
159
167
  items.forEach((item) => this.pattern.get(name)?.add(item));
160
168
  });
161
- result.jsx.forEach((item) => this.jsx.add(item));
162
169
  return this;
163
170
  }
164
171
  static fromJSON(json) {
@@ -166,9 +173,10 @@ var ParserResult = class _ParserResult {
166
173
  const result = new _ParserResult();
167
174
  result.css = new Set(data.css);
168
175
  result.cva = new Set(data.cva);
176
+ result.sva = new Set(data.sva);
177
+ result.jsx = new Set(data.jsx);
169
178
  result.recipe = new Map(Object.entries(data.recipe));
170
179
  result.pattern = new Map(Object.entries(data.pattern));
171
- result.jsx = new Set(data.jsx);
172
180
  return result;
173
181
  }
174
182
  };
@@ -177,6 +185,7 @@ var createParserResult = () => new ParserResult();
177
185
  // src/parser.ts
178
186
  var import_ts_path = require("@pandacss/config/ts-path");
179
187
  var isNodeRecipe = (node) => node.type === "recipe";
188
+ var isNodePattern = (node) => node.type === "pattern";
180
189
  var cvaProps = ["compoundVariants", "defaultVariants", "variants", "base"];
181
190
  var isCva = (map) => cvaProps.some((prop) => map.has(prop));
182
191
  function createImportMatcher(mod, values) {
@@ -199,15 +208,15 @@ var fallback = (box2) => ({
199
208
  });
200
209
  var defaultEnv = { preset: "NONE" };
201
210
  function createParser(options) {
202
- const { jsx, getRecipesByJsxName, tsOptions, join } = options;
211
+ const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
203
212
  const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
204
213
  const importRegex = [
205
- createImportMatcher(importMap.css, ["css", "cva"]),
214
+ createImportMatcher(importMap.css, ["css", "cva", "sva"]),
206
215
  createImportMatcher(importMap.recipe),
207
216
  createImportMatcher(importMap.pattern)
208
217
  ];
209
218
  if (jsx) {
210
- importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.name)]));
219
+ importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
211
220
  }
212
221
  return function parse2(sourceFile) {
213
222
  if (!sourceFile)
@@ -249,8 +258,20 @@ function createParser(options) {
249
258
  const name = fullName.split(".raw")[0] ?? "";
250
259
  return name === "css" || isValidPattern(name) || isValidRecipe(name);
251
260
  };
252
- const jsxPatternNodes = new RegExp(
253
- `^(${jsx?.nodes.filter((node) => node.type === "pattern").map((node) => node.name).join("|")})$`
261
+ const patternPropertiesByName = /* @__PURE__ */ new Map();
262
+ const patternJsxLists = (jsx?.nodes ?? []).filter(isNodePattern).reduce(
263
+ (acc, pattern) => {
264
+ patternPropertiesByName.set(pattern.jsxName, new Set(pattern.props ?? []));
265
+ pattern.jsx?.forEach((jsx2) => {
266
+ if (typeof jsx2 === "string") {
267
+ acc.string.add(jsx2);
268
+ } else {
269
+ acc.regex.push(jsx2);
270
+ }
271
+ });
272
+ return acc;
273
+ },
274
+ { string: /* @__PURE__ */ new Set(), regex: [] }
254
275
  );
255
276
  const recipes = /* @__PURE__ */ new Set();
256
277
  const patterns = /* @__PURE__ */ new Set();
@@ -269,7 +290,7 @@ function createParser(options) {
269
290
  const recipePropertiesByName = /* @__PURE__ */ new Map();
270
291
  const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
271
292
  (acc, recipe) => {
272
- recipePropertiesByName.set(recipe.baseName, new Set(recipe.props ?? []));
293
+ recipePropertiesByName.set(recipe.jsxName, new Set(recipe.props ?? []));
273
294
  recipe.jsx?.forEach((jsx2) => {
274
295
  if (typeof jsx2 === "string") {
275
296
  acc.string.add(jsx2);
@@ -283,9 +304,10 @@ function createParser(options) {
283
304
  );
284
305
  const cvaAlias = imports.getAlias("cva");
285
306
  const cssAlias = imports.getAlias("css");
307
+ const svaAlias = imports.getAlias("sva");
286
308
  if (options.jsx) {
287
309
  options.jsx.nodes.forEach((node) => {
288
- const alias = imports.getAlias(node.name);
310
+ const alias = imports.getAlias(node.jsxName);
289
311
  node.props?.forEach((prop) => propertiesMap.set(prop, true));
290
312
  functions.set(node.baseName, propertiesMap);
291
313
  functions.set(alias, propertiesMap);
@@ -295,24 +317,37 @@ function createParser(options) {
295
317
  const isJsxTagRecipe = (0, import_shared2.memo)(
296
318
  (tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
297
319
  );
320
+ const isJsxTagPattern = (0, import_shared2.memo)(
321
+ (tagName) => patternJsxLists.string.has(tagName) || patternJsxLists.regex.some((regex) => regex.test(tagName))
322
+ );
298
323
  const matchTag = (0, import_shared2.memo)((tagName) => {
299
324
  if (!tagName)
300
325
  return false;
301
- return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName);
326
+ return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
302
327
  });
303
- const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
304
- if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
305
- return true;
328
+ const isRecipeOrPatternProp = (0, import_shared2.memo)((tagName, propName) => {
306
329
  if (isJsxTagRecipe(tagName)) {
307
330
  const recipeList = getRecipesByJsxName(tagName);
308
- return recipeList.some((recipe) => recipePropertiesByName.get(recipe.name)?.has(propName));
331
+ return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
332
+ }
333
+ if (isJsxTagPattern(tagName)) {
334
+ const patternList = getPatternsByJsxName(tagName);
335
+ return patternList.some((pattern) => patternPropertiesByName.get(pattern.baseName)?.has(propName));
309
336
  }
310
337
  return false;
311
338
  });
339
+ const matchTagProp = (0, import_ts_pattern.match)(jsx?.styleProps).with(
340
+ "all",
341
+ () => (0, import_shared2.memo)((tagName, propName) => {
342
+ return Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName) || isRecipeOrPatternProp(tagName, propName);
343
+ })
344
+ ).with("minimal", () => (tagName, propName) => {
345
+ return propName === "css" || isRecipeOrPatternProp(tagName, propName);
346
+ }).otherwise(() => (tagName, propName) => isRecipeOrPatternProp(tagName, propName));
312
347
  const matchFn = (0, import_shared2.memo)((fnName) => {
313
348
  if (recipes.has(fnName) || patterns.has(fnName))
314
349
  return true;
315
- if (fnName === cvaAlias || fnName === cssAlias || isRawFn(fnName) || isFactory(fnName))
350
+ if (fnName === cvaAlias || fnName === cssAlias || fnName === svaAlias || isRawFn(fnName) || isFactory(fnName))
316
351
  return true;
317
352
  return functions.has(fnName);
318
353
  });
@@ -429,15 +464,12 @@ function createParser(options) {
429
464
  const data = combineResult((0, import_extractor.unbox)(query.box));
430
465
  (0, import_ts_pattern.match)(name).when(isFactory, (name2) => {
431
466
  collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
432
- }).when(
433
- (name2) => jsxPatternNodes.test(name2),
434
- (name2) => {
435
- collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
436
- }
437
- ).when(isJsxTagRecipe, (name2) => {
467
+ }).when(isJsxTagPattern, (name2) => {
468
+ collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
469
+ }).when(isJsxTagRecipe, (name2) => {
438
470
  const recipeList = getRecipesByJsxName(name2);
439
471
  recipeList.map((recipe) => {
440
- collector.setRecipe(recipe.name, { type: "jsx-recipe", name: name2, box: query.box, data });
472
+ collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: name2, box: query.box, data });
441
473
  });
442
474
  }).otherwise(() => {
443
475
  collector.setJsx({ name, box: query.box, type: "jsx", data });
package/dist/index.mjs CHANGED
@@ -64,6 +64,7 @@ var ParserResult = class _ParserResult {
64
64
  jsx = /* @__PURE__ */ new Set();
65
65
  css = /* @__PURE__ */ new Set();
66
66
  cva = /* @__PURE__ */ new Set();
67
+ sva = /* @__PURE__ */ new Set();
67
68
  recipe = /* @__PURE__ */ new Map();
68
69
  pattern = /* @__PURE__ */ new Map();
69
70
  filePath;
@@ -73,6 +74,9 @@ var ParserResult = class _ParserResult {
73
74
  setCva(result) {
74
75
  this.cva.add({ type: "cva", ...result });
75
76
  }
77
+ setSva(result) {
78
+ this.sva.add({ type: "sva", ...result });
79
+ }
76
80
  setJsx(result) {
77
81
  this.jsx.add({ type: "jsx", ...result });
78
82
  }
@@ -85,7 +89,7 @@ var ParserResult = class _ParserResult {
85
89
  this.recipe.get(name)?.add({ type: "recipe", ...result });
86
90
  }
87
91
  isEmpty() {
88
- return this.css.size === 0 && this.cva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
92
+ return this.css.size === 0 && this.cva.size === 0 && this.sva.size === 0 && this.recipe.size === 0 && this.pattern.size === 0 && this.jsx.size === 0;
89
93
  }
90
94
  setFilePath(filePath) {
91
95
  this.filePath = filePath;
@@ -95,23 +99,27 @@ var ParserResult = class _ParserResult {
95
99
  const result = [];
96
100
  this.css.forEach((item) => result.push(item));
97
101
  this.cva.forEach((item) => result.push(item));
102
+ this.sva.forEach((item) => result.push(item));
103
+ this.jsx.forEach((item) => result.push(item));
98
104
  this.recipe.forEach((items) => items.forEach((item) => result.push(item)));
99
105
  this.pattern.forEach((items) => items.forEach((item) => result.push(item)));
100
- this.jsx.forEach((item) => result.push(item));
101
106
  return result;
102
107
  }
103
108
  toJSON() {
104
109
  return {
105
110
  css: Array.from(this.css),
106
111
  cva: Array.from(this.cva),
112
+ sva: Array.from(this.sva),
113
+ jsx: Array.from(this.jsx),
107
114
  recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
108
- pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)])),
109
- jsx: Array.from(this.jsx)
115
+ pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)]))
110
116
  };
111
117
  }
112
118
  merge(result) {
113
119
  result.css.forEach((item) => this.css.add(item));
114
120
  result.cva.forEach((item) => this.cva.add(item));
121
+ result.sva.forEach((item) => this.sva.add(item));
122
+ result.jsx.forEach((item) => this.jsx.add(item));
115
123
  result.recipe.forEach((items, name) => {
116
124
  this.recipe.get(name) ?? this.recipe.set(name, /* @__PURE__ */ new Set());
117
125
  items.forEach((item) => this.recipe.get(name)?.add(item));
@@ -120,7 +128,6 @@ var ParserResult = class _ParserResult {
120
128
  this.pattern.get(name) ?? this.pattern.set(name, /* @__PURE__ */ new Set());
121
129
  items.forEach((item) => this.pattern.get(name)?.add(item));
122
130
  });
123
- result.jsx.forEach((item) => this.jsx.add(item));
124
131
  return this;
125
132
  }
126
133
  static fromJSON(json) {
@@ -128,9 +135,10 @@ var ParserResult = class _ParserResult {
128
135
  const result = new _ParserResult();
129
136
  result.css = new Set(data.css);
130
137
  result.cva = new Set(data.cva);
138
+ result.sva = new Set(data.sva);
139
+ result.jsx = new Set(data.jsx);
131
140
  result.recipe = new Map(Object.entries(data.recipe));
132
141
  result.pattern = new Map(Object.entries(data.pattern));
133
- result.jsx = new Set(data.jsx);
134
142
  return result;
135
143
  }
136
144
  };
@@ -139,6 +147,7 @@ var createParserResult = () => new ParserResult();
139
147
  // src/parser.ts
140
148
  import { resolveTsPathPattern } from "@pandacss/config/ts-path";
141
149
  var isNodeRecipe = (node) => node.type === "recipe";
150
+ var isNodePattern = (node) => node.type === "pattern";
142
151
  var cvaProps = ["compoundVariants", "defaultVariants", "variants", "base"];
143
152
  var isCva = (map) => cvaProps.some((prop) => map.has(prop));
144
153
  function createImportMatcher(mod, values) {
@@ -161,15 +170,15 @@ var fallback = (box2) => ({
161
170
  });
162
171
  var defaultEnv = { preset: "NONE" };
163
172
  function createParser(options) {
164
- const { jsx, getRecipesByJsxName, tsOptions, join } = options;
173
+ const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
165
174
  const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
166
175
  const importRegex = [
167
- createImportMatcher(importMap.css, ["css", "cva"]),
176
+ createImportMatcher(importMap.css, ["css", "cva", "sva"]),
168
177
  createImportMatcher(importMap.recipe),
169
178
  createImportMatcher(importMap.pattern)
170
179
  ];
171
180
  if (jsx) {
172
- importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.name)]));
181
+ importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.jsxName)]));
173
182
  }
174
183
  return function parse2(sourceFile) {
175
184
  if (!sourceFile)
@@ -211,8 +220,20 @@ function createParser(options) {
211
220
  const name = fullName.split(".raw")[0] ?? "";
212
221
  return name === "css" || isValidPattern(name) || isValidRecipe(name);
213
222
  };
214
- const jsxPatternNodes = new RegExp(
215
- `^(${jsx?.nodes.filter((node) => node.type === "pattern").map((node) => node.name).join("|")})$`
223
+ const patternPropertiesByName = /* @__PURE__ */ new Map();
224
+ const patternJsxLists = (jsx?.nodes ?? []).filter(isNodePattern).reduce(
225
+ (acc, pattern) => {
226
+ patternPropertiesByName.set(pattern.jsxName, new Set(pattern.props ?? []));
227
+ pattern.jsx?.forEach((jsx2) => {
228
+ if (typeof jsx2 === "string") {
229
+ acc.string.add(jsx2);
230
+ } else {
231
+ acc.regex.push(jsx2);
232
+ }
233
+ });
234
+ return acc;
235
+ },
236
+ { string: /* @__PURE__ */ new Set(), regex: [] }
216
237
  );
217
238
  const recipes = /* @__PURE__ */ new Set();
218
239
  const patterns = /* @__PURE__ */ new Set();
@@ -231,7 +252,7 @@ function createParser(options) {
231
252
  const recipePropertiesByName = /* @__PURE__ */ new Map();
232
253
  const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
233
254
  (acc, recipe) => {
234
- recipePropertiesByName.set(recipe.baseName, new Set(recipe.props ?? []));
255
+ recipePropertiesByName.set(recipe.jsxName, new Set(recipe.props ?? []));
235
256
  recipe.jsx?.forEach((jsx2) => {
236
257
  if (typeof jsx2 === "string") {
237
258
  acc.string.add(jsx2);
@@ -245,9 +266,10 @@ function createParser(options) {
245
266
  );
246
267
  const cvaAlias = imports.getAlias("cva");
247
268
  const cssAlias = imports.getAlias("css");
269
+ const svaAlias = imports.getAlias("sva");
248
270
  if (options.jsx) {
249
271
  options.jsx.nodes.forEach((node) => {
250
- const alias = imports.getAlias(node.name);
272
+ const alias = imports.getAlias(node.jsxName);
251
273
  node.props?.forEach((prop) => propertiesMap.set(prop, true));
252
274
  functions.set(node.baseName, propertiesMap);
253
275
  functions.set(alias, propertiesMap);
@@ -257,24 +279,37 @@ function createParser(options) {
257
279
  const isJsxTagRecipe = memo2(
258
280
  (tagName) => recipeJsxLists.string.has(tagName) || recipeJsxLists.regex.some((regex) => regex.test(tagName))
259
281
  );
282
+ const isJsxTagPattern = memo2(
283
+ (tagName) => patternJsxLists.string.has(tagName) || patternJsxLists.regex.some((regex) => regex.test(tagName))
284
+ );
260
285
  const matchTag = memo2((tagName) => {
261
286
  if (!tagName)
262
287
  return false;
263
- return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName);
288
+ return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
264
289
  });
265
- const matchTagProp = memo2((tagName, propName) => {
266
- if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
267
- return true;
290
+ const isRecipeOrPatternProp = memo2((tagName, propName) => {
268
291
  if (isJsxTagRecipe(tagName)) {
269
292
  const recipeList = getRecipesByJsxName(tagName);
270
- return recipeList.some((recipe) => recipePropertiesByName.get(recipe.name)?.has(propName));
293
+ return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
294
+ }
295
+ if (isJsxTagPattern(tagName)) {
296
+ const patternList = getPatternsByJsxName(tagName);
297
+ return patternList.some((pattern) => patternPropertiesByName.get(pattern.baseName)?.has(propName));
271
298
  }
272
299
  return false;
273
300
  });
301
+ const matchTagProp = match(jsx?.styleProps).with(
302
+ "all",
303
+ () => memo2((tagName, propName) => {
304
+ return Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName) || isRecipeOrPatternProp(tagName, propName);
305
+ })
306
+ ).with("minimal", () => (tagName, propName) => {
307
+ return propName === "css" || isRecipeOrPatternProp(tagName, propName);
308
+ }).otherwise(() => (tagName, propName) => isRecipeOrPatternProp(tagName, propName));
274
309
  const matchFn = memo2((fnName) => {
275
310
  if (recipes.has(fnName) || patterns.has(fnName))
276
311
  return true;
277
- if (fnName === cvaAlias || fnName === cssAlias || isRawFn(fnName) || isFactory(fnName))
312
+ if (fnName === cvaAlias || fnName === cssAlias || fnName === svaAlias || isRawFn(fnName) || isFactory(fnName))
278
313
  return true;
279
314
  return functions.has(fnName);
280
315
  });
@@ -391,15 +426,12 @@ function createParser(options) {
391
426
  const data = combineResult(unbox(query.box));
392
427
  match(name).when(isFactory, (name2) => {
393
428
  collector.setJsx({ name: name2, box: query.box, type: "jsx-factory", data });
394
- }).when(
395
- (name2) => jsxPatternNodes.test(name2),
396
- (name2) => {
397
- collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
398
- }
399
- ).when(isJsxTagRecipe, (name2) => {
429
+ }).when(isJsxTagPattern, (name2) => {
430
+ collector.setPattern(name2, { type: "jsx-pattern", name: name2, box: query.box, data });
431
+ }).when(isJsxTagRecipe, (name2) => {
400
432
  const recipeList = getRecipesByJsxName(name2);
401
433
  recipeList.map((recipe) => {
402
- collector.setRecipe(recipe.name, { type: "jsx-recipe", name: name2, box: query.box, data });
434
+ collector.setRecipe(recipe.baseName, { type: "jsx-recipe", name: name2, box: query.box, data });
403
435
  });
404
436
  }).otherwise(() => {
405
437
  collector.setJsx({ name, box: query.box, type: "jsx", data });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -13,20 +13,20 @@
13
13
  "dependencies": {
14
14
  "@vue/compiler-sfc": "^3.3.4",
15
15
  "lil-fp": "1.4.5",
16
- "magic-string": "^0.30.1",
16
+ "magic-string": "^0.30.2",
17
17
  "ts-morph": "19.0.0",
18
18
  "ts-pattern": "5.0.4",
19
- "@pandacss/config": "^0.8.0",
20
- "@pandacss/extractor": "0.8.0",
21
- "@pandacss/is-valid-prop": "0.8.0",
22
- "@pandacss/logger": "0.8.0",
23
- "@pandacss/shared": "0.8.0",
24
- "@pandacss/types": "0.8.0"
19
+ "@pandacss/config": "^0.10.0",
20
+ "@pandacss/extractor": "0.10.0",
21
+ "@pandacss/is-valid-prop": "0.10.0",
22
+ "@pandacss/logger": "0.10.0",
23
+ "@pandacss/shared": "0.10.0",
24
+ "@pandacss/types": "0.10.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "hookable": "5.5.3",
28
- "@pandacss/fixture": "0.8.0",
29
- "@pandacss/generator": "0.8.0"
28
+ "@pandacss/fixture": "0.10.0",
29
+ "@pandacss/generator": "0.10.0"
30
30
  },
31
31
  "files": [
32
32
  "dist"