@pandacss/generator 0.8.0 → 0.9.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 +68 -22
- package/dist/index.d.ts +68 -22
- package/dist/index.js +67 -67
- package/dist/index.mjs +68 -68
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -6,12 +6,11 @@ import { ConfigResultWithHooks, TSConfig } from '@pandacss/types';
|
|
|
6
6
|
|
|
7
7
|
declare const getEngine: (conf: ConfigResultWithHooks) => {
|
|
8
8
|
patterns: {
|
|
9
|
-
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
10
|
-
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
11
9
|
getConfig: (name: string) => _pandacss_types.PatternConfig;
|
|
10
|
+
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
12
11
|
getNames: (name: string) => {
|
|
13
|
-
name: string;
|
|
14
12
|
upperName: string;
|
|
13
|
+
baseName: string;
|
|
15
14
|
dashName: string;
|
|
16
15
|
styleFnName: string;
|
|
17
16
|
jsxName: string;
|
|
@@ -20,19 +19,29 @@ declare const getEngine: (conf: ConfigResultWithHooks) => {
|
|
|
20
19
|
props: string[];
|
|
21
20
|
blocklistType: string;
|
|
22
21
|
config: _pandacss_types.PatternConfig;
|
|
23
|
-
|
|
22
|
+
type: "pattern";
|
|
23
|
+
match: RegExp;
|
|
24
|
+
jsx: (string | RegExp)[];
|
|
24
25
|
upperName: string;
|
|
26
|
+
baseName: string;
|
|
25
27
|
dashName: string;
|
|
26
28
|
styleFnName: string;
|
|
27
29
|
jsxName: string;
|
|
28
30
|
}[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name: string;
|
|
31
|
+
getFnName: (jsxName: string) => string;
|
|
32
|
+
filter: (jsxName: string) => {
|
|
32
33
|
props: string[];
|
|
34
|
+
blocklistType: string;
|
|
35
|
+
config: _pandacss_types.PatternConfig;
|
|
36
|
+
type: "pattern";
|
|
37
|
+
match: RegExp;
|
|
38
|
+
jsx: (string | RegExp)[];
|
|
39
|
+
upperName: string;
|
|
33
40
|
baseName: string;
|
|
41
|
+
dashName: string;
|
|
42
|
+
styleFnName: string;
|
|
43
|
+
jsxName: string;
|
|
34
44
|
}[];
|
|
35
|
-
getFnName: (jsx: string) => string;
|
|
36
45
|
isEmpty: () => boolean;
|
|
37
46
|
};
|
|
38
47
|
jsx: {
|
|
@@ -164,21 +173,35 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
164
173
|
factory: string;
|
|
165
174
|
isStyleProp: (key: string) => boolean;
|
|
166
175
|
nodes: ({
|
|
167
|
-
type: "pattern";
|
|
168
|
-
name: string;
|
|
169
176
|
props: string[];
|
|
177
|
+
blocklistType: string;
|
|
178
|
+
config: _pandacss_types.PatternConfig;
|
|
179
|
+
type: "pattern";
|
|
180
|
+
match: RegExp;
|
|
181
|
+
jsx: (string | RegExp)[];
|
|
182
|
+
upperName: string;
|
|
170
183
|
baseName: string;
|
|
184
|
+
dashName: string;
|
|
185
|
+
styleFnName: string;
|
|
186
|
+
jsxName: string;
|
|
171
187
|
} | {
|
|
172
|
-
type: "recipe";
|
|
173
|
-
name: string;
|
|
174
|
-
props: string[];
|
|
175
188
|
baseName: string;
|
|
189
|
+
type: "recipe";
|
|
190
|
+
variantKeys: string[];
|
|
191
|
+
variantKeyMap: Record<string, string[]>;
|
|
176
192
|
jsx: (string | RegExp)[];
|
|
193
|
+
upperName: string;
|
|
194
|
+
dashName: string;
|
|
195
|
+
jsxName: string;
|
|
177
196
|
match: RegExp;
|
|
197
|
+
config: _pandacss_types.RecipeConfig;
|
|
198
|
+
splitProps: (props: _pandacss_types.Dict) => [_pandacss_types.Dict, _pandacss_types.Dict];
|
|
199
|
+
props: string[];
|
|
178
200
|
})[];
|
|
179
201
|
};
|
|
180
202
|
getRecipesByJsxName: (jsxName: string) => {
|
|
181
|
-
|
|
203
|
+
baseName: string;
|
|
204
|
+
type: "recipe";
|
|
182
205
|
variantKeys: string[];
|
|
183
206
|
variantKeyMap: Record<string, string[]>;
|
|
184
207
|
jsx: (string | RegExp)[];
|
|
@@ -188,17 +211,30 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
188
211
|
match: RegExp;
|
|
189
212
|
config: _pandacss_types.RecipeConfig;
|
|
190
213
|
splitProps: (props: _pandacss_types.Dict) => [_pandacss_types.Dict, _pandacss_types.Dict];
|
|
214
|
+
props: string[];
|
|
215
|
+
}[];
|
|
216
|
+
getPatternsByJsxName: (jsxName: string) => {
|
|
217
|
+
props: string[];
|
|
218
|
+
blocklistType: string;
|
|
219
|
+
config: _pandacss_types.PatternConfig;
|
|
220
|
+
type: "pattern";
|
|
221
|
+
match: RegExp;
|
|
222
|
+
jsx: (string | RegExp)[];
|
|
223
|
+
upperName: string;
|
|
224
|
+
baseName: string;
|
|
225
|
+
dashName: string;
|
|
226
|
+
styleFnName: string;
|
|
227
|
+
jsxName: string;
|
|
191
228
|
}[];
|
|
192
229
|
compilerOptions: any;
|
|
193
230
|
tsOptions: _pandacss_types.ConfigTsOptions | undefined;
|
|
194
231
|
};
|
|
195
232
|
patterns: {
|
|
196
|
-
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
197
|
-
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
198
233
|
getConfig: (name: string) => _pandacss_types.PatternConfig;
|
|
234
|
+
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
199
235
|
getNames: (name: string) => {
|
|
200
|
-
name: string;
|
|
201
236
|
upperName: string;
|
|
237
|
+
baseName: string;
|
|
202
238
|
dashName: string;
|
|
203
239
|
styleFnName: string;
|
|
204
240
|
jsxName: string;
|
|
@@ -207,19 +243,29 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
207
243
|
props: string[];
|
|
208
244
|
blocklistType: string;
|
|
209
245
|
config: _pandacss_types.PatternConfig;
|
|
210
|
-
|
|
246
|
+
type: "pattern";
|
|
247
|
+
match: RegExp;
|
|
248
|
+
jsx: (string | RegExp)[];
|
|
211
249
|
upperName: string;
|
|
250
|
+
baseName: string;
|
|
212
251
|
dashName: string;
|
|
213
252
|
styleFnName: string;
|
|
214
253
|
jsxName: string;
|
|
215
254
|
}[];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
name: string;
|
|
255
|
+
getFnName: (jsxName: string) => string;
|
|
256
|
+
filter: (jsxName: string) => {
|
|
219
257
|
props: string[];
|
|
258
|
+
blocklistType: string;
|
|
259
|
+
config: _pandacss_types.PatternConfig;
|
|
260
|
+
type: "pattern";
|
|
261
|
+
match: RegExp;
|
|
262
|
+
jsx: (string | RegExp)[];
|
|
263
|
+
upperName: string;
|
|
220
264
|
baseName: string;
|
|
265
|
+
dashName: string;
|
|
266
|
+
styleFnName: string;
|
|
267
|
+
jsxName: string;
|
|
221
268
|
}[];
|
|
222
|
-
getFnName: (jsx: string) => string;
|
|
223
269
|
isEmpty: () => boolean;
|
|
224
270
|
};
|
|
225
271
|
jsx: {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,11 @@ import { ConfigResultWithHooks, TSConfig } from '@pandacss/types';
|
|
|
6
6
|
|
|
7
7
|
declare const getEngine: (conf: ConfigResultWithHooks) => {
|
|
8
8
|
patterns: {
|
|
9
|
-
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
10
|
-
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
11
9
|
getConfig: (name: string) => _pandacss_types.PatternConfig;
|
|
10
|
+
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
12
11
|
getNames: (name: string) => {
|
|
13
|
-
name: string;
|
|
14
12
|
upperName: string;
|
|
13
|
+
baseName: string;
|
|
15
14
|
dashName: string;
|
|
16
15
|
styleFnName: string;
|
|
17
16
|
jsxName: string;
|
|
@@ -20,19 +19,29 @@ declare const getEngine: (conf: ConfigResultWithHooks) => {
|
|
|
20
19
|
props: string[];
|
|
21
20
|
blocklistType: string;
|
|
22
21
|
config: _pandacss_types.PatternConfig;
|
|
23
|
-
|
|
22
|
+
type: "pattern";
|
|
23
|
+
match: RegExp;
|
|
24
|
+
jsx: (string | RegExp)[];
|
|
24
25
|
upperName: string;
|
|
26
|
+
baseName: string;
|
|
25
27
|
dashName: string;
|
|
26
28
|
styleFnName: string;
|
|
27
29
|
jsxName: string;
|
|
28
30
|
}[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name: string;
|
|
31
|
+
getFnName: (jsxName: string) => string;
|
|
32
|
+
filter: (jsxName: string) => {
|
|
32
33
|
props: string[];
|
|
34
|
+
blocklistType: string;
|
|
35
|
+
config: _pandacss_types.PatternConfig;
|
|
36
|
+
type: "pattern";
|
|
37
|
+
match: RegExp;
|
|
38
|
+
jsx: (string | RegExp)[];
|
|
39
|
+
upperName: string;
|
|
33
40
|
baseName: string;
|
|
41
|
+
dashName: string;
|
|
42
|
+
styleFnName: string;
|
|
43
|
+
jsxName: string;
|
|
34
44
|
}[];
|
|
35
|
-
getFnName: (jsx: string) => string;
|
|
36
45
|
isEmpty: () => boolean;
|
|
37
46
|
};
|
|
38
47
|
jsx: {
|
|
@@ -164,21 +173,35 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
164
173
|
factory: string;
|
|
165
174
|
isStyleProp: (key: string) => boolean;
|
|
166
175
|
nodes: ({
|
|
167
|
-
type: "pattern";
|
|
168
|
-
name: string;
|
|
169
176
|
props: string[];
|
|
177
|
+
blocklistType: string;
|
|
178
|
+
config: _pandacss_types.PatternConfig;
|
|
179
|
+
type: "pattern";
|
|
180
|
+
match: RegExp;
|
|
181
|
+
jsx: (string | RegExp)[];
|
|
182
|
+
upperName: string;
|
|
170
183
|
baseName: string;
|
|
184
|
+
dashName: string;
|
|
185
|
+
styleFnName: string;
|
|
186
|
+
jsxName: string;
|
|
171
187
|
} | {
|
|
172
|
-
type: "recipe";
|
|
173
|
-
name: string;
|
|
174
|
-
props: string[];
|
|
175
188
|
baseName: string;
|
|
189
|
+
type: "recipe";
|
|
190
|
+
variantKeys: string[];
|
|
191
|
+
variantKeyMap: Record<string, string[]>;
|
|
176
192
|
jsx: (string | RegExp)[];
|
|
193
|
+
upperName: string;
|
|
194
|
+
dashName: string;
|
|
195
|
+
jsxName: string;
|
|
177
196
|
match: RegExp;
|
|
197
|
+
config: _pandacss_types.RecipeConfig;
|
|
198
|
+
splitProps: (props: _pandacss_types.Dict) => [_pandacss_types.Dict, _pandacss_types.Dict];
|
|
199
|
+
props: string[];
|
|
178
200
|
})[];
|
|
179
201
|
};
|
|
180
202
|
getRecipesByJsxName: (jsxName: string) => {
|
|
181
|
-
|
|
203
|
+
baseName: string;
|
|
204
|
+
type: "recipe";
|
|
182
205
|
variantKeys: string[];
|
|
183
206
|
variantKeyMap: Record<string, string[]>;
|
|
184
207
|
jsx: (string | RegExp)[];
|
|
@@ -188,17 +211,30 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
188
211
|
match: RegExp;
|
|
189
212
|
config: _pandacss_types.RecipeConfig;
|
|
190
213
|
splitProps: (props: _pandacss_types.Dict) => [_pandacss_types.Dict, _pandacss_types.Dict];
|
|
214
|
+
props: string[];
|
|
215
|
+
}[];
|
|
216
|
+
getPatternsByJsxName: (jsxName: string) => {
|
|
217
|
+
props: string[];
|
|
218
|
+
blocklistType: string;
|
|
219
|
+
config: _pandacss_types.PatternConfig;
|
|
220
|
+
type: "pattern";
|
|
221
|
+
match: RegExp;
|
|
222
|
+
jsx: (string | RegExp)[];
|
|
223
|
+
upperName: string;
|
|
224
|
+
baseName: string;
|
|
225
|
+
dashName: string;
|
|
226
|
+
styleFnName: string;
|
|
227
|
+
jsxName: string;
|
|
191
228
|
}[];
|
|
192
229
|
compilerOptions: any;
|
|
193
230
|
tsOptions: _pandacss_types.ConfigTsOptions | undefined;
|
|
194
231
|
};
|
|
195
232
|
patterns: {
|
|
196
|
-
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
197
|
-
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
198
233
|
getConfig: (name: string) => _pandacss_types.PatternConfig;
|
|
234
|
+
transform: (name: string, data: _pandacss_types.Dict) => _pandacss_types.SystemStyleObject;
|
|
199
235
|
getNames: (name: string) => {
|
|
200
|
-
name: string;
|
|
201
236
|
upperName: string;
|
|
237
|
+
baseName: string;
|
|
202
238
|
dashName: string;
|
|
203
239
|
styleFnName: string;
|
|
204
240
|
jsxName: string;
|
|
@@ -207,19 +243,29 @@ declare const createGenerator: (conf: ConfigResultWithHooks) => {
|
|
|
207
243
|
props: string[];
|
|
208
244
|
blocklistType: string;
|
|
209
245
|
config: _pandacss_types.PatternConfig;
|
|
210
|
-
|
|
246
|
+
type: "pattern";
|
|
247
|
+
match: RegExp;
|
|
248
|
+
jsx: (string | RegExp)[];
|
|
211
249
|
upperName: string;
|
|
250
|
+
baseName: string;
|
|
212
251
|
dashName: string;
|
|
213
252
|
styleFnName: string;
|
|
214
253
|
jsxName: string;
|
|
215
254
|
}[];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
name: string;
|
|
255
|
+
getFnName: (jsxName: string) => string;
|
|
256
|
+
filter: (jsxName: string) => {
|
|
219
257
|
props: string[];
|
|
258
|
+
blocklistType: string;
|
|
259
|
+
config: _pandacss_types.PatternConfig;
|
|
260
|
+
type: "pattern";
|
|
261
|
+
match: RegExp;
|
|
262
|
+
jsx: (string | RegExp)[];
|
|
263
|
+
upperName: string;
|
|
220
264
|
baseName: string;
|
|
265
|
+
dashName: string;
|
|
266
|
+
styleFnName: string;
|
|
267
|
+
jsxName: string;
|
|
221
268
|
}[];
|
|
222
|
-
getFnName: (jsx: string) => string;
|
|
223
269
|
isEmpty: () => boolean;
|
|
224
270
|
};
|
|
225
271
|
jsx: {
|
package/dist/index.js
CHANGED
|
@@ -419,7 +419,7 @@ var generateStaticCss = (ctx) => {
|
|
|
419
419
|
return [];
|
|
420
420
|
return Object.keys(values);
|
|
421
421
|
},
|
|
422
|
-
getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.
|
|
422
|
+
getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.baseName === recipe)?.variantKeyMap ?? {}
|
|
423
423
|
});
|
|
424
424
|
results.css.forEach((css2) => {
|
|
425
425
|
sheet.processAtomic(css2);
|
|
@@ -429,7 +429,7 @@ var generateStaticCss = (ctx) => {
|
|
|
429
429
|
const recipeConfig = recipes.getConfig(name);
|
|
430
430
|
if (!recipeConfig)
|
|
431
431
|
return;
|
|
432
|
-
sheet.processRecipe(recipeConfig, value);
|
|
432
|
+
sheet.processRecipe(name, recipeConfig, value);
|
|
433
433
|
});
|
|
434
434
|
});
|
|
435
435
|
const output = sheet.toCss({ optimize });
|
|
@@ -893,7 +893,7 @@ function generatePattern(ctx) {
|
|
|
893
893
|
if (ctx.patterns.isEmpty())
|
|
894
894
|
return;
|
|
895
895
|
return ctx.patterns.details.map((pattern) => {
|
|
896
|
-
const {
|
|
896
|
+
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
897
897
|
const { properties, transform, strict, description } = config;
|
|
898
898
|
const transformFn = (0, import_javascript_stringify.stringify)({ transform }) ?? "";
|
|
899
899
|
const helperImports = ["mapObject"];
|
|
@@ -929,7 +929,7 @@ function generatePattern(ctx) {
|
|
|
929
929
|
}).join("\n ")}
|
|
930
930
|
}
|
|
931
931
|
|
|
932
|
-
${strict ? import_outdent10.outdent`export declare function ${
|
|
932
|
+
${strict ? import_outdent10.outdent`export declare function ${baseName}(options: ${upperName}Properties): string` : import_outdent10.outdent`
|
|
933
933
|
|
|
934
934
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
935
935
|
|
|
@@ -939,7 +939,7 @@ function generatePattern(ctx) {
|
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
${description ? `/** ${description} */` : ""}
|
|
942
|
-
export declare const ${
|
|
942
|
+
export declare const ${baseName}: ${upperName}PatternFn;
|
|
943
943
|
`}
|
|
944
944
|
|
|
945
945
|
`,
|
|
@@ -947,13 +947,13 @@ function generatePattern(ctx) {
|
|
|
947
947
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
948
948
|
${ctx.file.import("css", "../css/index")}
|
|
949
949
|
|
|
950
|
-
const ${
|
|
950
|
+
const ${baseName}Config = ${transformFn.replace(`{transform`, `{
|
|
951
951
|
transform`)}
|
|
952
952
|
|
|
953
|
-
export const ${styleFnName} = (styles = {}) => ${
|
|
953
|
+
export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
|
|
954
954
|
|
|
955
|
-
export const ${
|
|
956
|
-
${
|
|
955
|
+
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
956
|
+
${baseName}.raw = (styles) => styles
|
|
957
957
|
`
|
|
958
958
|
};
|
|
959
959
|
});
|
|
@@ -1018,19 +1018,19 @@ function generateRecipes(ctx) {
|
|
|
1018
1018
|
return [
|
|
1019
1019
|
createRecipeFn,
|
|
1020
1020
|
...ctx.recipes.details.map((recipe) => {
|
|
1021
|
-
const { config, upperName, variantKeyMap, dashName } = recipe;
|
|
1022
|
-
const {
|
|
1021
|
+
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
1022
|
+
const { description, defaultVariants, compoundVariants } = config;
|
|
1023
1023
|
return {
|
|
1024
1024
|
name: dashName,
|
|
1025
1025
|
js: import_outdent11.outdent`
|
|
1026
1026
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1027
1027
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1028
1028
|
|
|
1029
|
-
const ${
|
|
1029
|
+
const ${baseName}Fn = createRecipe('${baseName}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
|
|
1030
1030
|
compoundVariants ?? []
|
|
1031
1031
|
)})
|
|
1032
1032
|
|
|
1033
|
-
export const ${
|
|
1033
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1034
1034
|
__recipe__: true,
|
|
1035
1035
|
raw: (props) => props,
|
|
1036
1036
|
variantKeys: ${stringify3(Object.keys(variantKeyMap))},
|
|
@@ -1071,7 +1071,7 @@ function generateRecipes(ctx) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
1073
|
${description ? `/** ${description} */` : ""}
|
|
1074
|
-
export declare const ${
|
|
1074
|
+
export declare const ${baseName}: ${upperName}Recipe
|
|
1075
1075
|
`
|
|
1076
1076
|
};
|
|
1077
1077
|
})
|
|
@@ -2745,12 +2745,12 @@ var composition_d_ts_default = {
|
|
|
2745
2745
|
|
|
2746
2746
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2747
2747
|
var recipe_d_ts_default = {
|
|
2748
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<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\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\n /**\n * The name of the recipe.\n */\n
|
|
2748
|
+
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<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\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\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"
|
|
2749
2749
|
};
|
|
2750
2750
|
|
|
2751
2751
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2752
2752
|
var pattern_d_ts_default = {
|
|
2753
|
-
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 type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type 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 css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n
|
|
2753
|
+
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 type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type 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 css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\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"
|
|
2754
2754
|
};
|
|
2755
2755
|
|
|
2756
2756
|
// src/artifacts/generated/parts.d.ts.json
|
|
@@ -3204,21 +3204,21 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3204
3204
|
sheet.processStyleProps(data);
|
|
3205
3205
|
});
|
|
3206
3206
|
});
|
|
3207
|
-
result2.recipe.forEach((recipeSet,
|
|
3207
|
+
result2.recipe.forEach((recipeSet, recipeName) => {
|
|
3208
3208
|
try {
|
|
3209
3209
|
for (const recipe of recipeSet) {
|
|
3210
|
-
const recipeConfig = recipes.getConfig(
|
|
3210
|
+
const recipeConfig = recipes.getConfig(recipeName);
|
|
3211
3211
|
if (!recipeConfig)
|
|
3212
3212
|
continue;
|
|
3213
|
-
(0, import_ts_pattern6.match)(recipe).with({ type: "jsx-recipe"
|
|
3213
|
+
(0, import_ts_pattern6.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3214
3214
|
recipe.data.forEach((data) => {
|
|
3215
|
-
const [recipeProps, styleProps] = recipes.splitProps(
|
|
3215
|
+
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3216
3216
|
sheet.processStyleProps(styleProps);
|
|
3217
|
-
sheet.processRecipe(recipeConfig, recipeProps);
|
|
3217
|
+
sheet.processRecipe(recipeName, recipeConfig, recipeProps);
|
|
3218
3218
|
});
|
|
3219
3219
|
}).otherwise(() => {
|
|
3220
3220
|
recipe.data.forEach((data) => {
|
|
3221
|
-
sheet.processRecipe(recipeConfig, data);
|
|
3221
|
+
sheet.processRecipe(recipeName, recipeConfig, data);
|
|
3222
3222
|
});
|
|
3223
3223
|
});
|
|
3224
3224
|
}
|
|
@@ -3229,9 +3229,9 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3229
3229
|
result2.pattern.forEach((patternSet, name) => {
|
|
3230
3230
|
try {
|
|
3231
3231
|
for (const pattern of patternSet) {
|
|
3232
|
-
(0, import_ts_pattern6.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern6.P.string }, ({ name:
|
|
3232
|
+
(0, import_ts_pattern6.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern6.P.string }, ({ name: jsxName }) => {
|
|
3233
3233
|
pattern.data.forEach((data) => {
|
|
3234
|
-
const fnName = patterns.getFnName(
|
|
3234
|
+
const fnName = patterns.getFnName(jsxName);
|
|
3235
3235
|
const styleProps = patterns.transform(fnName, data);
|
|
3236
3236
|
sheet.processStyleProps(styleProps);
|
|
3237
3237
|
});
|
|
@@ -3381,52 +3381,51 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
|
3381
3381
|
|
|
3382
3382
|
// src/engines/pattern.ts
|
|
3383
3383
|
var import_shared7 = require("@pandacss/shared");
|
|
3384
|
-
var import_lil_fp2 = require("lil-fp");
|
|
3385
3384
|
var helpers2 = { map: import_shared7.mapObject };
|
|
3385
|
+
var createRegex = (item) => {
|
|
3386
|
+
const regex = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
|
|
3387
|
+
return new RegExp(`^${regex}$`);
|
|
3388
|
+
};
|
|
3386
3389
|
var getPatternEngine = (config) => {
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
}
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
baseName: name
|
|
3421
|
-
}));
|
|
3390
|
+
const patterns = config.patterns ?? {};
|
|
3391
|
+
const getNames = (name) => {
|
|
3392
|
+
const upperName = (0, import_shared7.capitalize)(name);
|
|
3393
|
+
return {
|
|
3394
|
+
upperName,
|
|
3395
|
+
baseName: name,
|
|
3396
|
+
dashName: (0, import_shared7.dashCase)(name),
|
|
3397
|
+
styleFnName: `get${upperName}Style`,
|
|
3398
|
+
jsxName: patterns[name]?.jsxName ?? upperName
|
|
3399
|
+
};
|
|
3400
|
+
};
|
|
3401
|
+
const details = Object.entries(patterns).map(([name, pattern]) => {
|
|
3402
|
+
const names = getNames(name);
|
|
3403
|
+
const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
|
|
3404
|
+
return {
|
|
3405
|
+
...names,
|
|
3406
|
+
props: Object.keys(pattern?.properties ?? {}),
|
|
3407
|
+
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
|
|
3408
|
+
config: pattern,
|
|
3409
|
+
type: "pattern",
|
|
3410
|
+
match: createRegex(jsx),
|
|
3411
|
+
jsx
|
|
3412
|
+
};
|
|
3413
|
+
});
|
|
3414
|
+
return {
|
|
3415
|
+
getConfig: (name) => patterns[name],
|
|
3416
|
+
transform: (name, data) => {
|
|
3417
|
+
return patterns[name]?.transform?.(data, helpers2) ?? {};
|
|
3418
|
+
},
|
|
3419
|
+
getNames,
|
|
3420
|
+
details,
|
|
3421
|
+
getFnName: (0, import_shared7.memo)((jsxName) => {
|
|
3422
|
+
return details.find((node) => node.jsxName === jsxName)?.baseName ?? (0, import_shared7.uncapitalize)(jsxName);
|
|
3422
3423
|
}),
|
|
3423
|
-
|
|
3424
|
-
return
|
|
3424
|
+
filter: (0, import_shared7.memo)((jsxName) => {
|
|
3425
|
+
return details.filter((node) => node.match.test(jsxName));
|
|
3425
3426
|
}),
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
})
|
|
3429
|
-
);
|
|
3427
|
+
isEmpty: () => Object.keys(patterns).length === 0
|
|
3428
|
+
};
|
|
3430
3429
|
};
|
|
3431
3430
|
|
|
3432
3431
|
// src/engines/index.ts
|
|
@@ -3484,9 +3483,10 @@ var createGenerator = (conf) => {
|
|
|
3484
3483
|
jsx: {
|
|
3485
3484
|
factory: jsx.factoryName,
|
|
3486
3485
|
isStyleProp: isValidProperty,
|
|
3487
|
-
nodes: [...patterns.
|
|
3486
|
+
nodes: [...patterns.details, ...recipes.details]
|
|
3488
3487
|
},
|
|
3489
3488
|
getRecipesByJsxName: recipes.filter,
|
|
3489
|
+
getPatternsByJsxName: patterns.filter,
|
|
3490
3490
|
compilerOptions,
|
|
3491
3491
|
tsOptions: conf.tsOptions
|
|
3492
3492
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -388,7 +388,7 @@ var generateStaticCss = (ctx) => {
|
|
|
388
388
|
return [];
|
|
389
389
|
return Object.keys(values);
|
|
390
390
|
},
|
|
391
|
-
getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.
|
|
391
|
+
getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.baseName === recipe)?.variantKeyMap ?? {}
|
|
392
392
|
});
|
|
393
393
|
results.css.forEach((css2) => {
|
|
394
394
|
sheet.processAtomic(css2);
|
|
@@ -398,7 +398,7 @@ var generateStaticCss = (ctx) => {
|
|
|
398
398
|
const recipeConfig = recipes.getConfig(name);
|
|
399
399
|
if (!recipeConfig)
|
|
400
400
|
return;
|
|
401
|
-
sheet.processRecipe(recipeConfig, value);
|
|
401
|
+
sheet.processRecipe(name, recipeConfig, value);
|
|
402
402
|
});
|
|
403
403
|
});
|
|
404
404
|
const output = sheet.toCss({ optimize });
|
|
@@ -862,7 +862,7 @@ function generatePattern(ctx) {
|
|
|
862
862
|
if (ctx.patterns.isEmpty())
|
|
863
863
|
return;
|
|
864
864
|
return ctx.patterns.details.map((pattern) => {
|
|
865
|
-
const {
|
|
865
|
+
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
866
866
|
const { properties, transform, strict, description } = config;
|
|
867
867
|
const transformFn = stringify2({ transform }) ?? "";
|
|
868
868
|
const helperImports = ["mapObject"];
|
|
@@ -898,7 +898,7 @@ function generatePattern(ctx) {
|
|
|
898
898
|
}).join("\n ")}
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
-
${strict ? outdent10`export declare function ${
|
|
901
|
+
${strict ? outdent10`export declare function ${baseName}(options: ${upperName}Properties): string` : outdent10`
|
|
902
902
|
|
|
903
903
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
904
904
|
|
|
@@ -908,7 +908,7 @@ function generatePattern(ctx) {
|
|
|
908
908
|
}
|
|
909
909
|
|
|
910
910
|
${description ? `/** ${description} */` : ""}
|
|
911
|
-
export declare const ${
|
|
911
|
+
export declare const ${baseName}: ${upperName}PatternFn;
|
|
912
912
|
`}
|
|
913
913
|
|
|
914
914
|
`,
|
|
@@ -916,13 +916,13 @@ function generatePattern(ctx) {
|
|
|
916
916
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
917
917
|
${ctx.file.import("css", "../css/index")}
|
|
918
918
|
|
|
919
|
-
const ${
|
|
919
|
+
const ${baseName}Config = ${transformFn.replace(`{transform`, `{
|
|
920
920
|
transform`)}
|
|
921
921
|
|
|
922
|
-
export const ${styleFnName} = (styles = {}) => ${
|
|
922
|
+
export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
|
|
923
923
|
|
|
924
|
-
export const ${
|
|
925
|
-
${
|
|
924
|
+
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
925
|
+
${baseName}.raw = (styles) => styles
|
|
926
926
|
`
|
|
927
927
|
};
|
|
928
928
|
});
|
|
@@ -987,19 +987,19 @@ function generateRecipes(ctx) {
|
|
|
987
987
|
return [
|
|
988
988
|
createRecipeFn,
|
|
989
989
|
...ctx.recipes.details.map((recipe) => {
|
|
990
|
-
const { config, upperName, variantKeyMap, dashName } = recipe;
|
|
991
|
-
const {
|
|
990
|
+
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
991
|
+
const { description, defaultVariants, compoundVariants } = config;
|
|
992
992
|
return {
|
|
993
993
|
name: dashName,
|
|
994
994
|
js: outdent11`
|
|
995
995
|
${ctx.file.import("splitProps", "../helpers")}
|
|
996
996
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
997
997
|
|
|
998
|
-
const ${
|
|
998
|
+
const ${baseName}Fn = createRecipe('${baseName}', ${stringify3(defaultVariants ?? {})}, ${stringify3(
|
|
999
999
|
compoundVariants ?? []
|
|
1000
1000
|
)})
|
|
1001
1001
|
|
|
1002
|
-
export const ${
|
|
1002
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1003
1003
|
__recipe__: true,
|
|
1004
1004
|
raw: (props) => props,
|
|
1005
1005
|
variantKeys: ${stringify3(Object.keys(variantKeyMap))},
|
|
@@ -1040,7 +1040,7 @@ function generateRecipes(ctx) {
|
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
1042
|
${description ? `/** ${description} */` : ""}
|
|
1043
|
-
export declare const ${
|
|
1043
|
+
export declare const ${baseName}: ${upperName}Recipe
|
|
1044
1044
|
`
|
|
1045
1045
|
};
|
|
1046
1046
|
})
|
|
@@ -2714,12 +2714,12 @@ var composition_d_ts_default = {
|
|
|
2714
2714
|
|
|
2715
2715
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2716
2716
|
var recipe_d_ts_default = {
|
|
2717
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<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\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\n /**\n * The name of the recipe.\n */\n
|
|
2717
|
+
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never\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<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\nexport type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<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\nexport type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {\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"
|
|
2718
2718
|
};
|
|
2719
2719
|
|
|
2720
2720
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2721
2721
|
var pattern_d_ts_default = {
|
|
2722
|
-
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 type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type 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 css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n
|
|
2722
|
+
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 type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type 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 css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\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"
|
|
2723
2723
|
};
|
|
2724
2724
|
|
|
2725
2725
|
// src/artifacts/generated/parts.d.ts.json
|
|
@@ -3173,21 +3173,21 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3173
3173
|
sheet.processStyleProps(data);
|
|
3174
3174
|
});
|
|
3175
3175
|
});
|
|
3176
|
-
result2.recipe.forEach((recipeSet,
|
|
3176
|
+
result2.recipe.forEach((recipeSet, recipeName) => {
|
|
3177
3177
|
try {
|
|
3178
3178
|
for (const recipe of recipeSet) {
|
|
3179
|
-
const recipeConfig = recipes.getConfig(
|
|
3179
|
+
const recipeConfig = recipes.getConfig(recipeName);
|
|
3180
3180
|
if (!recipeConfig)
|
|
3181
3181
|
continue;
|
|
3182
|
-
match6(recipe).with({ type: "jsx-recipe"
|
|
3182
|
+
match6(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3183
3183
|
recipe.data.forEach((data) => {
|
|
3184
|
-
const [recipeProps, styleProps] = recipes.splitProps(
|
|
3184
|
+
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3185
3185
|
sheet.processStyleProps(styleProps);
|
|
3186
|
-
sheet.processRecipe(recipeConfig, recipeProps);
|
|
3186
|
+
sheet.processRecipe(recipeName, recipeConfig, recipeProps);
|
|
3187
3187
|
});
|
|
3188
3188
|
}).otherwise(() => {
|
|
3189
3189
|
recipe.data.forEach((data) => {
|
|
3190
|
-
sheet.processRecipe(recipeConfig, data);
|
|
3190
|
+
sheet.processRecipe(recipeName, recipeConfig, data);
|
|
3191
3191
|
});
|
|
3192
3192
|
});
|
|
3193
3193
|
}
|
|
@@ -3198,9 +3198,9 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3198
3198
|
result2.pattern.forEach((patternSet, name) => {
|
|
3199
3199
|
try {
|
|
3200
3200
|
for (const pattern of patternSet) {
|
|
3201
|
-
match6(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name:
|
|
3201
|
+
match6(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
|
|
3202
3202
|
pattern.data.forEach((data) => {
|
|
3203
|
-
const fnName = patterns.getFnName(
|
|
3203
|
+
const fnName = patterns.getFnName(jsxName);
|
|
3204
3204
|
const styleProps = patterns.transform(fnName, data);
|
|
3205
3205
|
sheet.processStyleProps(styleProps);
|
|
3206
3206
|
});
|
|
@@ -3355,53 +3355,52 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
|
3355
3355
|
};
|
|
3356
3356
|
|
|
3357
3357
|
// src/engines/pattern.ts
|
|
3358
|
-
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, uncapitalize } from "@pandacss/shared";
|
|
3359
|
-
import { Obj, pipe as pipe2 } from "lil-fp";
|
|
3358
|
+
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, memo as memo2, uncapitalize } from "@pandacss/shared";
|
|
3360
3359
|
var helpers2 = { map: mapObject2 };
|
|
3360
|
+
var createRegex = (item) => {
|
|
3361
|
+
const regex = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
|
|
3362
|
+
return new RegExp(`^${regex}$`);
|
|
3363
|
+
};
|
|
3361
3364
|
var getPatternEngine = (config) => {
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
baseName: name
|
|
3396
|
-
}));
|
|
3365
|
+
const patterns = config.patterns ?? {};
|
|
3366
|
+
const getNames = (name) => {
|
|
3367
|
+
const upperName = capitalize3(name);
|
|
3368
|
+
return {
|
|
3369
|
+
upperName,
|
|
3370
|
+
baseName: name,
|
|
3371
|
+
dashName: dashCase(name),
|
|
3372
|
+
styleFnName: `get${upperName}Style`,
|
|
3373
|
+
jsxName: patterns[name]?.jsxName ?? upperName
|
|
3374
|
+
};
|
|
3375
|
+
};
|
|
3376
|
+
const details = Object.entries(patterns).map(([name, pattern]) => {
|
|
3377
|
+
const names = getNames(name);
|
|
3378
|
+
const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
|
|
3379
|
+
return {
|
|
3380
|
+
...names,
|
|
3381
|
+
props: Object.keys(pattern?.properties ?? {}),
|
|
3382
|
+
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
|
|
3383
|
+
config: pattern,
|
|
3384
|
+
type: "pattern",
|
|
3385
|
+
match: createRegex(jsx),
|
|
3386
|
+
jsx
|
|
3387
|
+
};
|
|
3388
|
+
});
|
|
3389
|
+
return {
|
|
3390
|
+
getConfig: (name) => patterns[name],
|
|
3391
|
+
transform: (name, data) => {
|
|
3392
|
+
return patterns[name]?.transform?.(data, helpers2) ?? {};
|
|
3393
|
+
},
|
|
3394
|
+
getNames,
|
|
3395
|
+
details,
|
|
3396
|
+
getFnName: memo2((jsxName) => {
|
|
3397
|
+
return details.find((node) => node.jsxName === jsxName)?.baseName ?? uncapitalize(jsxName);
|
|
3397
3398
|
}),
|
|
3398
|
-
|
|
3399
|
-
return
|
|
3399
|
+
filter: memo2((jsxName) => {
|
|
3400
|
+
return details.filter((node) => node.match.test(jsxName));
|
|
3400
3401
|
}),
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
})
|
|
3404
|
-
);
|
|
3402
|
+
isEmpty: () => Object.keys(patterns).length === 0
|
|
3403
|
+
};
|
|
3405
3404
|
};
|
|
3406
3405
|
|
|
3407
3406
|
// src/engines/index.ts
|
|
@@ -3459,9 +3458,10 @@ var createGenerator = (conf) => {
|
|
|
3459
3458
|
jsx: {
|
|
3460
3459
|
factory: jsx.factoryName,
|
|
3461
3460
|
isStyleProp: isValidProperty,
|
|
3462
|
-
nodes: [...patterns.
|
|
3461
|
+
nodes: [...patterns.details, ...recipes.details]
|
|
3463
3462
|
},
|
|
3464
3463
|
getRecipesByJsxName: recipes.filter,
|
|
3464
|
+
getPatternsByJsxName: patterns.filter,
|
|
3465
3465
|
compilerOptions,
|
|
3466
3466
|
tsOptions: conf.tsOptions
|
|
3467
3467
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.25",
|
|
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/token-dictionary": "0.
|
|
28
|
-
"@pandacss/types": "0.
|
|
23
|
+
"@pandacss/core": "0.9.0",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.9.0",
|
|
25
|
+
"@pandacss/logger": "0.9.0",
|
|
26
|
+
"@pandacss/shared": "0.9.0",
|
|
27
|
+
"@pandacss/token-dictionary": "0.9.0",
|
|
28
|
+
"@pandacss/types": "0.9.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.9.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|