@pandacss/parser 0.9.0 → 0.11.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,17 +1,19 @@
1
1
  import * as ts_morph from 'ts-morph';
2
2
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
3
- import { ResultItem, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
3
+ import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
4
  import { Generator } from '@pandacss/generator';
5
5
 
6
6
  declare class ParserResult {
7
7
  jsx: Set<ResultItem>;
8
8
  css: Set<ResultItem>;
9
9
  cva: Set<ResultItem>;
10
+ sva: Set<ResultItem>;
10
11
  recipe: Map<string, Set<ResultItem>>;
11
12
  pattern: Map<string, Set<ResultItem>>;
12
13
  filePath: string | undefined;
13
- set(name: 'cva' | 'css', result: ResultItem): void;
14
+ set(name: 'cva' | 'css' | 'sva', result: ResultItem): void;
14
15
  setCva(result: ResultItem): void;
16
+ setSva(result: ResultItem): void;
15
17
  setJsx(result: ResultItem): void;
16
18
  setPattern(name: string, result: ResultItem): void;
17
19
  setRecipe(name: string, result: ResultItem): void;
@@ -21,13 +23,14 @@ declare class ParserResult {
21
23
  toJSON(): {
22
24
  css: ResultItem[];
23
25
  cva: ResultItem[];
26
+ sva: ResultItem[];
27
+ jsx: ResultItem[];
24
28
  recipe: {
25
29
  [k: string]: ResultItem[];
26
30
  };
27
31
  pattern: {
28
32
  [k: string]: ResultItem[];
29
33
  };
30
- jsx: ResultItem[];
31
34
  };
32
35
  merge(result: ParserResult): this;
33
36
  static fromJSON(json: string): ParserResult;
@@ -41,6 +44,7 @@ type ParserOptions = {
41
44
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
42
45
  jsx?: {
43
46
  factory: string;
47
+ styleProps: Exclude<Config['jsxStyleProps'], undefined>;
44
48
  nodes: ParserNodeOptions[];
45
49
  isStyleProp: (prop: string) => boolean;
46
50
  };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import * as ts_morph from 'ts-morph';
2
2
  import { ProjectOptions as ProjectOptions$1 } from 'ts-morph';
3
- import { ResultItem, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
3
+ import { ResultItem, Config, ConfigTsOptions, Runtime, PandaHookable } from '@pandacss/types';
4
4
  import { Generator } from '@pandacss/generator';
5
5
 
6
6
  declare class ParserResult {
7
7
  jsx: Set<ResultItem>;
8
8
  css: Set<ResultItem>;
9
9
  cva: Set<ResultItem>;
10
+ sva: Set<ResultItem>;
10
11
  recipe: Map<string, Set<ResultItem>>;
11
12
  pattern: Map<string, Set<ResultItem>>;
12
13
  filePath: string | undefined;
13
- set(name: 'cva' | 'css', result: ResultItem): void;
14
+ set(name: 'cva' | 'css' | 'sva', result: ResultItem): void;
14
15
  setCva(result: ResultItem): void;
16
+ setSva(result: ResultItem): void;
15
17
  setJsx(result: ResultItem): void;
16
18
  setPattern(name: string, result: ResultItem): void;
17
19
  setRecipe(name: string, result: ResultItem): void;
@@ -21,13 +23,14 @@ declare class ParserResult {
21
23
  toJSON(): {
22
24
  css: ResultItem[];
23
25
  cva: ResultItem[];
26
+ sva: ResultItem[];
27
+ jsx: ResultItem[];
24
28
  recipe: {
25
29
  [k: string]: ResultItem[];
26
30
  };
27
31
  pattern: {
28
32
  [k: string]: ResultItem[];
29
33
  };
30
- jsx: ResultItem[];
31
34
  };
32
35
  merge(result: ParserResult): this;
33
36
  static fromJSON(json: string): ParserResult;
@@ -41,6 +44,7 @@ type ParserOptions = {
41
44
  importMap: Record<'css' | 'recipe' | 'pattern' | 'jsx', string[]>;
42
45
  jsx?: {
43
46
  factory: string;
47
+ styleProps: Exclude<Config['jsxStyleProps'], undefined>;
44
48
  nodes: ParserNodeOptions[];
45
49
  isStyleProp: (prop: string) => boolean;
46
50
  };
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
  };
@@ -203,7 +211,7 @@ function createParser(options) {
203
211
  const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
204
212
  const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
205
213
  const importRegex = [
206
- createImportMatcher(importMap.css, ["css", "cva"]),
214
+ createImportMatcher(importMap.css, ["css", "cva", "sva"]),
207
215
  createImportMatcher(importMap.recipe),
208
216
  createImportMatcher(importMap.pattern)
209
217
  ];
@@ -296,6 +304,7 @@ function createParser(options) {
296
304
  );
297
305
  const cvaAlias = imports.getAlias("cva");
298
306
  const cssAlias = imports.getAlias("css");
307
+ const svaAlias = imports.getAlias("sva");
299
308
  if (options.jsx) {
300
309
  options.jsx.nodes.forEach((node) => {
301
310
  const alias = imports.getAlias(node.jsxName);
@@ -316,9 +325,7 @@ function createParser(options) {
316
325
  return false;
317
326
  return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
318
327
  });
319
- const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
320
- if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
321
- return true;
328
+ const isRecipeOrPatternProp = (0, import_shared2.memo)((tagName, propName) => {
322
329
  if (isJsxTagRecipe(tagName)) {
323
330
  const recipeList = getRecipesByJsxName(tagName);
324
331
  return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
@@ -329,10 +336,18 @@ function createParser(options) {
329
336
  }
330
337
  return false;
331
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));
332
347
  const matchFn = (0, import_shared2.memo)((fnName) => {
333
348
  if (recipes.has(fnName) || patterns.has(fnName))
334
349
  return true;
335
- if (fnName === cvaAlias || fnName === cssAlias || isRawFn(fnName) || isFactory(fnName))
350
+ if (fnName === cvaAlias || fnName === cssAlias || fnName === svaAlias || isRawFn(fnName) || isFactory(fnName))
336
351
  return true;
337
352
  return functions.has(fnName);
338
353
  });
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
  };
@@ -165,7 +173,7 @@ function createParser(options) {
165
173
  const { jsx, getRecipesByJsxName, getPatternsByJsxName, tsOptions, join } = options;
166
174
  const importMap = Object.fromEntries(Object.entries(options.importMap).map(([key, value]) => [key, join(...value)]));
167
175
  const importRegex = [
168
- createImportMatcher(importMap.css, ["css", "cva"]),
176
+ createImportMatcher(importMap.css, ["css", "cva", "sva"]),
169
177
  createImportMatcher(importMap.recipe),
170
178
  createImportMatcher(importMap.pattern)
171
179
  ];
@@ -258,6 +266,7 @@ function createParser(options) {
258
266
  );
259
267
  const cvaAlias = imports.getAlias("cva");
260
268
  const cssAlias = imports.getAlias("css");
269
+ const svaAlias = imports.getAlias("sva");
261
270
  if (options.jsx) {
262
271
  options.jsx.nodes.forEach((node) => {
263
272
  const alias = imports.getAlias(node.jsxName);
@@ -278,9 +287,7 @@ function createParser(options) {
278
287
  return false;
279
288
  return components.has(tagName) || isUpperCase(tagName) || isFactory(tagName) || isJsxTagRecipe(tagName) || isJsxTagPattern(tagName);
280
289
  });
281
- const matchTagProp = memo2((tagName, propName) => {
282
- if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
283
- return true;
290
+ const isRecipeOrPatternProp = memo2((tagName, propName) => {
284
291
  if (isJsxTagRecipe(tagName)) {
285
292
  const recipeList = getRecipesByJsxName(tagName);
286
293
  return recipeList.some((recipe) => recipePropertiesByName.get(recipe.baseName)?.has(propName));
@@ -291,10 +298,18 @@ function createParser(options) {
291
298
  }
292
299
  return false;
293
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));
294
309
  const matchFn = memo2((fnName) => {
295
310
  if (recipes.has(fnName) || patterns.has(fnName))
296
311
  return true;
297
- if (fnName === cvaAlias || fnName === cssAlias || isRawFn(fnName) || isFactory(fnName))
312
+ if (fnName === cvaAlias || fnName === cssAlias || fnName === svaAlias || isRawFn(fnName) || isFactory(fnName))
298
313
  return true;
299
314
  return functions.has(fnName);
300
315
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.9.0",
3
+ "version": "0.11.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.9.0",
20
- "@pandacss/extractor": "0.9.0",
21
- "@pandacss/is-valid-prop": "0.9.0",
22
- "@pandacss/logger": "0.9.0",
23
- "@pandacss/shared": "0.9.0",
24
- "@pandacss/types": "0.9.0"
19
+ "@pandacss/config": "^0.11.0",
20
+ "@pandacss/extractor": "0.11.0",
21
+ "@pandacss/is-valid-prop": "0.11.0",
22
+ "@pandacss/logger": "0.11.0",
23
+ "@pandacss/shared": "0.11.0",
24
+ "@pandacss/types": "0.11.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "hookable": "5.5.3",
28
- "@pandacss/fixture": "0.9.0",
29
- "@pandacss/generator": "0.9.0"
28
+ "@pandacss/fixture": "0.11.0",
29
+ "@pandacss/generator": "0.11.0"
30
30
  },
31
31
  "files": [
32
32
  "dist"