@pandacss/node 0.0.0-dev-20230104161128 → 0.0.0-dev-20230105082451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +81 -78
- package/dist/index.mjs +81 -78
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -127,7 +127,7 @@ async function writeFileChunk(ctx, file) {
|
|
|
127
127
|
|
|
128
128
|
// src/generators/index.ts
|
|
129
129
|
var import_fs2 = require("fs");
|
|
130
|
-
var
|
|
130
|
+
var import_outdent24 = __toESM(require("outdent"));
|
|
131
131
|
|
|
132
132
|
// src/generators/conditions.ts
|
|
133
133
|
var import_shared = require("@pandacss/shared");
|
|
@@ -1244,21 +1244,12 @@ function generateReset() {
|
|
|
1244
1244
|
|
|
1245
1245
|
// src/generators/token-css.ts
|
|
1246
1246
|
var import_core2 = require("@pandacss/core");
|
|
1247
|
-
var
|
|
1248
|
-
var import_ts_pattern5 = require("ts-pattern");
|
|
1247
|
+
var import_postcss = __toESM(require("postcss"));
|
|
1249
1248
|
function generateKeyframes(keyframes) {
|
|
1250
1249
|
if (!keyframes)
|
|
1251
1250
|
return;
|
|
1252
1251
|
return (0, import_core2.toKeyframeCss)(keyframes);
|
|
1253
1252
|
}
|
|
1254
|
-
var getConditionMessage = (value) => import_outdent21.outdent`
|
|
1255
|
-
It seems you provided an invalid condition for semantic tokens.
|
|
1256
|
-
|
|
1257
|
-
- You provided: \`${value}\`
|
|
1258
|
-
|
|
1259
|
-
Valid conditions are those that reference a parent selectors or at-rules.
|
|
1260
|
-
@media (min-width: 768px), or .dark &
|
|
1261
|
-
`;
|
|
1262
1253
|
function generateTokenCss(ctx, varRoot) {
|
|
1263
1254
|
const root = varRoot ?? ctx.cssVarRoot;
|
|
1264
1255
|
const conditions = ctx.conditions;
|
|
@@ -1273,47 +1264,59 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
1273
1264
|
} else {
|
|
1274
1265
|
const keys = key.split(":");
|
|
1275
1266
|
const { css: css3 } = (0, import_core2.toCss)(varsObj);
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
${acc}
|
|
1286
|
-
}`;
|
|
1287
|
-
}).with({ type: "at-rule" }, (cond2) => {
|
|
1288
|
-
selector = cond2?.rawValue ?? cond2?.raw;
|
|
1289
|
-
return `${selector} {
|
|
1290
|
-
${acc}
|
|
1291
|
-
}`;
|
|
1292
|
-
}).otherwise((cond2) => {
|
|
1293
|
-
if (!cond2)
|
|
1294
|
-
return acc;
|
|
1295
|
-
throw new Error(getConditionMessage(cond2.raw));
|
|
1296
|
-
});
|
|
1297
|
-
},
|
|
1298
|
-
allAtRules ? `${root} {
|
|
1299
|
-
${css3}
|
|
1300
|
-
}` : css3
|
|
1301
|
-
);
|
|
1302
|
-
if (result) {
|
|
1303
|
-
results.push(result);
|
|
1304
|
-
}
|
|
1267
|
+
const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
|
|
1268
|
+
const parent = (0, import_core2.extractParentSelectors)(condition);
|
|
1269
|
+
return parent ? `&${parent}` : condition;
|
|
1270
|
+
});
|
|
1271
|
+
const rule = getDeepestRule(root, mapped);
|
|
1272
|
+
if (!rule)
|
|
1273
|
+
continue;
|
|
1274
|
+
getDeepestNode(rule)?.append(css3);
|
|
1275
|
+
results.push((0, import_core2.expandNestedCss)(rule.toString()));
|
|
1305
1276
|
}
|
|
1306
1277
|
}
|
|
1307
|
-
const css2 = results.join("\n\n")
|
|
1308
|
-
return
|
|
1309
|
-
${css2}
|
|
1278
|
+
const css2 = results.join("\n\n");
|
|
1279
|
+
return `@layer tokens {
|
|
1280
|
+
${(0, import_core2.prettifyCss)(cleanupSelectors(css2, root))}
|
|
1310
1281
|
}
|
|
1311
|
-
|
|
1282
|
+
`;
|
|
1283
|
+
}
|
|
1284
|
+
function getDeepestRule(root, selectors) {
|
|
1285
|
+
const rule = import_postcss.default.rule({ selector: "" });
|
|
1286
|
+
for (const selector of selectors) {
|
|
1287
|
+
const last = getDeepestNode(rule);
|
|
1288
|
+
const node = last ?? rule;
|
|
1289
|
+
if (selector.startsWith("@")) {
|
|
1290
|
+
const atRule = import_postcss.default.rule({ selector, nodes: [import_postcss.default.rule({ selector: `${root}&` })] });
|
|
1291
|
+
node.append(atRule);
|
|
1292
|
+
} else {
|
|
1293
|
+
node.append(import_postcss.default.rule({ selector }));
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return rule;
|
|
1297
|
+
}
|
|
1298
|
+
function getDeepestNode(node) {
|
|
1299
|
+
if (node.nodes && node.nodes.length) {
|
|
1300
|
+
return getDeepestNode(node.nodes[node.nodes.length - 1]);
|
|
1301
|
+
}
|
|
1302
|
+
return node;
|
|
1303
|
+
}
|
|
1304
|
+
function cleanupSelectors(css2, varSelector) {
|
|
1305
|
+
const root = import_postcss.default.parse(css2);
|
|
1306
|
+
root.walkRules((rule) => {
|
|
1307
|
+
rule.selectors.forEach((selector) => {
|
|
1308
|
+
const res = selector.split(varSelector).filter(Boolean);
|
|
1309
|
+
if (res.length === 0)
|
|
1310
|
+
return;
|
|
1311
|
+
rule.selector = res.join(varSelector);
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
return root.toString();
|
|
1312
1315
|
}
|
|
1313
1316
|
|
|
1314
1317
|
// src/generators/token-dts.ts
|
|
1315
1318
|
var import_shared13 = require("@pandacss/shared");
|
|
1316
|
-
var
|
|
1319
|
+
var import_outdent21 = require("outdent");
|
|
1317
1320
|
var import_pluralize = __toESM(require("pluralize"));
|
|
1318
1321
|
function generateTokenDts(dict) {
|
|
1319
1322
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -1331,11 +1334,11 @@ function generateTokenDts(dict) {
|
|
|
1331
1334
|
}
|
|
1332
1335
|
result.add("} & { [token: string]: never }");
|
|
1333
1336
|
set.add(Array.from(result).join("\n"));
|
|
1334
|
-
return
|
|
1337
|
+
return import_outdent21.outdent.string(Array.from(set).join("\n\n"));
|
|
1335
1338
|
}
|
|
1336
1339
|
|
|
1337
1340
|
// src/generators/token-js.ts
|
|
1338
|
-
var
|
|
1341
|
+
var import_outdent22 = __toESM(require("outdent"));
|
|
1339
1342
|
function generateTokenJs(dict) {
|
|
1340
1343
|
const map = /* @__PURE__ */ new Map();
|
|
1341
1344
|
dict.allTokens.forEach((token) => {
|
|
@@ -1345,7 +1348,7 @@ function generateTokenJs(dict) {
|
|
|
1345
1348
|
});
|
|
1346
1349
|
const obj = Object.fromEntries(map);
|
|
1347
1350
|
return {
|
|
1348
|
-
js:
|
|
1351
|
+
js: import_outdent22.default`
|
|
1349
1352
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1350
1353
|
|
|
1351
1354
|
export function getToken(path) {
|
|
@@ -1358,7 +1361,7 @@ function generateTokenJs(dict) {
|
|
|
1358
1361
|
return variable
|
|
1359
1362
|
}
|
|
1360
1363
|
`,
|
|
1361
|
-
dts:
|
|
1364
|
+
dts: import_outdent22.default`
|
|
1362
1365
|
import { Token } from "../types/token"
|
|
1363
1366
|
export declare function getToken(path: Token): string
|
|
1364
1367
|
export declare function getTokenVar(path: Token): string
|
|
@@ -1368,7 +1371,7 @@ function generateTokenJs(dict) {
|
|
|
1368
1371
|
|
|
1369
1372
|
// src/generators/types.ts
|
|
1370
1373
|
var import_fs_extra = require("fs-extra");
|
|
1371
|
-
var
|
|
1374
|
+
var import_outdent23 = __toESM(require("outdent"));
|
|
1372
1375
|
function getType(file) {
|
|
1373
1376
|
const filepath = getEntrypoint("@pandacss/types", { dev: file });
|
|
1374
1377
|
return (0, import_fs_extra.readFileSync)(filepath, "utf8");
|
|
@@ -1379,7 +1382,7 @@ function generateCssType(ctx) {
|
|
|
1379
1382
|
return {
|
|
1380
1383
|
cssType: getType("csstype.d.ts"),
|
|
1381
1384
|
pandaCssType: getType("system-types.d.ts"),
|
|
1382
|
-
publicType:
|
|
1385
|
+
publicType: import_outdent23.default`
|
|
1383
1386
|
import * as System from './system-types'
|
|
1384
1387
|
import { PropTypes } from './prop-type'
|
|
1385
1388
|
import { Conditions } from './conditions'
|
|
@@ -1503,7 +1506,7 @@ function setupPatterns(ctx) {
|
|
|
1503
1506
|
if (!files) {
|
|
1504
1507
|
return { files: [] };
|
|
1505
1508
|
}
|
|
1506
|
-
const indexCode =
|
|
1509
|
+
const indexCode = import_outdent24.default.string(files.map((file) => `export * from './${file.name}'`).join("\n"));
|
|
1507
1510
|
return {
|
|
1508
1511
|
dir: ctx.paths.pattern,
|
|
1509
1512
|
files: [
|
|
@@ -1522,10 +1525,10 @@ function setupJsx(ctx) {
|
|
|
1522
1525
|
const factory = generateJsxFactory(ctx);
|
|
1523
1526
|
const patterns = generateJsxPatterns(ctx);
|
|
1524
1527
|
const layoutGrid = generateLayoutGrid(ctx);
|
|
1525
|
-
const indexCode =
|
|
1528
|
+
const indexCode = import_outdent24.default`
|
|
1526
1529
|
export * from './factory'
|
|
1527
1530
|
export * from './layout-grid'
|
|
1528
|
-
${
|
|
1531
|
+
${import_outdent24.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1529
1532
|
`;
|
|
1530
1533
|
return {
|
|
1531
1534
|
dir: ctx.paths.jsx,
|
|
@@ -1543,7 +1546,7 @@ function setupJsx(ctx) {
|
|
|
1543
1546
|
};
|
|
1544
1547
|
}
|
|
1545
1548
|
function setupCssIndex(ctx) {
|
|
1546
|
-
const code =
|
|
1549
|
+
const code = import_outdent24.default`
|
|
1547
1550
|
export * from './css'
|
|
1548
1551
|
export * from './cx'
|
|
1549
1552
|
export * from './global-css'
|
|
@@ -1583,30 +1586,30 @@ function generateSystem(ctx) {
|
|
|
1583
1586
|
|
|
1584
1587
|
// src/messages.ts
|
|
1585
1588
|
var import_logger3 = require("@pandacss/logger");
|
|
1586
|
-
var
|
|
1589
|
+
var import_outdent25 = require("outdent");
|
|
1587
1590
|
var tick = import_logger3.colors.green().bold("\u2714\uFE0F");
|
|
1588
1591
|
function artifactsGeneratedMessage(ctx) {
|
|
1589
1592
|
return [
|
|
1590
|
-
|
|
1593
|
+
import_outdent25.outdent`
|
|
1591
1594
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/css")}: the css function to author styles
|
|
1592
1595
|
`,
|
|
1593
|
-
ctx.hasTokens &&
|
|
1596
|
+
ctx.hasTokens && import_outdent25.outdent`
|
|
1594
1597
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/tokens")}: the css variables and js function to query your tokens
|
|
1595
1598
|
`,
|
|
1596
|
-
ctx.hasPatterns &&
|
|
1599
|
+
ctx.hasPatterns && import_outdent25.outdent`
|
|
1597
1600
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/patterns")}: functions to implement common css patterns
|
|
1598
1601
|
`,
|
|
1599
|
-
ctx.hasRecipes &&
|
|
1602
|
+
ctx.hasRecipes && import_outdent25.outdent`
|
|
1600
1603
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/recipes")}: functions to create multi-variant styles
|
|
1601
1604
|
`,
|
|
1602
|
-
ctx.jsxFramework &&
|
|
1605
|
+
ctx.jsxFramework && import_outdent25.outdent`
|
|
1603
1606
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/jsx")}: style prop powered elements for ${ctx.jsxFramework}
|
|
1604
1607
|
`,
|
|
1605
1608
|
"\n"
|
|
1606
1609
|
].filter(Boolean).join("\n");
|
|
1607
1610
|
}
|
|
1608
1611
|
function configExistsMessage(cmd) {
|
|
1609
|
-
return
|
|
1612
|
+
return import_outdent25.outdent`
|
|
1610
1613
|
\n
|
|
1611
1614
|
It looks like you already have panda created\`.
|
|
1612
1615
|
|
|
@@ -1615,7 +1618,7 @@ function configExistsMessage(cmd) {
|
|
|
1615
1618
|
`;
|
|
1616
1619
|
}
|
|
1617
1620
|
function thankYouMessage() {
|
|
1618
|
-
return
|
|
1621
|
+
return import_outdent25.outdent`
|
|
1619
1622
|
|
|
1620
1623
|
🚀 Thanks for choosing ${import_logger3.colors.cyan("Panda")} to write your css.
|
|
1621
1624
|
|
|
@@ -1627,7 +1630,7 @@ var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
|
1627
1630
|
var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
1628
1631
|
function scaffoldCompleteMessage() {
|
|
1629
1632
|
return import_logger3.logger.box(
|
|
1630
|
-
|
|
1633
|
+
import_outdent25.outdent`
|
|
1631
1634
|
|
|
1632
1635
|
${import_logger3.colors.bold().cyan("Next steps:")}
|
|
1633
1636
|
|
|
@@ -1643,12 +1646,12 @@ function scaffoldCompleteMessage() {
|
|
|
1643
1646
|
);
|
|
1644
1647
|
}
|
|
1645
1648
|
function watchMessage() {
|
|
1646
|
-
return
|
|
1649
|
+
return import_outdent25.outdent`
|
|
1647
1650
|
Watching for file changes...
|
|
1648
1651
|
`;
|
|
1649
1652
|
}
|
|
1650
1653
|
function buildCompleteMessage(ctx) {
|
|
1651
|
-
return
|
|
1654
|
+
return import_outdent25.outdent`
|
|
1652
1655
|
Successfully extracted css from ${ctx.files.length} file(s) ✨
|
|
1653
1656
|
`;
|
|
1654
1657
|
}
|
|
@@ -1704,9 +1707,9 @@ var import_fs3 = require("fs");
|
|
|
1704
1707
|
var import_fs_extra2 = require("fs-extra");
|
|
1705
1708
|
var import_promises = require("fs/promises");
|
|
1706
1709
|
var import_path2 = require("path");
|
|
1707
|
-
var
|
|
1710
|
+
var import_postcss2 = __toESM(require("postcss"));
|
|
1708
1711
|
var import_ts_morph = require("ts-morph");
|
|
1709
|
-
var
|
|
1712
|
+
var import_ts_pattern5 = require("ts-pattern");
|
|
1710
1713
|
var helpers = {
|
|
1711
1714
|
map: import_shared14.mapObject
|
|
1712
1715
|
};
|
|
@@ -1787,7 +1790,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1787
1790
|
})
|
|
1788
1791
|
);
|
|
1789
1792
|
const context = () => ({
|
|
1790
|
-
root:
|
|
1793
|
+
root: import_postcss2.default.root(),
|
|
1791
1794
|
conditions,
|
|
1792
1795
|
hash,
|
|
1793
1796
|
helpers,
|
|
@@ -2015,9 +2018,9 @@ function createContext(conf, io = fileSystem) {
|
|
|
2015
2018
|
const { data, type, name } = result;
|
|
2016
2019
|
const { css: css2 = {}, ...rest } = data;
|
|
2017
2020
|
const styles = { ...css2, ...rest };
|
|
2018
|
-
(0,
|
|
2021
|
+
(0, import_ts_pattern5.match)([name, type]).with([import_ts_pattern5.P.string, "pattern"], ([name2]) => {
|
|
2019
2022
|
collector.setPattern(getPatternFnName(name2), { data: styles });
|
|
2020
|
-
}).with([
|
|
2023
|
+
}).with([import_ts_pattern5.P.string, "recipe"], ([name2]) => {
|
|
2021
2024
|
const [recipeProps, atomicProps] = splitRecipeProps(name2, styles);
|
|
2022
2025
|
collector.setRecipe(getRecipeFnName(name2), { data: recipeProps });
|
|
2023
2026
|
sheet.processAtomic(atomicProps);
|
|
@@ -2282,7 +2285,7 @@ var import_logger8 = require("@pandacss/logger");
|
|
|
2282
2285
|
var import_logger7 = require("@pandacss/logger");
|
|
2283
2286
|
var import_chokidar = __toESM(require("chokidar"));
|
|
2284
2287
|
var import_path5 = require("path");
|
|
2285
|
-
var
|
|
2288
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
2286
2289
|
function createWatcher(files, options = {}) {
|
|
2287
2290
|
const { ignore, cwd = process.cwd(), poll } = options;
|
|
2288
2291
|
const coalesce = poll || process.platform === "win32";
|
|
@@ -2314,7 +2317,7 @@ async function createContentWatcher(ctx, callback) {
|
|
|
2314
2317
|
});
|
|
2315
2318
|
watcher.on("all", async (event, file) => {
|
|
2316
2319
|
import_logger7.logger.debug({ type: `file:${event}`, file });
|
|
2317
|
-
(0,
|
|
2320
|
+
(0, import_ts_pattern6.match)(event).with("unlink", () => {
|
|
2318
2321
|
ctx.removeSourceFile(file);
|
|
2319
2322
|
ctx.chunks.rm(file);
|
|
2320
2323
|
}).with("change", async () => {
|
|
@@ -2382,9 +2385,9 @@ async function generate5(config, configPath) {
|
|
|
2382
2385
|
// src/git-ignore.ts
|
|
2383
2386
|
var import_fs5 = require("fs");
|
|
2384
2387
|
var import_look_it_up2 = require("look-it-up");
|
|
2385
|
-
var
|
|
2388
|
+
var import_outdent26 = __toESM(require("outdent"));
|
|
2386
2389
|
function setupGitIgnore(ctx) {
|
|
2387
|
-
const txt =
|
|
2390
|
+
const txt = import_outdent26.default`## CSS Panda
|
|
2388
2391
|
${ctx.outdir}
|
|
2389
2392
|
${ctx.outdir}-static
|
|
2390
2393
|
`;
|
|
@@ -2402,7 +2405,7 @@ function setupGitIgnore(ctx) {
|
|
|
2402
2405
|
var import_logger9 = require("@pandacss/logger");
|
|
2403
2406
|
var import_fs_extra4 = require("fs-extra");
|
|
2404
2407
|
var import_look_it_up3 = require("look-it-up");
|
|
2405
|
-
var
|
|
2408
|
+
var import_outdent27 = require("outdent");
|
|
2406
2409
|
var import_path6 = require("path");
|
|
2407
2410
|
var import_preferred_pm2 = __toESM(require("preferred-pm"));
|
|
2408
2411
|
async function setupConfig(cwd, { force }) {
|
|
@@ -2416,7 +2419,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2416
2419
|
if (!force && configFile) {
|
|
2417
2420
|
import_logger9.logger.warn("config exists", configExistsMessage(cmd));
|
|
2418
2421
|
} else {
|
|
2419
|
-
const content =
|
|
2422
|
+
const content = import_outdent27.outdent`
|
|
2420
2423
|
import { defineConfig } from "css-panda"
|
|
2421
2424
|
|
|
2422
2425
|
export default defineConfig({
|
|
@@ -2442,7 +2445,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2442
2445
|
}
|
|
2443
2446
|
async function setupPostcss(cwd) {
|
|
2444
2447
|
import_logger9.logger.info({ type: "init", msg: `creating postcss config file: ${(0, import_logger9.quote)("postcss.config.cjs")}` });
|
|
2445
|
-
const content =
|
|
2448
|
+
const content = import_outdent27.outdent`
|
|
2446
2449
|
module.exports = {
|
|
2447
2450
|
plugins: {
|
|
2448
2451
|
'css-panda/postcss': {},
|
package/dist/index.mjs
CHANGED
|
@@ -81,7 +81,7 @@ async function writeFileChunk(ctx, file) {
|
|
|
81
81
|
|
|
82
82
|
// src/generators/index.ts
|
|
83
83
|
import { readFileSync as readFileSync3 } from "fs";
|
|
84
|
-
import
|
|
84
|
+
import outdent24 from "outdent";
|
|
85
85
|
|
|
86
86
|
// src/generators/conditions.ts
|
|
87
87
|
import { unionType } from "@pandacss/shared";
|
|
@@ -1197,22 +1197,13 @@ function generateReset() {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
|
|
1199
1199
|
// src/generators/token-css.ts
|
|
1200
|
-
import { prettifyCss, toCss, toKeyframeCss } from "@pandacss/core";
|
|
1201
|
-
import
|
|
1202
|
-
import { match as match5 } from "ts-pattern";
|
|
1200
|
+
import { expandNestedCss, extractParentSelectors, prettifyCss, toCss, toKeyframeCss } from "@pandacss/core";
|
|
1201
|
+
import postcss from "postcss";
|
|
1203
1202
|
function generateKeyframes(keyframes) {
|
|
1204
1203
|
if (!keyframes)
|
|
1205
1204
|
return;
|
|
1206
1205
|
return toKeyframeCss(keyframes);
|
|
1207
1206
|
}
|
|
1208
|
-
var getConditionMessage = (value) => outdent21`
|
|
1209
|
-
It seems you provided an invalid condition for semantic tokens.
|
|
1210
|
-
|
|
1211
|
-
- You provided: \`${value}\`
|
|
1212
|
-
|
|
1213
|
-
Valid conditions are those that reference a parent selectors or at-rules.
|
|
1214
|
-
@media (min-width: 768px), or .dark &
|
|
1215
|
-
`;
|
|
1216
1207
|
function generateTokenCss(ctx, varRoot) {
|
|
1217
1208
|
const root = varRoot ?? ctx.cssVarRoot;
|
|
1218
1209
|
const conditions = ctx.conditions;
|
|
@@ -1227,47 +1218,59 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
1227
1218
|
} else {
|
|
1228
1219
|
const keys = key.split(":");
|
|
1229
1220
|
const { css: css3 } = toCss(varsObj);
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
${acc}
|
|
1240
|
-
}`;
|
|
1241
|
-
}).with({ type: "at-rule" }, (cond2) => {
|
|
1242
|
-
selector = cond2?.rawValue ?? cond2?.raw;
|
|
1243
|
-
return `${selector} {
|
|
1244
|
-
${acc}
|
|
1245
|
-
}`;
|
|
1246
|
-
}).otherwise((cond2) => {
|
|
1247
|
-
if (!cond2)
|
|
1248
|
-
return acc;
|
|
1249
|
-
throw new Error(getConditionMessage(cond2.raw));
|
|
1250
|
-
});
|
|
1251
|
-
},
|
|
1252
|
-
allAtRules ? `${root} {
|
|
1253
|
-
${css3}
|
|
1254
|
-
}` : css3
|
|
1255
|
-
);
|
|
1256
|
-
if (result) {
|
|
1257
|
-
results.push(result);
|
|
1258
|
-
}
|
|
1221
|
+
const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
|
|
1222
|
+
const parent = extractParentSelectors(condition);
|
|
1223
|
+
return parent ? `&${parent}` : condition;
|
|
1224
|
+
});
|
|
1225
|
+
const rule = getDeepestRule(root, mapped);
|
|
1226
|
+
if (!rule)
|
|
1227
|
+
continue;
|
|
1228
|
+
getDeepestNode(rule)?.append(css3);
|
|
1229
|
+
results.push(expandNestedCss(rule.toString()));
|
|
1259
1230
|
}
|
|
1260
1231
|
}
|
|
1261
|
-
const css2 = results.join("\n\n")
|
|
1262
|
-
return
|
|
1263
|
-
${css2}
|
|
1232
|
+
const css2 = results.join("\n\n");
|
|
1233
|
+
return `@layer tokens {
|
|
1234
|
+
${prettifyCss(cleanupSelectors(css2, root))}
|
|
1264
1235
|
}
|
|
1265
|
-
|
|
1236
|
+
`;
|
|
1237
|
+
}
|
|
1238
|
+
function getDeepestRule(root, selectors) {
|
|
1239
|
+
const rule = postcss.rule({ selector: "" });
|
|
1240
|
+
for (const selector of selectors) {
|
|
1241
|
+
const last = getDeepestNode(rule);
|
|
1242
|
+
const node = last ?? rule;
|
|
1243
|
+
if (selector.startsWith("@")) {
|
|
1244
|
+
const atRule = postcss.rule({ selector, nodes: [postcss.rule({ selector: `${root}&` })] });
|
|
1245
|
+
node.append(atRule);
|
|
1246
|
+
} else {
|
|
1247
|
+
node.append(postcss.rule({ selector }));
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return rule;
|
|
1251
|
+
}
|
|
1252
|
+
function getDeepestNode(node) {
|
|
1253
|
+
if (node.nodes && node.nodes.length) {
|
|
1254
|
+
return getDeepestNode(node.nodes[node.nodes.length - 1]);
|
|
1255
|
+
}
|
|
1256
|
+
return node;
|
|
1257
|
+
}
|
|
1258
|
+
function cleanupSelectors(css2, varSelector) {
|
|
1259
|
+
const root = postcss.parse(css2);
|
|
1260
|
+
root.walkRules((rule) => {
|
|
1261
|
+
rule.selectors.forEach((selector) => {
|
|
1262
|
+
const res = selector.split(varSelector).filter(Boolean);
|
|
1263
|
+
if (res.length === 0)
|
|
1264
|
+
return;
|
|
1265
|
+
rule.selector = res.join(varSelector);
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
return root.toString();
|
|
1266
1269
|
}
|
|
1267
1270
|
|
|
1268
1271
|
// src/generators/token-dts.ts
|
|
1269
1272
|
import { unionType as unionType4, capitalize as capitalize12 } from "@pandacss/shared";
|
|
1270
|
-
import { outdent as
|
|
1273
|
+
import { outdent as outdent21 } from "outdent";
|
|
1271
1274
|
import pluralize from "pluralize";
|
|
1272
1275
|
function generateTokenDts(dict) {
|
|
1273
1276
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -1285,11 +1288,11 @@ function generateTokenDts(dict) {
|
|
|
1285
1288
|
}
|
|
1286
1289
|
result.add("} & { [token: string]: never }");
|
|
1287
1290
|
set.add(Array.from(result).join("\n"));
|
|
1288
|
-
return
|
|
1291
|
+
return outdent21.string(Array.from(set).join("\n\n"));
|
|
1289
1292
|
}
|
|
1290
1293
|
|
|
1291
1294
|
// src/generators/token-js.ts
|
|
1292
|
-
import
|
|
1295
|
+
import outdent22 from "outdent";
|
|
1293
1296
|
function generateTokenJs(dict) {
|
|
1294
1297
|
const map = /* @__PURE__ */ new Map();
|
|
1295
1298
|
dict.allTokens.forEach((token) => {
|
|
@@ -1299,7 +1302,7 @@ function generateTokenJs(dict) {
|
|
|
1299
1302
|
});
|
|
1300
1303
|
const obj = Object.fromEntries(map);
|
|
1301
1304
|
return {
|
|
1302
|
-
js:
|
|
1305
|
+
js: outdent22`
|
|
1303
1306
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1304
1307
|
|
|
1305
1308
|
export function getToken(path) {
|
|
@@ -1312,7 +1315,7 @@ function generateTokenJs(dict) {
|
|
|
1312
1315
|
return variable
|
|
1313
1316
|
}
|
|
1314
1317
|
`,
|
|
1315
|
-
dts:
|
|
1318
|
+
dts: outdent22`
|
|
1316
1319
|
import { Token } from "../types/token"
|
|
1317
1320
|
export declare function getToken(path: Token): string
|
|
1318
1321
|
export declare function getTokenVar(path: Token): string
|
|
@@ -1322,7 +1325,7 @@ function generateTokenJs(dict) {
|
|
|
1322
1325
|
|
|
1323
1326
|
// src/generators/types.ts
|
|
1324
1327
|
import { readFileSync as readFileSync2 } from "fs-extra";
|
|
1325
|
-
import
|
|
1328
|
+
import outdent23 from "outdent";
|
|
1326
1329
|
function getType(file) {
|
|
1327
1330
|
const filepath = getEntrypoint("@pandacss/types", { dev: file });
|
|
1328
1331
|
return readFileSync2(filepath, "utf8");
|
|
@@ -1333,7 +1336,7 @@ function generateCssType(ctx) {
|
|
|
1333
1336
|
return {
|
|
1334
1337
|
cssType: getType("csstype.d.ts"),
|
|
1335
1338
|
pandaCssType: getType("system-types.d.ts"),
|
|
1336
|
-
publicType:
|
|
1339
|
+
publicType: outdent23`
|
|
1337
1340
|
import * as System from './system-types'
|
|
1338
1341
|
import { PropTypes } from './prop-type'
|
|
1339
1342
|
import { Conditions } from './conditions'
|
|
@@ -1457,7 +1460,7 @@ function setupPatterns(ctx) {
|
|
|
1457
1460
|
if (!files) {
|
|
1458
1461
|
return { files: [] };
|
|
1459
1462
|
}
|
|
1460
|
-
const indexCode =
|
|
1463
|
+
const indexCode = outdent24.string(files.map((file) => `export * from './${file.name}'`).join("\n"));
|
|
1461
1464
|
return {
|
|
1462
1465
|
dir: ctx.paths.pattern,
|
|
1463
1466
|
files: [
|
|
@@ -1476,10 +1479,10 @@ function setupJsx(ctx) {
|
|
|
1476
1479
|
const factory = generateJsxFactory(ctx);
|
|
1477
1480
|
const patterns = generateJsxPatterns(ctx);
|
|
1478
1481
|
const layoutGrid = generateLayoutGrid(ctx);
|
|
1479
|
-
const indexCode =
|
|
1482
|
+
const indexCode = outdent24`
|
|
1480
1483
|
export * from './factory'
|
|
1481
1484
|
export * from './layout-grid'
|
|
1482
|
-
${
|
|
1485
|
+
${outdent24.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1483
1486
|
`;
|
|
1484
1487
|
return {
|
|
1485
1488
|
dir: ctx.paths.jsx,
|
|
@@ -1497,7 +1500,7 @@ function setupJsx(ctx) {
|
|
|
1497
1500
|
};
|
|
1498
1501
|
}
|
|
1499
1502
|
function setupCssIndex(ctx) {
|
|
1500
|
-
const code =
|
|
1503
|
+
const code = outdent24`
|
|
1501
1504
|
export * from './css'
|
|
1502
1505
|
export * from './cx'
|
|
1503
1506
|
export * from './global-css'
|
|
@@ -1537,30 +1540,30 @@ function generateSystem(ctx) {
|
|
|
1537
1540
|
|
|
1538
1541
|
// src/messages.ts
|
|
1539
1542
|
import { colors, logger as logger3, quote as quote2 } from "@pandacss/logger";
|
|
1540
|
-
import { outdent as
|
|
1543
|
+
import { outdent as outdent25 } from "outdent";
|
|
1541
1544
|
var tick = colors.green().bold("\u2714\uFE0F");
|
|
1542
1545
|
function artifactsGeneratedMessage(ctx) {
|
|
1543
1546
|
return [
|
|
1544
|
-
|
|
1547
|
+
outdent25`
|
|
1545
1548
|
${tick} ${quote2(ctx.outdir, "/css")}: the css function to author styles
|
|
1546
1549
|
`,
|
|
1547
|
-
ctx.hasTokens &&
|
|
1550
|
+
ctx.hasTokens && outdent25`
|
|
1548
1551
|
${tick} ${quote2(ctx.outdir, "/tokens")}: the css variables and js function to query your tokens
|
|
1549
1552
|
`,
|
|
1550
|
-
ctx.hasPatterns &&
|
|
1553
|
+
ctx.hasPatterns && outdent25`
|
|
1551
1554
|
${tick} ${quote2(ctx.outdir, "/patterns")}: functions to implement common css patterns
|
|
1552
1555
|
`,
|
|
1553
|
-
ctx.hasRecipes &&
|
|
1556
|
+
ctx.hasRecipes && outdent25`
|
|
1554
1557
|
${tick} ${quote2(ctx.outdir, "/recipes")}: functions to create multi-variant styles
|
|
1555
1558
|
`,
|
|
1556
|
-
ctx.jsxFramework &&
|
|
1559
|
+
ctx.jsxFramework && outdent25`
|
|
1557
1560
|
${tick} ${quote2(ctx.outdir, "/jsx")}: style prop powered elements for ${ctx.jsxFramework}
|
|
1558
1561
|
`,
|
|
1559
1562
|
"\n"
|
|
1560
1563
|
].filter(Boolean).join("\n");
|
|
1561
1564
|
}
|
|
1562
1565
|
function configExistsMessage(cmd) {
|
|
1563
|
-
return
|
|
1566
|
+
return outdent25`
|
|
1564
1567
|
\n
|
|
1565
1568
|
It looks like you already have panda created\`.
|
|
1566
1569
|
|
|
@@ -1569,7 +1572,7 @@ function configExistsMessage(cmd) {
|
|
|
1569
1572
|
`;
|
|
1570
1573
|
}
|
|
1571
1574
|
function thankYouMessage() {
|
|
1572
|
-
return
|
|
1575
|
+
return outdent25`
|
|
1573
1576
|
|
|
1574
1577
|
🚀 Thanks for choosing ${colors.cyan("Panda")} to write your css.
|
|
1575
1578
|
|
|
@@ -1581,7 +1584,7 @@ var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
|
1581
1584
|
var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
1582
1585
|
function scaffoldCompleteMessage() {
|
|
1583
1586
|
return logger3.box(
|
|
1584
|
-
|
|
1587
|
+
outdent25`
|
|
1585
1588
|
|
|
1586
1589
|
${colors.bold().cyan("Next steps:")}
|
|
1587
1590
|
|
|
@@ -1597,12 +1600,12 @@ function scaffoldCompleteMessage() {
|
|
|
1597
1600
|
);
|
|
1598
1601
|
}
|
|
1599
1602
|
function watchMessage() {
|
|
1600
|
-
return
|
|
1603
|
+
return outdent25`
|
|
1601
1604
|
Watching for file changes...
|
|
1602
1605
|
`;
|
|
1603
1606
|
}
|
|
1604
1607
|
function buildCompleteMessage(ctx) {
|
|
1605
|
-
return
|
|
1608
|
+
return outdent25`
|
|
1606
1609
|
Successfully extracted css from ${ctx.files.length} file(s) ✨
|
|
1607
1610
|
`;
|
|
1608
1611
|
}
|
|
@@ -1665,9 +1668,9 @@ import { readdirSync, readFileSync as readFileSync4 } from "fs";
|
|
|
1665
1668
|
import { emptyDir, ensureDir, existsSync } from "fs-extra";
|
|
1666
1669
|
import { readFile, unlink, writeFile } from "fs/promises";
|
|
1667
1670
|
import { extname, isAbsolute, join as join2, relative, resolve, sep } from "path";
|
|
1668
|
-
import
|
|
1671
|
+
import postcss2 from "postcss";
|
|
1669
1672
|
import { ScriptKind } from "ts-morph";
|
|
1670
|
-
import { match as
|
|
1673
|
+
import { match as match5, P } from "ts-pattern";
|
|
1671
1674
|
var helpers = {
|
|
1672
1675
|
map: mapObject
|
|
1673
1676
|
};
|
|
@@ -1748,7 +1751,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1748
1751
|
})
|
|
1749
1752
|
);
|
|
1750
1753
|
const context = () => ({
|
|
1751
|
-
root:
|
|
1754
|
+
root: postcss2.root(),
|
|
1752
1755
|
conditions,
|
|
1753
1756
|
hash,
|
|
1754
1757
|
helpers,
|
|
@@ -1976,7 +1979,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1976
1979
|
const { data, type, name } = result;
|
|
1977
1980
|
const { css: css2 = {}, ...rest } = data;
|
|
1978
1981
|
const styles = { ...css2, ...rest };
|
|
1979
|
-
|
|
1982
|
+
match5([name, type]).with([P.string, "pattern"], ([name2]) => {
|
|
1980
1983
|
collector.setPattern(getPatternFnName(name2), { data: styles });
|
|
1981
1984
|
}).with([P.string, "recipe"], ([name2]) => {
|
|
1982
1985
|
const [recipeProps, atomicProps] = splitRecipeProps(name2, styles);
|
|
@@ -2243,7 +2246,7 @@ import { logger as logger8 } from "@pandacss/logger";
|
|
|
2243
2246
|
import { logger as logger7 } from "@pandacss/logger";
|
|
2244
2247
|
import chokidar from "chokidar";
|
|
2245
2248
|
import { join as join3 } from "path";
|
|
2246
|
-
import { match as
|
|
2249
|
+
import { match as match6 } from "ts-pattern";
|
|
2247
2250
|
function createWatcher(files, options = {}) {
|
|
2248
2251
|
const { ignore, cwd = process.cwd(), poll } = options;
|
|
2249
2252
|
const coalesce = poll || process.platform === "win32";
|
|
@@ -2275,7 +2278,7 @@ async function createContentWatcher(ctx, callback) {
|
|
|
2275
2278
|
});
|
|
2276
2279
|
watcher.on("all", async (event, file) => {
|
|
2277
2280
|
logger7.debug({ type: `file:${event}`, file });
|
|
2278
|
-
|
|
2281
|
+
match6(event).with("unlink", () => {
|
|
2279
2282
|
ctx.removeSourceFile(file);
|
|
2280
2283
|
ctx.chunks.rm(file);
|
|
2281
2284
|
}).with("change", async () => {
|
|
@@ -2343,9 +2346,9 @@ async function generate5(config, configPath) {
|
|
|
2343
2346
|
// src/git-ignore.ts
|
|
2344
2347
|
import { appendFileSync, readFileSync as readFileSync6, writeFileSync } from "fs";
|
|
2345
2348
|
import { lookItUpSync as lookItUpSync2 } from "look-it-up";
|
|
2346
|
-
import
|
|
2349
|
+
import outdent26 from "outdent";
|
|
2347
2350
|
function setupGitIgnore(ctx) {
|
|
2348
|
-
const txt =
|
|
2351
|
+
const txt = outdent26`## CSS Panda
|
|
2349
2352
|
${ctx.outdir}
|
|
2350
2353
|
${ctx.outdir}-static
|
|
2351
2354
|
`;
|
|
@@ -2363,7 +2366,7 @@ function setupGitIgnore(ctx) {
|
|
|
2363
2366
|
import { logger as logger9, quote as quote3 } from "@pandacss/logger";
|
|
2364
2367
|
import { writeFile as writeFile2 } from "fs-extra";
|
|
2365
2368
|
import { lookItUpSync as lookItUpSync3 } from "look-it-up";
|
|
2366
|
-
import { outdent as
|
|
2369
|
+
import { outdent as outdent27 } from "outdent";
|
|
2367
2370
|
import { join as join4 } from "path";
|
|
2368
2371
|
import getPackageManager2 from "preferred-pm";
|
|
2369
2372
|
async function setupConfig(cwd, { force }) {
|
|
@@ -2377,7 +2380,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2377
2380
|
if (!force && configFile) {
|
|
2378
2381
|
logger9.warn("config exists", configExistsMessage(cmd));
|
|
2379
2382
|
} else {
|
|
2380
|
-
const content =
|
|
2383
|
+
const content = outdent27`
|
|
2381
2384
|
import { defineConfig } from "css-panda"
|
|
2382
2385
|
|
|
2383
2386
|
export default defineConfig({
|
|
@@ -2403,7 +2406,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2403
2406
|
}
|
|
2404
2407
|
async function setupPostcss(cwd) {
|
|
2405
2408
|
logger9.info({ type: "init", msg: `creating postcss config file: ${quote3("postcss.config.cjs")}` });
|
|
2406
|
-
const content =
|
|
2409
|
+
const content = outdent27`
|
|
2407
2410
|
module.exports = {
|
|
2408
2411
|
plugins: {
|
|
2409
2412
|
'css-panda/postcss': {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230105082451",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"telejson": "7.0.4",
|
|
31
31
|
"ts-pattern": "4.0.6",
|
|
32
32
|
"ts-morph": "17.0.1",
|
|
33
|
-
"@pandacss/types": "0.0.0-dev-
|
|
34
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
35
|
-
"@pandacss/error": "0.0.0-dev-
|
|
36
|
-
"@pandacss/parser": "0.0.0-dev-
|
|
37
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
38
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
39
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
40
|
-
"@pandacss/core": "0.0.0-dev-
|
|
41
|
-
"@pandacss/config": "0.0.0-dev-
|
|
33
|
+
"@pandacss/types": "0.0.0-dev-20230105082451",
|
|
34
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230105082451",
|
|
35
|
+
"@pandacss/error": "0.0.0-dev-20230105082451",
|
|
36
|
+
"@pandacss/parser": "0.0.0-dev-20230105082451",
|
|
37
|
+
"@pandacss/shared": "0.0.0-dev-20230105082451",
|
|
38
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230105082451",
|
|
39
|
+
"@pandacss/logger": "0.0.0-dev-20230105082451",
|
|
40
|
+
"@pandacss/core": "0.0.0-dev-20230105082451",
|
|
41
|
+
"@pandacss/config": "0.0.0-dev-20230105082451"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/fs-extra": "9.0.13",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/glob-parent": "^5.1.1",
|
|
47
47
|
"@types/pluralize": "0.0.29",
|
|
48
48
|
"@types/lodash.merge": "4.6.7",
|
|
49
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
49
|
+
"@pandacss/fixture": "0.0.0-dev-20230105082451"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|