@pandacss/generator 0.0.0-dev-20230523074619 → 0.0.0-dev-20230523173112

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.
Files changed (3) hide show
  1. package/dist/index.js +274 -180
  2. package/dist/index.mjs +246 -152
  3. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -127,8 +127,52 @@ var getMessages = (ctx) => ({
127
127
  var import_lil_fp4 = require("lil-fp");
128
128
 
129
129
  // src/artifacts/index.ts
130
+ var import_shared4 = require("@pandacss/shared");
130
131
  var import_outdent25 = __toESM(require("outdent"));
131
132
 
133
+ // src/artifacts/css/global-css.ts
134
+ var generateGlobalCss = (ctx) => {
135
+ const { globalCss = {}, optimize = true } = ctx.config;
136
+ const sheet = ctx.createSheet();
137
+ sheet.processGlobalCss({
138
+ ":root": {
139
+ "--made-with-panda": `'\u{1F43C}'`
140
+ },
141
+ "*, *::before, *::after, ::backdrop": {
142
+ "--blur": "/*!*/ /*!*/",
143
+ "--brightness": "/*!*/ /*!*/",
144
+ "--contrast": "/*!*/ /*!*/",
145
+ "--grayscale": "/*!*/ /*!*/",
146
+ "--hue-rotate": "/*!*/ /*!*/",
147
+ "--invert": "/*!*/ /*!*/",
148
+ "--saturate": "/*!*/ /*!*/",
149
+ "--sepia": "/*!*/ /*!*/",
150
+ "--drop-shadow": "/*!*/ /*!*/",
151
+ "--backdrop-blur": "/*!*/ /*!*/",
152
+ "--backdrop-brightness": "/*!*/ /*!*/",
153
+ "--backdrop-contrast": "/*!*/ /*!*/",
154
+ "--backdrop-grayscale": "/*!*/ /*!*/",
155
+ "--backdrop-hue-rotate": "/*!*/ /*!*/",
156
+ "--backdrop-invert": "/*!*/ /*!*/",
157
+ "--backdrop-opacity": "/*!*/ /*!*/",
158
+ "--backdrop-saturate": "/*!*/ /*!*/",
159
+ "--backdrop-sepia": "/*!*/ /*!*/",
160
+ "--scroll-snap-strictness": "proximity",
161
+ "--border-spacing-x": 0,
162
+ "--border-spacing-y": 0,
163
+ "--translate-x": 0,
164
+ "--translate-y": 0,
165
+ "--rotate": 0,
166
+ "--skew-x": 0,
167
+ "--skew-y": 0,
168
+ "--scale-x": 1,
169
+ "--scale-y": 1
170
+ }
171
+ });
172
+ sheet.processGlobalCss(globalCss);
173
+ return sheet.toCss({ optimize });
174
+ };
175
+
132
176
  // src/artifacts/css/keyframe-css.ts
133
177
  var import_core = require("@pandacss/core");
134
178
  var import_postcss = __toESM(require("postcss"));
@@ -154,106 +198,223 @@ function generateKeyframeCss(ctx) {
154
198
 
155
199
  // src/artifacts/css/reset-css.ts
156
200
  var css = String.raw;
157
- var reset = css`
158
- * {
159
- margin: 0;
160
- padding: 0;
161
- font: inherit;
162
- }
201
+ function generateResetCss(scope = "") {
202
+ const selector = scope ? `${scope} ` : "";
203
+ return css`
204
+ @layer reset {
205
+ ${selector}* {
206
+ margin: 0;
207
+ padding: 0;
208
+ font: inherit;
209
+ }
163
210
 
164
- *,
165
- *::before,
166
- *::after {
167
- box-sizing: border-box;
168
- border-width: 0;
169
- border-style: solid;
170
- }
211
+ ${selector}*,
212
+ ${selector}*::before,
213
+ ${selector}*::after {
214
+ box-sizing: border-box;
215
+ border-width: 0;
216
+ border-style: solid;
217
+ }
171
218
 
172
- html,
173
- body {
174
- height: 100%;
175
- }
219
+ ${scope || "html"} {
220
+ line-height: 1.5;
221
+ -webkit-text-size-adjust: 100%;
222
+ -webkit-text-size-adjust: 100%;
223
+ -webkit-font-smoothing: antialiased;
224
+ -moz-tab-size: 4;
225
+ tab-size: 4;
226
+ }
176
227
 
177
- body {
178
- line-height: 1.5;
179
- -webkit-text-size-adjust: 100%;
180
- -webkit-font-smoothing: antialiased;
181
- }
228
+ ${selector}hr {
229
+ height: 0;
230
+ color: inherit;
231
+ border-top-width: 1px;
232
+ }
182
233
 
183
- img {
184
- border-style: none;
185
- }
234
+ body {
235
+ height: 100%;
236
+ line-height: inherit;
237
+ }
186
238
 
187
- img,
188
- picture,
189
- video,
190
- canvas,
191
- svg {
192
- display: block;
193
- max-width: 100%;
194
- }
239
+ ${selector}img {
240
+ border-style: none;
241
+ }
195
242
 
196
- p,
197
- h1,
198
- h2,
199
- h3,
200
- h4,
201
- h5,
202
- h6 {
203
- overflow-wrap: break-word;
204
- }
243
+ ${selector}img,
244
+ ${selector}svg,
245
+ ${selector}video,
246
+ ${selector}canvas,
247
+ ${selector}audio,
248
+ ${selector}iframe,
249
+ ${selector}embed,
250
+ ${selector}object {
251
+ display: block;
252
+ vertical-align: middle;
253
+ }
205
254
 
206
- ::-webkit-search-decoration {
207
- -webkit-appearance: none;
208
- appearance: none;
209
- }
255
+ ${selector}img,
256
+ ${selector}video {
257
+ max-width: 100%;
258
+ height: auto;
259
+ }
210
260
 
211
- ::-webkit-file-upload-button {
212
- -webkit-appearance: button;
213
- appearance: none;
214
- font: inherit;
215
- }
261
+ ${selector}p,
262
+ ${selector}h1,
263
+ ${selector}h2,
264
+ ${selector}h3,
265
+ ${selector}h4,
266
+ ${selector}h5,
267
+ ${selector}h6 {
268
+ overflow-wrap: break-word;
269
+ }
216
270
 
217
- ::-webkit-inner-spin-button,
218
- ::-webkit-outer-spin-button {
219
- height: auto;
220
- }
271
+ ${selector}ol,
272
+ ${selector}ul {
273
+ list-style: none;
274
+ }
221
275
 
222
- code,
223
- kbd,
224
- pre,
225
- samp {
226
- font-size: 1em;
227
- }
276
+ ${selector}code,
277
+ ${selector}kbd,
278
+ ${selector}pre,
279
+ ${selector}samp {
280
+ font-size: 1em;
281
+ }
228
282
 
229
- table {
230
- border-collapse: collapse;
231
- }
283
+ ${selector}button,
284
+ ${selector}[type='button'],
285
+ ${selector}[type='reset'],
286
+ ${selector}[type='submit'] {
287
+ -webkit-appearance: button;
288
+ background-color: transparent;
289
+ background-image: none;
290
+ }
232
291
 
233
- textarea {
234
- resize: vertical;
235
- }
292
+ ${selector}button,
293
+ ${selector}select {
294
+ text-transform: none;
295
+ }
236
296
 
237
- sub {
238
- bottom: -0.25em;
239
- }
297
+ ${selector}table {
298
+ text-indent: 0;
299
+ border-color: inherit;
300
+ border-collapse: collapse;
301
+ }
240
302
 
241
- sup {
242
- top: -0.5em;
243
- }
303
+ ${selector}input::placeholder,
304
+ ${selector}textarea::placeholder {
305
+ opacity: 1;
306
+ }
244
307
 
245
- dialog {
246
- padding: 0;
247
- }
248
- `;
249
- function generateResetCss() {
250
- return `@layer reset {
251
- ${reset}
252
- }`;
308
+ ${selector}textarea {
309
+ resize: vertical;
310
+ }
311
+
312
+ ${selector}summary {
313
+ display: list-item;
314
+ }
315
+
316
+ ${selector}small {
317
+ font-size: 80%;
318
+ }
319
+
320
+ ${selector}sub,
321
+ ${selector}sup {
322
+ font-size: 75%;
323
+ line-height: 0;
324
+ position: relative;
325
+ vertical-align: baseline;
326
+ }
327
+
328
+ ${selector}sub {
329
+ bottom: -0.25em;
330
+ }
331
+
332
+ ${selector}sup {
333
+ top: -0.5em;
334
+ }
335
+
336
+ ${selector}dialog {
337
+ padding: 0;
338
+ }
339
+
340
+ ${selector}a {
341
+ color: inherit;
342
+ text-decoration: inherit;
343
+ }
344
+
345
+ ${selector}abbr:where([title]) {
346
+ text-decoration: underline dotted;
347
+ }
348
+
349
+ ${selector}b,
350
+ ${selector}strong {
351
+ font-weight: bolder;
352
+ }
353
+
354
+ ${selector}code,
355
+ ${selector}kbd,
356
+ ${selector}samp,
357
+ ${selector}pre {
358
+ font-size: 1em;
359
+ }
360
+
361
+ ${selector}[type='search'] {
362
+ -webkit-appearance: textfield;
363
+ outline-offset: -2px;
364
+ }
365
+
366
+ ${selector}::-webkit-search-decoration {
367
+ -webkit-appearance: none;
368
+ }
369
+
370
+ ${selector}::-webkit-file-upload-button {
371
+ -webkit-appearance: button;
372
+ }
373
+
374
+ ${selector}::-webkit-inner-spin-button,
375
+ ${selector}::-webkit-outer-spin-button {
376
+ height: auto;
377
+ }
378
+
379
+ ${selector}:-moz-ui-invalid {
380
+ box-shadow: none;
381
+ }
382
+
383
+ ${selector}:-moz-focusring {
384
+ outline: auto;
385
+ }
386
+ }
387
+ `;
253
388
  }
254
389
 
255
- // src/artifacts/css/token-css.ts
390
+ // src/artifacts/css/static-css.ts
256
391
  var import_core2 = require("@pandacss/core");
392
+ var generateStaticCss = (ctx) => {
393
+ const { config, createSheet, utility, recipes } = ctx;
394
+ const { staticCss = {}, theme = {}, optimize = true } = config;
395
+ const sheet = createSheet();
396
+ const fn = (0, import_core2.getStaticCss)(staticCss);
397
+ const results = fn({
398
+ breakpoints: Object.keys(theme.breakpoints ?? {}),
399
+ getPropertyKeys: utility.getPropertyKeys,
400
+ getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
401
+ });
402
+ results.css.forEach((css2) => {
403
+ sheet.processAtomic(css2);
404
+ });
405
+ results.recipes.forEach((result) => {
406
+ Object.entries(result).forEach(([name, value]) => {
407
+ const recipeConfig = recipes.getConfig(name);
408
+ if (!recipeConfig)
409
+ return;
410
+ sheet.processRecipe(recipeConfig, value);
411
+ });
412
+ });
413
+ return sheet.toCss({ optimize });
414
+ };
415
+
416
+ // src/artifacts/css/token-css.ts
417
+ var import_core3 = require("@pandacss/core");
257
418
  var import_postcss2 = __toESM(require("postcss"));
258
419
  function generateTokenCss(ctx) {
259
420
  const {
@@ -268,25 +429,25 @@ function generateTokenCss(ctx) {
268
429
  if (Object.keys(varsObj).length === 0)
269
430
  continue;
270
431
  if (key === "base") {
271
- const { css: css3 } = (0, import_core2.toCss)({ [root]: varsObj });
432
+ const { css: css3 } = (0, import_core3.toCss)({ [root]: varsObj });
272
433
  results.push(css3);
273
434
  } else {
274
435
  const keys = key.split(":");
275
- const { css: css3 } = (0, import_core2.toCss)(varsObj);
436
+ const { css: css3 } = (0, import_core3.toCss)(varsObj);
276
437
  const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
277
- const parent = (0, import_core2.extractParentSelectors)(condition);
438
+ const parent = (0, import_core3.extractParentSelectors)(condition);
278
439
  return parent ? `&${parent}` : condition;
279
440
  });
280
441
  const rule = getDeepestRule(root, mapped);
281
442
  if (!rule)
282
443
  continue;
283
444
  getDeepestNode(rule)?.append(css3);
284
- results.push((0, import_core2.expandNestedCss)(rule.toString()));
445
+ results.push((0, import_core3.expandNestedCss)(rule.toString()));
285
446
  }
286
447
  }
287
448
  const css2 = results.join("\n\n");
288
449
  return `@layer tokens {
289
- ${(0, import_core2.prettifyCss)(cleanupSelectors(css2, root))}
450
+ ${(0, import_core3.prettifyCss)(cleanupSelectors(css2, root))}
290
451
  }
291
452
  `;
292
453
  }
@@ -1732,75 +1893,6 @@ function generateTokenTypes(ctx) {
1732
1893
  return import_outdent24.outdent.string(Array.from(set).join("\n\n"));
1733
1894
  }
1734
1895
 
1735
- // src/artifacts/css/global-css.ts
1736
- var generateGlobalCss = (ctx) => {
1737
- const { globalCss = {}, optimize = true } = ctx.config;
1738
- const sheet = ctx.createSheet();
1739
- sheet.processGlobalCss({
1740
- ":root": {
1741
- "--made-with-panda": `'\u{1F43C}'`
1742
- },
1743
- "*, *::before, *::after, ::backdrop": {
1744
- "--blur": "/*!*/ /*!*/",
1745
- "--brightness": "/*!*/ /*!*/",
1746
- "--contrast": "/*!*/ /*!*/",
1747
- "--grayscale": "/*!*/ /*!*/",
1748
- "--hue-rotate": "/*!*/ /*!*/",
1749
- "--invert": "/*!*/ /*!*/",
1750
- "--saturate": "/*!*/ /*!*/",
1751
- "--sepia": "/*!*/ /*!*/",
1752
- "--drop-shadow": "/*!*/ /*!*/",
1753
- "--backdrop-blur": "/*!*/ /*!*/",
1754
- "--backdrop-brightness": "/*!*/ /*!*/",
1755
- "--backdrop-contrast": "/*!*/ /*!*/",
1756
- "--backdrop-grayscale": "/*!*/ /*!*/",
1757
- "--backdrop-hue-rotate": "/*!*/ /*!*/",
1758
- "--backdrop-invert": "/*!*/ /*!*/",
1759
- "--backdrop-opacity": "/*!*/ /*!*/",
1760
- "--backdrop-saturate": "/*!*/ /*!*/",
1761
- "--backdrop-sepia": "/*!*/ /*!*/",
1762
- "--scroll-snap-strictness": "proximity",
1763
- "--border-spacing-x": 0,
1764
- "--border-spacing-y": 0,
1765
- "--translate-x": 0,
1766
- "--translate-y": 0,
1767
- "--rotate": 0,
1768
- "--skew-x": 0,
1769
- "--skew-y": 0,
1770
- "--scale-x": 1,
1771
- "--scale-y": 1
1772
- }
1773
- });
1774
- sheet.processGlobalCss(globalCss);
1775
- return sheet.toCss({ optimize });
1776
- };
1777
-
1778
- // src/artifacts/css/static-css.ts
1779
- var import_core3 = require("@pandacss/core");
1780
- var generateStaticCss = (ctx) => {
1781
- const { config, createSheet, utility, recipes } = ctx;
1782
- const { staticCss = {}, theme = {}, optimize = true } = config;
1783
- const sheet = createSheet();
1784
- const fn = (0, import_core3.getStaticCss)(staticCss);
1785
- const results = fn({
1786
- breakpoints: Object.keys(theme.breakpoints ?? {}),
1787
- getPropertyKeys: utility.getPropertyKeys,
1788
- getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
1789
- });
1790
- results.css.forEach((css2) => {
1791
- sheet.processAtomic(css2);
1792
- });
1793
- results.recipes.forEach((result) => {
1794
- Object.entries(result).forEach(([name, value]) => {
1795
- const recipeConfig = recipes.getConfig(name);
1796
- if (!recipeConfig)
1797
- return;
1798
- sheet.processRecipe(recipeConfig, value);
1799
- });
1800
- });
1801
- return sheet.toCss({ optimize });
1802
- };
1803
-
1804
1896
  // src/artifacts/index.ts
1805
1897
  function setupHelpers(ctx) {
1806
1898
  const code = generateHelpers();
@@ -1977,9 +2069,11 @@ function setupCssIndex(ctx) {
1977
2069
  };
1978
2070
  }
1979
2071
  function setupResetCss(ctx) {
1980
- if (!ctx.config.preflight)
2072
+ const { preflight } = ctx.config;
2073
+ if (!preflight)
1981
2074
  return;
1982
- const code = generateResetCss();
2075
+ const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
2076
+ const code = generateResetCss(scope);
1983
2077
  return { files: [{ file: "reset.css", code }] };
1984
2078
  }
1985
2079
  function setupGlobalCss(ctx) {
@@ -2125,11 +2219,11 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
2125
2219
  var import_core4 = require("@pandacss/core");
2126
2220
  var import_is_valid_prop3 = require("@pandacss/is-valid-prop");
2127
2221
  var import_logger3 = require("@pandacss/logger");
2128
- var import_shared4 = require("@pandacss/shared");
2222
+ var import_shared5 = require("@pandacss/shared");
2129
2223
  var import_token_dictionary = require("@pandacss/token-dictionary");
2130
2224
  var import_lil_fp = require("lil-fp");
2131
2225
  var import_postcss3 = __toESM(require("postcss"));
2132
- var helpers = { map: import_shared4.mapObject };
2226
+ var helpers = { map: import_shared5.mapObject };
2133
2227
  var getBaseEngine = (conf) => (0, import_lil_fp.pipe)(
2134
2228
  conf,
2135
2229
  import_lil_fp.Obj.bind("configDependencies", ({ dependencies }) => dependencies ?? []),
@@ -2150,7 +2244,7 @@ var getBaseEngine = (conf) => (0, import_lil_fp.pipe)(
2150
2244
  (0, import_lil_fp.tap)(({ conditions, utility, config: { theme } }) => {
2151
2245
  import_logger3.logger.debug("generator:conditions", conditions);
2152
2246
  const { textStyles, layerStyles } = theme ?? {};
2153
- const compositions = (0, import_shared4.compact)({ textStyle: textStyles, layerStyle: layerStyles });
2247
+ const compositions = (0, import_shared5.compact)({ textStyle: textStyles, layerStyle: layerStyles });
2154
2248
  (0, import_core4.assignCompositions)({ conditions, utility }, compositions);
2155
2249
  }),
2156
2250
  import_lil_fp.Obj.bind("createSheet", ({ conditions, utility, config: { hash } }) => (options) => {
@@ -2163,21 +2257,21 @@ var getBaseEngine = (conf) => (0, import_lil_fp.pipe)(
2163
2257
  ),
2164
2258
  import_lil_fp.Obj.bind("isValidProperty", ({ properties }) => {
2165
2259
  const propertyMap = new Map(properties.map((prop) => [prop, true]));
2166
- return (0, import_shared4.memo)((key) => {
2260
+ return (0, import_shared5.memo)((key) => {
2167
2261
  return propertyMap.has(key) || (0, import_is_valid_prop3.isCssProperty)(key);
2168
2262
  });
2169
2263
  })
2170
2264
  );
2171
2265
 
2172
2266
  // src/engines/jsx.ts
2173
- var import_shared5 = require("@pandacss/shared");
2267
+ var import_shared6 = require("@pandacss/shared");
2174
2268
  var getJsxEngine = (config) => {
2175
2269
  const { jsxFactory, jsxFramework } = config;
2176
2270
  return {
2177
2271
  factoryName: jsxFactory,
2178
- upperName: (0, import_shared5.capitalize)(jsxFactory),
2179
- typeName: `HTML${(0, import_shared5.capitalize)(jsxFactory)}Props`,
2180
- componentName: `${(0, import_shared5.capitalize)(jsxFactory)}Component`,
2272
+ upperName: (0, import_shared6.capitalize)(jsxFactory),
2273
+ typeName: `HTML${(0, import_shared6.capitalize)(jsxFactory)}Props`,
2274
+ componentName: `${(0, import_shared6.capitalize)(jsxFactory)}Component`,
2181
2275
  framework: jsxFramework
2182
2276
  };
2183
2277
  };
@@ -2200,9 +2294,9 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
2200
2294
  };
2201
2295
 
2202
2296
  // src/engines/pattern.ts
2203
- var import_shared6 = require("@pandacss/shared");
2297
+ var import_shared7 = require("@pandacss/shared");
2204
2298
  var import_lil_fp2 = require("lil-fp");
2205
- var helpers2 = { map: import_shared6.mapObject };
2299
+ var helpers2 = { map: import_shared7.mapObject };
2206
2300
  var getPatternEngine = (config) => {
2207
2301
  return (0, import_lil_fp2.pipe)(
2208
2302
  { patterns: config.patterns ?? {} },
@@ -2215,11 +2309,11 @@ var getPatternEngine = (config) => {
2215
2309
  };
2216
2310
  }),
2217
2311
  import_lil_fp2.Obj.bind("getNames", ({ getConfig }) => (name) => {
2218
- const upperName = (0, import_shared6.capitalize)(name);
2312
+ const upperName = (0, import_shared7.capitalize)(name);
2219
2313
  return {
2220
2314
  name,
2221
2315
  upperName,
2222
- dashName: (0, import_shared6.dashCase)(name),
2316
+ dashName: (0, import_shared7.dashCase)(name),
2223
2317
  styleFnName: `get${upperName}Style`,
2224
2318
  jsxName: getConfig(name)?.jsx ?? upperName
2225
2319
  };
@@ -2235,13 +2329,13 @@ var getPatternEngine = (config) => {
2235
2329
  import_lil_fp2.Obj.bind("nodes", ({ patterns }) => {
2236
2330
  return Object.entries(patterns).map(([name, pattern]) => ({
2237
2331
  type: "pattern",
2238
- name: pattern.jsx ?? (0, import_shared6.capitalize)(name),
2332
+ name: pattern.jsx ?? (0, import_shared7.capitalize)(name),
2239
2333
  props: Object.keys(pattern.properties),
2240
2334
  baseName: name
2241
2335
  }));
2242
2336
  }),
2243
2337
  import_lil_fp2.Obj.bind("getFnName", ({ nodes }) => (jsx) => {
2244
- return nodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared6.uncapitalize)(jsx);
2338
+ return nodes.find((node) => node.name === jsx)?.baseName ?? (0, import_shared7.uncapitalize)(jsx);
2245
2339
  }),
2246
2340
  import_lil_fp2.Obj.bind("isEmpty", ({ patterns }) => {
2247
2341
  return () => Object.keys(patterns).length === 0;
@@ -2250,7 +2344,7 @@ var getPatternEngine = (config) => {
2250
2344
  };
2251
2345
 
2252
2346
  // src/engines/recipe.ts
2253
- var import_shared7 = require("@pandacss/shared");
2347
+ var import_shared8 = require("@pandacss/shared");
2254
2348
  var import_lil_fp3 = require("lil-fp");
2255
2349
  var mergeRegex = (item) => {
2256
2350
  const regex = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
@@ -2264,18 +2358,18 @@ var getRecipeEngine = (config) => {
2264
2358
  }),
2265
2359
  import_lil_fp3.Obj.bind("getNames", () => {
2266
2360
  return (name) => ({
2267
- upperName: (0, import_shared7.capitalize)(name),
2268
- dashName: (0, import_shared7.dashCase)(name),
2269
- jsxName: (0, import_shared7.capitalize)(name)
2361
+ upperName: (0, import_shared8.capitalize)(name),
2362
+ dashName: (0, import_shared8.dashCase)(name),
2363
+ jsxName: (0, import_shared8.capitalize)(name)
2270
2364
  });
2271
2365
  }),
2272
2366
  import_lil_fp3.Obj.bind("nodes", ({ recipes }) => {
2273
2367
  return Object.entries(recipes).map(([name, recipe]) => {
2274
- const jsx = recipe.jsx ?? [(0, import_shared7.capitalize)(name)];
2368
+ const jsx = recipe.jsx ?? [(0, import_shared8.capitalize)(name)];
2275
2369
  const match6 = mergeRegex(jsx);
2276
2370
  return {
2277
2371
  type: "recipe",
2278
- name: (0, import_shared7.capitalize)(name),
2372
+ name: (0, import_shared8.capitalize)(name),
2279
2373
  props: Object.keys(recipe.variants ?? {}),
2280
2374
  baseName: name,
2281
2375
  jsx,
@@ -2286,7 +2380,7 @@ var getRecipeEngine = (config) => {
2286
2380
  import_lil_fp3.Obj.bind("getFnName", ({ nodes }) => {
2287
2381
  return (jsx) => {
2288
2382
  const recipe = nodes.find((node) => node.match.test(jsx));
2289
- return recipe?.baseName ?? (0, import_shared7.uncapitalize)(jsx);
2383
+ return recipe?.baseName ?? (0, import_shared8.uncapitalize)(jsx);
2290
2384
  };
2291
2385
  }),
2292
2386
  import_lil_fp3.Obj.bind("splitProps", ({ nodes }) => {
@@ -2294,7 +2388,7 @@ var getRecipeEngine = (config) => {
2294
2388
  const recipe = nodes.find((node) => node.match.test(name));
2295
2389
  if (!recipe)
2296
2390
  return [{}, props];
2297
- return (0, import_shared7.splitProps)(props, recipe.props);
2391
+ return (0, import_shared8.splitProps)(props, recipe.props);
2298
2392
  };
2299
2393
  }),
2300
2394
  import_lil_fp3.Obj.bind("details", ({ getNames, recipes }) => {
package/dist/index.mjs CHANGED
@@ -96,8 +96,52 @@ var getMessages = (ctx) => ({
96
96
  import { Obj as Obj4, pipe as pipe5 } from "lil-fp";
97
97
 
98
98
  // src/artifacts/index.ts
99
+ import { isObject } from "@pandacss/shared";
99
100
  import outdent25 from "outdent";
100
101
 
102
+ // src/artifacts/css/global-css.ts
103
+ var generateGlobalCss = (ctx) => {
104
+ const { globalCss = {}, optimize = true } = ctx.config;
105
+ const sheet = ctx.createSheet();
106
+ sheet.processGlobalCss({
107
+ ":root": {
108
+ "--made-with-panda": `'\u{1F43C}'`
109
+ },
110
+ "*, *::before, *::after, ::backdrop": {
111
+ "--blur": "/*!*/ /*!*/",
112
+ "--brightness": "/*!*/ /*!*/",
113
+ "--contrast": "/*!*/ /*!*/",
114
+ "--grayscale": "/*!*/ /*!*/",
115
+ "--hue-rotate": "/*!*/ /*!*/",
116
+ "--invert": "/*!*/ /*!*/",
117
+ "--saturate": "/*!*/ /*!*/",
118
+ "--sepia": "/*!*/ /*!*/",
119
+ "--drop-shadow": "/*!*/ /*!*/",
120
+ "--backdrop-blur": "/*!*/ /*!*/",
121
+ "--backdrop-brightness": "/*!*/ /*!*/",
122
+ "--backdrop-contrast": "/*!*/ /*!*/",
123
+ "--backdrop-grayscale": "/*!*/ /*!*/",
124
+ "--backdrop-hue-rotate": "/*!*/ /*!*/",
125
+ "--backdrop-invert": "/*!*/ /*!*/",
126
+ "--backdrop-opacity": "/*!*/ /*!*/",
127
+ "--backdrop-saturate": "/*!*/ /*!*/",
128
+ "--backdrop-sepia": "/*!*/ /*!*/",
129
+ "--scroll-snap-strictness": "proximity",
130
+ "--border-spacing-x": 0,
131
+ "--border-spacing-y": 0,
132
+ "--translate-x": 0,
133
+ "--translate-y": 0,
134
+ "--rotate": 0,
135
+ "--skew-x": 0,
136
+ "--skew-y": 0,
137
+ "--scale-x": 1,
138
+ "--scale-y": 1
139
+ }
140
+ });
141
+ sheet.processGlobalCss(globalCss);
142
+ return sheet.toCss({ optimize });
143
+ };
144
+
101
145
  // src/artifacts/css/keyframe-css.ts
102
146
  import { toCss } from "@pandacss/core";
103
147
  import postcss from "postcss";
@@ -123,104 +167,221 @@ function generateKeyframeCss(ctx) {
123
167
 
124
168
  // src/artifacts/css/reset-css.ts
125
169
  var css = String.raw;
126
- var reset = css`
127
- * {
128
- margin: 0;
129
- padding: 0;
130
- font: inherit;
131
- }
170
+ function generateResetCss(scope = "") {
171
+ const selector = scope ? `${scope} ` : "";
172
+ return css`
173
+ @layer reset {
174
+ ${selector}* {
175
+ margin: 0;
176
+ padding: 0;
177
+ font: inherit;
178
+ }
132
179
 
133
- *,
134
- *::before,
135
- *::after {
136
- box-sizing: border-box;
137
- border-width: 0;
138
- border-style: solid;
139
- }
180
+ ${selector}*,
181
+ ${selector}*::before,
182
+ ${selector}*::after {
183
+ box-sizing: border-box;
184
+ border-width: 0;
185
+ border-style: solid;
186
+ }
140
187
 
141
- html,
142
- body {
143
- height: 100%;
144
- }
188
+ ${scope || "html"} {
189
+ line-height: 1.5;
190
+ -webkit-text-size-adjust: 100%;
191
+ -webkit-text-size-adjust: 100%;
192
+ -webkit-font-smoothing: antialiased;
193
+ -moz-tab-size: 4;
194
+ tab-size: 4;
195
+ }
145
196
 
146
- body {
147
- line-height: 1.5;
148
- -webkit-text-size-adjust: 100%;
149
- -webkit-font-smoothing: antialiased;
150
- }
197
+ ${selector}hr {
198
+ height: 0;
199
+ color: inherit;
200
+ border-top-width: 1px;
201
+ }
151
202
 
152
- img {
153
- border-style: none;
154
- }
203
+ body {
204
+ height: 100%;
205
+ line-height: inherit;
206
+ }
155
207
 
156
- img,
157
- picture,
158
- video,
159
- canvas,
160
- svg {
161
- display: block;
162
- max-width: 100%;
163
- }
208
+ ${selector}img {
209
+ border-style: none;
210
+ }
164
211
 
165
- p,
166
- h1,
167
- h2,
168
- h3,
169
- h4,
170
- h5,
171
- h6 {
172
- overflow-wrap: break-word;
173
- }
212
+ ${selector}img,
213
+ ${selector}svg,
214
+ ${selector}video,
215
+ ${selector}canvas,
216
+ ${selector}audio,
217
+ ${selector}iframe,
218
+ ${selector}embed,
219
+ ${selector}object {
220
+ display: block;
221
+ vertical-align: middle;
222
+ }
174
223
 
175
- ::-webkit-search-decoration {
176
- -webkit-appearance: none;
177
- appearance: none;
178
- }
224
+ ${selector}img,
225
+ ${selector}video {
226
+ max-width: 100%;
227
+ height: auto;
228
+ }
179
229
 
180
- ::-webkit-file-upload-button {
181
- -webkit-appearance: button;
182
- appearance: none;
183
- font: inherit;
184
- }
230
+ ${selector}p,
231
+ ${selector}h1,
232
+ ${selector}h2,
233
+ ${selector}h3,
234
+ ${selector}h4,
235
+ ${selector}h5,
236
+ ${selector}h6 {
237
+ overflow-wrap: break-word;
238
+ }
185
239
 
186
- ::-webkit-inner-spin-button,
187
- ::-webkit-outer-spin-button {
188
- height: auto;
189
- }
240
+ ${selector}ol,
241
+ ${selector}ul {
242
+ list-style: none;
243
+ }
190
244
 
191
- code,
192
- kbd,
193
- pre,
194
- samp {
195
- font-size: 1em;
196
- }
245
+ ${selector}code,
246
+ ${selector}kbd,
247
+ ${selector}pre,
248
+ ${selector}samp {
249
+ font-size: 1em;
250
+ }
197
251
 
198
- table {
199
- border-collapse: collapse;
200
- }
252
+ ${selector}button,
253
+ ${selector}[type='button'],
254
+ ${selector}[type='reset'],
255
+ ${selector}[type='submit'] {
256
+ -webkit-appearance: button;
257
+ background-color: transparent;
258
+ background-image: none;
259
+ }
201
260
 
202
- textarea {
203
- resize: vertical;
204
- }
261
+ ${selector}button,
262
+ ${selector}select {
263
+ text-transform: none;
264
+ }
205
265
 
206
- sub {
207
- bottom: -0.25em;
208
- }
266
+ ${selector}table {
267
+ text-indent: 0;
268
+ border-color: inherit;
269
+ border-collapse: collapse;
270
+ }
209
271
 
210
- sup {
211
- top: -0.5em;
212
- }
272
+ ${selector}input::placeholder,
273
+ ${selector}textarea::placeholder {
274
+ opacity: 1;
275
+ }
213
276
 
214
- dialog {
215
- padding: 0;
216
- }
217
- `;
218
- function generateResetCss() {
219
- return `@layer reset {
220
- ${reset}
221
- }`;
277
+ ${selector}textarea {
278
+ resize: vertical;
279
+ }
280
+
281
+ ${selector}summary {
282
+ display: list-item;
283
+ }
284
+
285
+ ${selector}small {
286
+ font-size: 80%;
287
+ }
288
+
289
+ ${selector}sub,
290
+ ${selector}sup {
291
+ font-size: 75%;
292
+ line-height: 0;
293
+ position: relative;
294
+ vertical-align: baseline;
295
+ }
296
+
297
+ ${selector}sub {
298
+ bottom: -0.25em;
299
+ }
300
+
301
+ ${selector}sup {
302
+ top: -0.5em;
303
+ }
304
+
305
+ ${selector}dialog {
306
+ padding: 0;
307
+ }
308
+
309
+ ${selector}a {
310
+ color: inherit;
311
+ text-decoration: inherit;
312
+ }
313
+
314
+ ${selector}abbr:where([title]) {
315
+ text-decoration: underline dotted;
316
+ }
317
+
318
+ ${selector}b,
319
+ ${selector}strong {
320
+ font-weight: bolder;
321
+ }
322
+
323
+ ${selector}code,
324
+ ${selector}kbd,
325
+ ${selector}samp,
326
+ ${selector}pre {
327
+ font-size: 1em;
328
+ }
329
+
330
+ ${selector}[type='search'] {
331
+ -webkit-appearance: textfield;
332
+ outline-offset: -2px;
333
+ }
334
+
335
+ ${selector}::-webkit-search-decoration {
336
+ -webkit-appearance: none;
337
+ }
338
+
339
+ ${selector}::-webkit-file-upload-button {
340
+ -webkit-appearance: button;
341
+ }
342
+
343
+ ${selector}::-webkit-inner-spin-button,
344
+ ${selector}::-webkit-outer-spin-button {
345
+ height: auto;
346
+ }
347
+
348
+ ${selector}:-moz-ui-invalid {
349
+ box-shadow: none;
350
+ }
351
+
352
+ ${selector}:-moz-focusring {
353
+ outline: auto;
354
+ }
355
+ }
356
+ `;
222
357
  }
223
358
 
359
+ // src/artifacts/css/static-css.ts
360
+ import { getStaticCss } from "@pandacss/core";
361
+ var generateStaticCss = (ctx) => {
362
+ const { config, createSheet, utility, recipes } = ctx;
363
+ const { staticCss = {}, theme = {}, optimize = true } = config;
364
+ const sheet = createSheet();
365
+ const fn = getStaticCss(staticCss);
366
+ const results = fn({
367
+ breakpoints: Object.keys(theme.breakpoints ?? {}),
368
+ getPropertyKeys: utility.getPropertyKeys,
369
+ getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
370
+ });
371
+ results.css.forEach((css2) => {
372
+ sheet.processAtomic(css2);
373
+ });
374
+ results.recipes.forEach((result) => {
375
+ Object.entries(result).forEach(([name, value]) => {
376
+ const recipeConfig = recipes.getConfig(name);
377
+ if (!recipeConfig)
378
+ return;
379
+ sheet.processRecipe(recipeConfig, value);
380
+ });
381
+ });
382
+ return sheet.toCss({ optimize });
383
+ };
384
+
224
385
  // src/artifacts/css/token-css.ts
225
386
  import { expandNestedCss, extractParentSelectors, prettifyCss, toCss as toCss2 } from "@pandacss/core";
226
387
  import postcss2 from "postcss";
@@ -1701,75 +1862,6 @@ function generateTokenTypes(ctx) {
1701
1862
  return outdent24.string(Array.from(set).join("\n\n"));
1702
1863
  }
1703
1864
 
1704
- // src/artifacts/css/global-css.ts
1705
- var generateGlobalCss = (ctx) => {
1706
- const { globalCss = {}, optimize = true } = ctx.config;
1707
- const sheet = ctx.createSheet();
1708
- sheet.processGlobalCss({
1709
- ":root": {
1710
- "--made-with-panda": `'\u{1F43C}'`
1711
- },
1712
- "*, *::before, *::after, ::backdrop": {
1713
- "--blur": "/*!*/ /*!*/",
1714
- "--brightness": "/*!*/ /*!*/",
1715
- "--contrast": "/*!*/ /*!*/",
1716
- "--grayscale": "/*!*/ /*!*/",
1717
- "--hue-rotate": "/*!*/ /*!*/",
1718
- "--invert": "/*!*/ /*!*/",
1719
- "--saturate": "/*!*/ /*!*/",
1720
- "--sepia": "/*!*/ /*!*/",
1721
- "--drop-shadow": "/*!*/ /*!*/",
1722
- "--backdrop-blur": "/*!*/ /*!*/",
1723
- "--backdrop-brightness": "/*!*/ /*!*/",
1724
- "--backdrop-contrast": "/*!*/ /*!*/",
1725
- "--backdrop-grayscale": "/*!*/ /*!*/",
1726
- "--backdrop-hue-rotate": "/*!*/ /*!*/",
1727
- "--backdrop-invert": "/*!*/ /*!*/",
1728
- "--backdrop-opacity": "/*!*/ /*!*/",
1729
- "--backdrop-saturate": "/*!*/ /*!*/",
1730
- "--backdrop-sepia": "/*!*/ /*!*/",
1731
- "--scroll-snap-strictness": "proximity",
1732
- "--border-spacing-x": 0,
1733
- "--border-spacing-y": 0,
1734
- "--translate-x": 0,
1735
- "--translate-y": 0,
1736
- "--rotate": 0,
1737
- "--skew-x": 0,
1738
- "--skew-y": 0,
1739
- "--scale-x": 1,
1740
- "--scale-y": 1
1741
- }
1742
- });
1743
- sheet.processGlobalCss(globalCss);
1744
- return sheet.toCss({ optimize });
1745
- };
1746
-
1747
- // src/artifacts/css/static-css.ts
1748
- import { getStaticCss } from "@pandacss/core";
1749
- var generateStaticCss = (ctx) => {
1750
- const { config, createSheet, utility, recipes } = ctx;
1751
- const { staticCss = {}, theme = {}, optimize = true } = config;
1752
- const sheet = createSheet();
1753
- const fn = getStaticCss(staticCss);
1754
- const results = fn({
1755
- breakpoints: Object.keys(theme.breakpoints ?? {}),
1756
- getPropertyKeys: utility.getPropertyKeys,
1757
- getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
1758
- });
1759
- results.css.forEach((css2) => {
1760
- sheet.processAtomic(css2);
1761
- });
1762
- results.recipes.forEach((result) => {
1763
- Object.entries(result).forEach(([name, value]) => {
1764
- const recipeConfig = recipes.getConfig(name);
1765
- if (!recipeConfig)
1766
- return;
1767
- sheet.processRecipe(recipeConfig, value);
1768
- });
1769
- });
1770
- return sheet.toCss({ optimize });
1771
- };
1772
-
1773
1865
  // src/artifacts/index.ts
1774
1866
  function setupHelpers(ctx) {
1775
1867
  const code = generateHelpers();
@@ -1946,9 +2038,11 @@ function setupCssIndex(ctx) {
1946
2038
  };
1947
2039
  }
1948
2040
  function setupResetCss(ctx) {
1949
- if (!ctx.config.preflight)
2041
+ const { preflight } = ctx.config;
2042
+ if (!preflight)
1950
2043
  return;
1951
- const code = generateResetCss();
2044
+ const scope = isObject(preflight) ? preflight.scope : void 0;
2045
+ const code = generateResetCss(scope);
1952
2046
  return { files: [{ file: "reset.css", code }] };
1953
2047
  }
1954
2048
  function setupGlobalCss(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20230523074619",
3
+ "version": "0.0.0-dev-20230523173112",
4
4
  "description": "The css generator for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -20,16 +20,16 @@
20
20
  "pluralize": "8.0.0",
21
21
  "postcss": "8.4.23",
22
22
  "ts-pattern": "4.3.0",
23
- "@pandacss/core": "0.0.0-dev-20230523074619",
24
- "@pandacss/logger": "0.0.0-dev-20230523074619",
25
- "@pandacss/is-valid-prop": "0.0.0-dev-20230523074619",
26
- "@pandacss/shared": "0.0.0-dev-20230523074619",
27
- "@pandacss/types": "0.0.0-dev-20230523074619",
28
- "@pandacss/token-dictionary": "0.0.0-dev-20230523074619"
23
+ "@pandacss/core": "0.0.0-dev-20230523173112",
24
+ "@pandacss/logger": "0.0.0-dev-20230523173112",
25
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230523173112",
26
+ "@pandacss/shared": "0.0.0-dev-20230523173112",
27
+ "@pandacss/types": "0.0.0-dev-20230523173112",
28
+ "@pandacss/token-dictionary": "0.0.0-dev-20230523173112"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/pluralize": "0.0.29",
32
- "@pandacss/fixture": "0.0.0-dev-20230523074619"
32
+ "@pandacss/fixture": "0.0.0-dev-20230523173112"
33
33
  },
34
34
  "scripts": {
35
35
  "prebuild": "tsx scripts/prebuild.ts",