@pandacss/node 0.0.0-dev-20230203184408 → 0.0.0-dev-20230204134735
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.ts +47 -157
- package/dist/index.js +163 -178
- package/dist/index.mjs +164 -179
- package/package.json +18 -17
package/dist/index.js
CHANGED
|
@@ -60,8 +60,7 @@ function extractFile(ctx, file) {
|
|
|
60
60
|
let result;
|
|
61
61
|
const done = import_logger.logger.time.debug(`Extracted ${(0, import_logger.quote)(file)}`);
|
|
62
62
|
try {
|
|
63
|
-
|
|
64
|
-
data = ctx.parseSourceFile(source);
|
|
63
|
+
data = ctx.project.parseSourceFile(ctx.absPath(file));
|
|
65
64
|
} catch (error) {
|
|
66
65
|
import_logger.logger.error("file:parse", error);
|
|
67
66
|
}
|
|
@@ -83,16 +82,16 @@ function extractFiles(ctx) {
|
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
84
|
function extractGlobalCss(ctx) {
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
85
|
+
const css3 = ctx.getGlobalCss();
|
|
86
|
+
if (!css3)
|
|
88
87
|
return;
|
|
89
|
-
return ctx.chunks.write("system/global.css",
|
|
88
|
+
return ctx.chunks.write("system/global.css", css3);
|
|
90
89
|
}
|
|
91
90
|
function extractStaticCss(ctx) {
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
91
|
+
const css3 = ctx.getStaticCss();
|
|
92
|
+
if (!css3)
|
|
94
93
|
return;
|
|
95
|
-
return ctx.chunks.write("system/static.css",
|
|
94
|
+
return ctx.chunks.write("system/static.css", css3);
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
// src/chunks.ts
|
|
@@ -100,6 +99,7 @@ async function extractChunks(ctx) {
|
|
|
100
99
|
const sheet = new import_core.Stylesheet(ctx.context(), {
|
|
101
100
|
content: [
|
|
102
101
|
"@layer reset, base, tokens, recipes, utilities;",
|
|
102
|
+
"@import './layout-grid.css';",
|
|
103
103
|
ctx.preflight && "@import './reset.css';",
|
|
104
104
|
!ctx.tokens.isEmpty && "@import './tokens/index.css';",
|
|
105
105
|
ctx.theme.keyframes && "@import './tokens/keyframes.css';"
|
|
@@ -108,15 +108,15 @@ async function extractChunks(ctx) {
|
|
|
108
108
|
const files = ctx.chunks.getFiles();
|
|
109
109
|
await Promise.all(
|
|
110
110
|
files.map(async (file) => {
|
|
111
|
-
const
|
|
112
|
-
sheet.append(
|
|
111
|
+
const css3 = await ctx.chunks.readFile(file);
|
|
112
|
+
sheet.append(css3);
|
|
113
113
|
})
|
|
114
114
|
);
|
|
115
115
|
return sheet.toCss({ minify: ctx.minify });
|
|
116
116
|
}
|
|
117
117
|
async function bundleChunks(ctx) {
|
|
118
|
-
const
|
|
119
|
-
await ctx.write(ctx.paths.root, [{ file: "styles.css", code:
|
|
118
|
+
const css3 = await extractChunks(ctx);
|
|
119
|
+
await ctx.write(ctx.paths.root, [{ file: "styles.css", code: css3 }]);
|
|
120
120
|
}
|
|
121
121
|
async function writeFileChunk(ctx, file) {
|
|
122
122
|
import_logger2.logger.info("chunk:change", `File changed: ${file}`);
|
|
@@ -128,7 +128,7 @@ async function writeFileChunk(ctx, file) {
|
|
|
128
128
|
|
|
129
129
|
// src/generators/index.ts
|
|
130
130
|
var import_fs2 = require("fs");
|
|
131
|
-
var
|
|
131
|
+
var import_outdent24 = __toESM(require("outdent"));
|
|
132
132
|
|
|
133
133
|
// src/generators/conditions.ts
|
|
134
134
|
var import_outdent = __toESM(require("outdent"));
|
|
@@ -993,9 +993,45 @@ function generateLayoutGrid(ctx) {
|
|
|
993
993
|
return layoutGridMap[ctx.jsxFramework]();
|
|
994
994
|
}
|
|
995
995
|
|
|
996
|
+
// src/generators/layout-grid.ts
|
|
997
|
+
var import_outdent17 = require("outdent");
|
|
998
|
+
var css = (v) => v[0];
|
|
999
|
+
var layoutGrid = css`
|
|
1000
|
+
.panda-layout-grid {
|
|
1001
|
+
display: grid;
|
|
1002
|
+
gap: var(--gutter);
|
|
1003
|
+
grid-template-columns: repeat(var(--count), 1fr);
|
|
1004
|
+
height: 100%;
|
|
1005
|
+
width: 100%;
|
|
1006
|
+
position: absolute;
|
|
1007
|
+
inset: 0;
|
|
1008
|
+
pointer-events: none;
|
|
1009
|
+
max-width: var(--max-width);
|
|
1010
|
+
margin-inline: var(--margin-x);
|
|
1011
|
+
padding-inline: var(--padding-x);
|
|
1012
|
+
}
|
|
1013
|
+
.panda-layout-grid__item {
|
|
1014
|
+
display: flex;
|
|
1015
|
+
--color: rgba(255, 0, 0, 0.1);
|
|
1016
|
+
height: 100%;
|
|
1017
|
+
}
|
|
1018
|
+
.panda-layout-grid__item[data-variant='bg'] {
|
|
1019
|
+
background: var(--color);
|
|
1020
|
+
}
|
|
1021
|
+
.panda-layout-grid__item[data-variant='outline'] {
|
|
1022
|
+
border-inline: 1px solid var(--color);
|
|
1023
|
+
}
|
|
1024
|
+
`;
|
|
1025
|
+
function generateLayoutGridCss() {
|
|
1026
|
+
return import_outdent17.outdent`
|
|
1027
|
+
@layer base {
|
|
1028
|
+
${layoutGrid}
|
|
1029
|
+
}`;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
996
1032
|
// src/generators/pattern.ts
|
|
997
1033
|
var import_shared = require("@pandacss/shared");
|
|
998
|
-
var
|
|
1034
|
+
var import_outdent18 = require("outdent");
|
|
999
1035
|
var import_javascript_stringify = require("javascript-stringify");
|
|
1000
1036
|
var import_ts_pattern4 = require("ts-pattern");
|
|
1001
1037
|
function generate4(ctx, name, pattern) {
|
|
@@ -1003,7 +1039,7 @@ function generate4(ctx, name, pattern) {
|
|
|
1003
1039
|
const { upperName, styleFn, blocklistType } = ctx.getPatternDetails(name, pattern);
|
|
1004
1040
|
return {
|
|
1005
1041
|
name: (0, import_shared.dashCase)(name),
|
|
1006
|
-
dts:
|
|
1042
|
+
dts: import_outdent18.outdent`
|
|
1007
1043
|
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
1008
1044
|
import type { PropertyValue } from '../types/prop-type'
|
|
1009
1045
|
import type { Properties } from '../types/csstype'
|
|
@@ -1027,7 +1063,7 @@ function generate4(ctx, name, pattern) {
|
|
|
1027
1063
|
}).join("\n ")}
|
|
1028
1064
|
}
|
|
1029
1065
|
|
|
1030
|
-
${strict ?
|
|
1066
|
+
${strict ? import_outdent18.outdent`export declare function ${name}(options: ${upperName}Properties): string` : import_outdent18.outdent`
|
|
1031
1067
|
|
|
1032
1068
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
1033
1069
|
|
|
@@ -1036,7 +1072,7 @@ function generate4(ctx, name, pattern) {
|
|
|
1036
1072
|
`}
|
|
1037
1073
|
|
|
1038
1074
|
`,
|
|
1039
|
-
js:
|
|
1075
|
+
js: import_outdent18.outdent`
|
|
1040
1076
|
${ctx.getImport("mapObject", "../helpers")}
|
|
1041
1077
|
${ctx.getImport("css", "../css/index")}
|
|
1042
1078
|
|
|
@@ -1075,11 +1111,11 @@ function generatePackageJSON(ctx) {
|
|
|
1075
1111
|
}
|
|
1076
1112
|
|
|
1077
1113
|
// src/generators/prop-types.ts
|
|
1078
|
-
var
|
|
1114
|
+
var import_outdent19 = require("outdent");
|
|
1079
1115
|
function generatePropTypes(utility, strict) {
|
|
1080
1116
|
const strictText = `${strict ? "" : " | NativeValue<T>"}`;
|
|
1081
1117
|
const result = [
|
|
1082
|
-
|
|
1118
|
+
import_outdent19.outdent`
|
|
1083
1119
|
import type { ConditionalValue } from './conditions';
|
|
1084
1120
|
import type { Properties as CSSProperties } from './csstype'
|
|
1085
1121
|
import type { Tokens } from './token'
|
|
@@ -1102,7 +1138,7 @@ function generatePropTypes(utility, strict) {
|
|
|
1102
1138
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
1103
1139
|
});
|
|
1104
1140
|
result.push("}");
|
|
1105
|
-
return
|
|
1141
|
+
return import_outdent19.outdent`
|
|
1106
1142
|
${result.join("\n")}
|
|
1107
1143
|
|
|
1108
1144
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -1115,14 +1151,14 @@ function generatePropTypes(utility, strict) {
|
|
|
1115
1151
|
|
|
1116
1152
|
// src/generators/recipe.ts
|
|
1117
1153
|
var import_shared2 = require("@pandacss/shared");
|
|
1118
|
-
var
|
|
1154
|
+
var import_outdent20 = require("outdent");
|
|
1119
1155
|
function generateRecipes(ctx) {
|
|
1120
1156
|
const { recipes = {}, hash, hasRecipes, utility } = ctx;
|
|
1121
1157
|
const { separator } = utility;
|
|
1122
1158
|
if (!hasRecipes)
|
|
1123
1159
|
return;
|
|
1124
1160
|
const js = [
|
|
1125
|
-
|
|
1161
|
+
import_outdent20.outdent`
|
|
1126
1162
|
${ctx.getImport("createCss, withoutSpace, compact", "../helpers")}
|
|
1127
1163
|
|
|
1128
1164
|
const createRecipe = (name, defaultVariants) => {
|
|
@@ -1156,17 +1192,17 @@ function generateRecipes(ctx) {
|
|
|
1156
1192
|
`
|
|
1157
1193
|
];
|
|
1158
1194
|
const dts = [
|
|
1159
|
-
|
|
1195
|
+
import_outdent20.outdent`
|
|
1160
1196
|
import type { ConditionalValue } from '../types'
|
|
1161
1197
|
`
|
|
1162
1198
|
];
|
|
1163
1199
|
Object.values(recipes).forEach((recipe) => {
|
|
1164
1200
|
const { name, description, defaultVariants, variants } = recipe;
|
|
1165
|
-
js.push(
|
|
1201
|
+
js.push(import_outdent20.outdent`
|
|
1166
1202
|
export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
|
|
1167
1203
|
${name}.variants = ${JSON.stringify(Object.keys(variants ?? {}))}
|
|
1168
1204
|
`);
|
|
1169
|
-
dts.push(
|
|
1205
|
+
dts.push(import_outdent20.outdent`
|
|
1170
1206
|
export type ${(0, import_shared2.capitalize)(name)}Variants = {
|
|
1171
1207
|
${Object.keys(variants ?? {}).map((key) => {
|
|
1172
1208
|
const value = variants[key];
|
|
@@ -1180,14 +1216,14 @@ function generateRecipes(ctx) {
|
|
|
1180
1216
|
`);
|
|
1181
1217
|
});
|
|
1182
1218
|
return {
|
|
1183
|
-
js:
|
|
1184
|
-
dts:
|
|
1219
|
+
js: import_outdent20.outdent.string(js.join("\n\n")),
|
|
1220
|
+
dts: import_outdent20.outdent.string(dts.join("\n\n"))
|
|
1185
1221
|
};
|
|
1186
1222
|
}
|
|
1187
1223
|
|
|
1188
1224
|
// src/generators/reset.ts
|
|
1189
|
-
var
|
|
1190
|
-
var reset =
|
|
1225
|
+
var css2 = (v) => v[0];
|
|
1226
|
+
var reset = css2`
|
|
1191
1227
|
* {
|
|
1192
1228
|
margin: 0;
|
|
1193
1229
|
}
|
|
@@ -1280,7 +1316,7 @@ var reset = css`
|
|
|
1280
1316
|
top: -0.5em;
|
|
1281
1317
|
}
|
|
1282
1318
|
`;
|
|
1283
|
-
function
|
|
1319
|
+
function generateResetCss() {
|
|
1284
1320
|
return `@layer reset {
|
|
1285
1321
|
${reset}
|
|
1286
1322
|
}`;
|
|
@@ -1303,11 +1339,11 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
1303
1339
|
if (Object.keys(varsObj).length === 0)
|
|
1304
1340
|
continue;
|
|
1305
1341
|
if (key === "base") {
|
|
1306
|
-
const { css:
|
|
1307
|
-
results.push(
|
|
1342
|
+
const { css: css4 } = (0, import_core2.toCss)({ [root]: varsObj });
|
|
1343
|
+
results.push(css4);
|
|
1308
1344
|
} else {
|
|
1309
1345
|
const keys = key.split(":");
|
|
1310
|
-
const { css:
|
|
1346
|
+
const { css: css4 } = (0, import_core2.toCss)(varsObj);
|
|
1311
1347
|
const mapped = keys.map((key2) => conditions.get(key2)).filter(Boolean).map((condition) => {
|
|
1312
1348
|
const parent = (0, import_core2.extractParentSelectors)(condition);
|
|
1313
1349
|
return parent ? `&${parent}` : condition;
|
|
@@ -1315,13 +1351,13 @@ function generateTokenCss(ctx, varRoot) {
|
|
|
1315
1351
|
const rule = getDeepestRule(root, mapped);
|
|
1316
1352
|
if (!rule)
|
|
1317
1353
|
continue;
|
|
1318
|
-
getDeepestNode(rule)?.append(
|
|
1354
|
+
getDeepestNode(rule)?.append(css4);
|
|
1319
1355
|
results.push((0, import_core2.expandNestedCss)(rule.toString()));
|
|
1320
1356
|
}
|
|
1321
1357
|
}
|
|
1322
|
-
const
|
|
1358
|
+
const css3 = results.join("\n\n");
|
|
1323
1359
|
return `@layer tokens {
|
|
1324
|
-
${(0, import_core2.prettifyCss)(cleanupSelectors(
|
|
1360
|
+
${(0, import_core2.prettifyCss)(cleanupSelectors(css3, root))}
|
|
1325
1361
|
}
|
|
1326
1362
|
`;
|
|
1327
1363
|
}
|
|
@@ -1345,8 +1381,8 @@ function getDeepestNode(node) {
|
|
|
1345
1381
|
}
|
|
1346
1382
|
return node;
|
|
1347
1383
|
}
|
|
1348
|
-
function cleanupSelectors(
|
|
1349
|
-
const root = import_postcss.default.parse(
|
|
1384
|
+
function cleanupSelectors(css3, varSelector) {
|
|
1385
|
+
const root = import_postcss.default.parse(css3);
|
|
1350
1386
|
root.walkRules((rule) => {
|
|
1351
1387
|
rule.selectors.forEach((selector) => {
|
|
1352
1388
|
const res = selector.split(varSelector).filter(Boolean);
|
|
@@ -1360,7 +1396,7 @@ function cleanupSelectors(css2, varSelector) {
|
|
|
1360
1396
|
|
|
1361
1397
|
// src/generators/token-dts.ts
|
|
1362
1398
|
var import_shared3 = require("@pandacss/shared");
|
|
1363
|
-
var
|
|
1399
|
+
var import_outdent21 = require("outdent");
|
|
1364
1400
|
var import_pluralize = __toESM(require("pluralize"));
|
|
1365
1401
|
function generateTokenDts(dict) {
|
|
1366
1402
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -1378,11 +1414,11 @@ function generateTokenDts(dict) {
|
|
|
1378
1414
|
}
|
|
1379
1415
|
result.add("} & { [token: string]: never }");
|
|
1380
1416
|
set.add(Array.from(result).join("\n"));
|
|
1381
|
-
return
|
|
1417
|
+
return import_outdent21.outdent.string(Array.from(set).join("\n\n"));
|
|
1382
1418
|
}
|
|
1383
1419
|
|
|
1384
1420
|
// src/generators/token-js.ts
|
|
1385
|
-
var
|
|
1421
|
+
var import_outdent22 = __toESM(require("outdent"));
|
|
1386
1422
|
function generateTokenJs(dict) {
|
|
1387
1423
|
const map = /* @__PURE__ */ new Map();
|
|
1388
1424
|
dict.allTokens.forEach((token) => {
|
|
@@ -1392,7 +1428,7 @@ function generateTokenJs(dict) {
|
|
|
1392
1428
|
});
|
|
1393
1429
|
const obj = Object.fromEntries(map);
|
|
1394
1430
|
return {
|
|
1395
|
-
js:
|
|
1431
|
+
js: import_outdent22.default`
|
|
1396
1432
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1397
1433
|
|
|
1398
1434
|
export function token(path, fallback) {
|
|
@@ -1405,7 +1441,7 @@ function generateTokenJs(dict) {
|
|
|
1405
1441
|
|
|
1406
1442
|
token.var = tokenVar
|
|
1407
1443
|
`,
|
|
1408
|
-
dts:
|
|
1444
|
+
dts: import_outdent22.default`
|
|
1409
1445
|
import type { Token } from '../types/token'
|
|
1410
1446
|
|
|
1411
1447
|
export declare function token(path: Token, fallback?: string): string & {
|
|
@@ -1418,7 +1454,7 @@ function generateTokenJs(dict) {
|
|
|
1418
1454
|
// src/generators/types.ts
|
|
1419
1455
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
1420
1456
|
var import_fs_extra = require("fs-extra");
|
|
1421
|
-
var
|
|
1457
|
+
var import_outdent23 = __toESM(require("outdent"));
|
|
1422
1458
|
function getType(file) {
|
|
1423
1459
|
const filepath = getEntrypoint("@pandacss/types", { dev: file });
|
|
1424
1460
|
return (0, import_fs_extra.readFileSync)(filepath, "utf8");
|
|
@@ -1431,7 +1467,7 @@ function generateCssType(ctx) {
|
|
|
1431
1467
|
selectors: getType("selectors.d.ts"),
|
|
1432
1468
|
recipe: getType("recipe.d.ts"),
|
|
1433
1469
|
composition: getType("composition.d.ts"),
|
|
1434
|
-
global:
|
|
1470
|
+
global: import_outdent23.default`
|
|
1435
1471
|
import { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
1436
1472
|
import { GlobalStyleObject } from './system-types'
|
|
1437
1473
|
import { CompositionStyles } from './composition'
|
|
@@ -1443,14 +1479,14 @@ function generateCssType(ctx) {
|
|
|
1443
1479
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
1444
1480
|
}
|
|
1445
1481
|
`,
|
|
1446
|
-
exported:
|
|
1482
|
+
exported: import_outdent23.default`
|
|
1447
1483
|
import './global'
|
|
1448
1484
|
export { ConditionalValue } from './conditions'
|
|
1449
1485
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1450
1486
|
|
|
1451
1487
|
export type Assign<Target, Override> = Omit<Target, keyof Override> & Override
|
|
1452
1488
|
`,
|
|
1453
|
-
styleProps:
|
|
1489
|
+
styleProps: import_outdent23.default`
|
|
1454
1490
|
import { PropertyValue } from './prop-type'
|
|
1455
1491
|
import { Token } from './token'
|
|
1456
1492
|
|
|
@@ -1484,11 +1520,11 @@ function setupDesignTokens(ctx) {
|
|
|
1484
1520
|
if (ctx.tokens.isEmpty)
|
|
1485
1521
|
return;
|
|
1486
1522
|
const code = generateTokenJs(ctx.tokens);
|
|
1487
|
-
const
|
|
1523
|
+
const css3 = generateTokenCss(ctx);
|
|
1488
1524
|
return {
|
|
1489
1525
|
dir: ctx.paths.token,
|
|
1490
1526
|
files: [
|
|
1491
|
-
{ file: "index.css", code:
|
|
1527
|
+
{ file: "index.css", code: css3 },
|
|
1492
1528
|
{ file: "index.d.ts", code: code.dts },
|
|
1493
1529
|
{ file: ctx.getExt("index"), code: code.js }
|
|
1494
1530
|
]
|
|
@@ -1565,8 +1601,8 @@ function setupPatterns(ctx) {
|
|
|
1565
1601
|
if (!files)
|
|
1566
1602
|
return;
|
|
1567
1603
|
const index = {
|
|
1568
|
-
js:
|
|
1569
|
-
dts:
|
|
1604
|
+
js: import_outdent24.default.string(files.map((file) => ctx.getExport(`./${file.name}`)).join("\n")),
|
|
1605
|
+
dts: import_outdent24.default.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
1570
1606
|
};
|
|
1571
1607
|
return {
|
|
1572
1608
|
dir: ctx.paths.pattern,
|
|
@@ -1585,17 +1621,17 @@ function setupJsx(ctx) {
|
|
|
1585
1621
|
const types = generateJsxTypes(ctx);
|
|
1586
1622
|
const factory = generateJsxFactory(ctx);
|
|
1587
1623
|
const patterns = generateJsxPatterns(ctx);
|
|
1588
|
-
const
|
|
1624
|
+
const layoutGrid2 = generateLayoutGrid(ctx);
|
|
1589
1625
|
const index = {
|
|
1590
|
-
js:
|
|
1626
|
+
js: import_outdent24.default`
|
|
1591
1627
|
${ctx.getExport("./factory")}
|
|
1592
1628
|
${ctx.getExport("./layout-grid")}
|
|
1593
|
-
${
|
|
1629
|
+
${import_outdent24.default.string(patterns.map((file) => ctx.getExport(`./${file.name}`)).join("\n"))}
|
|
1594
1630
|
`,
|
|
1595
|
-
dts:
|
|
1631
|
+
dts: import_outdent24.default`
|
|
1596
1632
|
export * from './factory'
|
|
1597
1633
|
export * from './layout-grid'
|
|
1598
|
-
${
|
|
1634
|
+
${import_outdent24.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
1599
1635
|
export type { ${ctx.jsxFactoryDetails.typeName} } from '../types/jsx'
|
|
1600
1636
|
`
|
|
1601
1637
|
};
|
|
@@ -1604,8 +1640,8 @@ function setupJsx(ctx) {
|
|
|
1604
1640
|
files: [
|
|
1605
1641
|
...patterns.map((file) => ({ file: ctx.getExt(file.name), code: file.js })),
|
|
1606
1642
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
1607
|
-
{ file: ctx.getExt("layout-grid"), code:
|
|
1608
|
-
{ file: "layout-grid.d.ts", code:
|
|
1643
|
+
{ file: ctx.getExt("layout-grid"), code: layoutGrid2.js },
|
|
1644
|
+
{ file: "layout-grid.d.ts", code: layoutGrid2.dts },
|
|
1609
1645
|
{ file: ctx.getExt("is-valid-prop"), code: isValidProp.js },
|
|
1610
1646
|
{ file: "factory.d.ts", code: types.jsxFactory },
|
|
1611
1647
|
{ file: ctx.getExt("factory"), code: factory.js },
|
|
@@ -1616,12 +1652,12 @@ function setupJsx(ctx) {
|
|
|
1616
1652
|
}
|
|
1617
1653
|
function setupCssIndex(ctx) {
|
|
1618
1654
|
const index = {
|
|
1619
|
-
js:
|
|
1655
|
+
js: import_outdent24.default`
|
|
1620
1656
|
${ctx.getExport("./css")}
|
|
1621
1657
|
${ctx.getExport("./cx")}
|
|
1622
1658
|
${ctx.getExport("./cva")}
|
|
1623
1659
|
`,
|
|
1624
|
-
dts:
|
|
1660
|
+
dts: import_outdent24.default`
|
|
1625
1661
|
export * from './css'
|
|
1626
1662
|
export * from './cx'
|
|
1627
1663
|
export * from './cva'
|
|
@@ -1635,12 +1671,16 @@ function setupCssIndex(ctx) {
|
|
|
1635
1671
|
]
|
|
1636
1672
|
};
|
|
1637
1673
|
}
|
|
1638
|
-
function
|
|
1674
|
+
function setupResetCss(ctx) {
|
|
1639
1675
|
if (!ctx.preflight)
|
|
1640
1676
|
return;
|
|
1641
|
-
const code =
|
|
1677
|
+
const code = generateResetCss();
|
|
1642
1678
|
return { files: [{ file: "reset.css", code }] };
|
|
1643
1679
|
}
|
|
1680
|
+
function setupLayoutGridCss() {
|
|
1681
|
+
const code = generateLayoutGridCss();
|
|
1682
|
+
return { files: [{ file: "layout-grid.css", code }] };
|
|
1683
|
+
}
|
|
1644
1684
|
function setupPackageJson(ctx) {
|
|
1645
1685
|
if (!ctx.emitPackage)
|
|
1646
1686
|
return;
|
|
@@ -1661,37 +1701,38 @@ function generateSystem(ctx) {
|
|
|
1661
1701
|
setupPatterns(ctx),
|
|
1662
1702
|
setupCssIndex(ctx),
|
|
1663
1703
|
setupJsx(ctx),
|
|
1664
|
-
|
|
1704
|
+
setupResetCss(ctx),
|
|
1705
|
+
setupLayoutGridCss(),
|
|
1665
1706
|
setupPackageJson(ctx)
|
|
1666
1707
|
].filter(Boolean);
|
|
1667
1708
|
}
|
|
1668
1709
|
|
|
1669
1710
|
// src/messages.ts
|
|
1670
1711
|
var import_logger3 = require("@pandacss/logger");
|
|
1671
|
-
var
|
|
1712
|
+
var import_outdent25 = require("outdent");
|
|
1672
1713
|
var tick = import_logger3.colors.green().bold("\u2714\uFE0F");
|
|
1673
1714
|
function artifactsGeneratedMessage(ctx) {
|
|
1674
1715
|
return [
|
|
1675
|
-
|
|
1716
|
+
import_outdent25.outdent`
|
|
1676
1717
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/css")}: the css function to author styles
|
|
1677
1718
|
`,
|
|
1678
|
-
ctx.hasTokens &&
|
|
1719
|
+
ctx.hasTokens && import_outdent25.outdent`
|
|
1679
1720
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/tokens")}: the css variables and js function to query your tokens
|
|
1680
1721
|
`,
|
|
1681
|
-
ctx.hasPatterns &&
|
|
1722
|
+
ctx.hasPatterns && import_outdent25.outdent`
|
|
1682
1723
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/patterns")}: functions to implement common css patterns
|
|
1683
1724
|
`,
|
|
1684
|
-
ctx.hasRecipes &&
|
|
1725
|
+
ctx.hasRecipes && import_outdent25.outdent`
|
|
1685
1726
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/recipes")}: functions to create multi-variant styles
|
|
1686
1727
|
`,
|
|
1687
|
-
ctx.jsxFramework &&
|
|
1728
|
+
ctx.jsxFramework && import_outdent25.outdent`
|
|
1688
1729
|
${tick} ${(0, import_logger3.quote)(ctx.outdir, "/jsx")}: style prop powered elements for ${ctx.jsxFramework}
|
|
1689
1730
|
`,
|
|
1690
1731
|
"\n"
|
|
1691
1732
|
].filter(Boolean).join("\n");
|
|
1692
1733
|
}
|
|
1693
1734
|
function configExistsMessage(cmd) {
|
|
1694
|
-
return
|
|
1735
|
+
return import_outdent25.outdent`
|
|
1695
1736
|
\n
|
|
1696
1737
|
It looks like you already have panda created\`.
|
|
1697
1738
|
|
|
@@ -1700,7 +1741,7 @@ function configExistsMessage(cmd) {
|
|
|
1700
1741
|
`;
|
|
1701
1742
|
}
|
|
1702
1743
|
function thankYouMessage() {
|
|
1703
|
-
return
|
|
1744
|
+
return import_outdent25.outdent`
|
|
1704
1745
|
|
|
1705
1746
|
🚀 Thanks for choosing ${import_logger3.colors.cyan("Panda")} to write your css.
|
|
1706
1747
|
|
|
@@ -1712,7 +1753,7 @@ var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
|
1712
1753
|
var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
1713
1754
|
function scaffoldCompleteMessage() {
|
|
1714
1755
|
return import_logger3.logger.box(
|
|
1715
|
-
|
|
1756
|
+
import_outdent25.outdent`
|
|
1716
1757
|
|
|
1717
1758
|
${import_logger3.colors.bold().cyan("Next steps:")}
|
|
1718
1759
|
|
|
@@ -1728,12 +1769,12 @@ function scaffoldCompleteMessage() {
|
|
|
1728
1769
|
);
|
|
1729
1770
|
}
|
|
1730
1771
|
function watchMessage() {
|
|
1731
|
-
return
|
|
1772
|
+
return import_outdent25.outdent`
|
|
1732
1773
|
Watching for file changes...
|
|
1733
1774
|
`;
|
|
1734
1775
|
}
|
|
1735
1776
|
function buildCompleteMessage(ctx) {
|
|
1736
|
-
return
|
|
1777
|
+
return import_outdent25.outdent`
|
|
1737
1778
|
Successfully extracted css from ${ctx.files.length} file(s) ✨
|
|
1738
1779
|
`;
|
|
1739
1780
|
}
|
|
@@ -1757,16 +1798,6 @@ async function extractCss(ctx) {
|
|
|
1757
1798
|
await bundleChunks(ctx);
|
|
1758
1799
|
return buildCompleteMessage(ctx);
|
|
1759
1800
|
}
|
|
1760
|
-
function getBaseCss(ctx) {
|
|
1761
|
-
const css2 = [
|
|
1762
|
-
generateReset(),
|
|
1763
|
-
generateTokenCss(ctx),
|
|
1764
|
-
generateKeyframes(ctx.theme.keyframes),
|
|
1765
|
-
ctx.getGlobalCss(),
|
|
1766
|
-
ctx.getStaticCss()
|
|
1767
|
-
];
|
|
1768
|
-
return css2.filter(Boolean).join("\n\n");
|
|
1769
|
-
}
|
|
1770
1801
|
|
|
1771
1802
|
// src/builder.ts
|
|
1772
1803
|
var import_core4 = require("@pandacss/core");
|
|
@@ -1777,6 +1808,19 @@ var import_fs4 = require("fs");
|
|
|
1777
1808
|
var import_fs_extra3 = require("fs-extra");
|
|
1778
1809
|
var import_path4 = require("path");
|
|
1779
1810
|
|
|
1811
|
+
// src/get-base-css.ts
|
|
1812
|
+
function getBaseCss(ctx) {
|
|
1813
|
+
const css3 = [
|
|
1814
|
+
generateResetCss(),
|
|
1815
|
+
generateLayoutGridCss(),
|
|
1816
|
+
generateTokenCss(ctx),
|
|
1817
|
+
generateKeyframes(ctx.theme.keyframes),
|
|
1818
|
+
ctx.getGlobalCss(),
|
|
1819
|
+
ctx.getStaticCss()
|
|
1820
|
+
];
|
|
1821
|
+
return css3.filter(Boolean).join("\n\n");
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1780
1824
|
// src/config.ts
|
|
1781
1825
|
var import_config = require("@pandacss/config");
|
|
1782
1826
|
var import_look_it_up = require("look-it-up");
|
|
@@ -1794,7 +1838,6 @@ var import_fs_extra2 = require("fs-extra");
|
|
|
1794
1838
|
var import_promises = require("fs/promises");
|
|
1795
1839
|
var import_path2 = require("path");
|
|
1796
1840
|
var import_postcss2 = __toESM(require("postcss"));
|
|
1797
|
-
var import_ts_morph = require("ts-morph");
|
|
1798
1841
|
var import_ts_pattern5 = require("ts-pattern");
|
|
1799
1842
|
var helpers = {
|
|
1800
1843
|
map: import_shared4.mapObject
|
|
@@ -2009,10 +2052,10 @@ function createContext(conf, io = fileSystem) {
|
|
|
2009
2052
|
format(file) {
|
|
2010
2053
|
return (0, import_path2.relative)(cwd, file).replaceAll(import_path2.sep, "__").replace((0, import_path2.extname)(file), ".css");
|
|
2011
2054
|
},
|
|
2012
|
-
async write(file,
|
|
2055
|
+
async write(file, css3) {
|
|
2013
2056
|
const fileName = chunks.format(file);
|
|
2014
2057
|
const oldCss = await chunks.readFile(file);
|
|
2015
|
-
const newCss = (0, import_core3.mergeCss)(oldCss,
|
|
2058
|
+
const newCss = (0, import_core3.mergeCss)(oldCss, css3);
|
|
2016
2059
|
import_logger4.logger.debug("chunk:write", { file, path: fileName });
|
|
2017
2060
|
return write(paths.chunk, [{ file: fileName, code: newCss }]);
|
|
2018
2061
|
},
|
|
@@ -2032,84 +2075,30 @@ function createContext(conf, io = fileSystem) {
|
|
|
2032
2075
|
}
|
|
2033
2076
|
const files = getFiles();
|
|
2034
2077
|
import_logger4.logger.debug("ctx:files", files);
|
|
2035
|
-
const tsProject = (0, import_parser.createProject)();
|
|
2036
|
-
function addSourceFile(file) {
|
|
2037
|
-
tsProject.createSourceFile(file, (0, import_fs3.readFileSync)(file, "utf8"), {
|
|
2038
|
-
overwrite: true,
|
|
2039
|
-
scriptKind: import_ts_morph.ScriptKind.TSX
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
function reloadSourceFile(file) {
|
|
2043
|
-
const sourceFile = tsProject.getSourceFile(file);
|
|
2044
|
-
sourceFile?.refreshFromFileSystemSync();
|
|
2045
|
-
}
|
|
2046
|
-
function reloadSourceFiles() {
|
|
2047
|
-
const files2 = getFiles();
|
|
2048
|
-
for (const file of files2) {
|
|
2049
|
-
const source = tsProject.getSourceFile(file);
|
|
2050
|
-
if (source) {
|
|
2051
|
-
source.refreshFromFileSystemSync();
|
|
2052
|
-
} else {
|
|
2053
|
-
tsProject.addSourceFileAtPath(file);
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
function getSourceFile(file) {
|
|
2058
|
-
return tsProject.getSourceFile(absPath(file));
|
|
2059
|
-
}
|
|
2060
|
-
function removeSourceFile(file) {
|
|
2061
|
-
const sourceFile = tsProject.getSourceFile(absPath(file));
|
|
2062
|
-
if (sourceFile) {
|
|
2063
|
-
return tsProject.removeSourceFile(sourceFile);
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
files.forEach((file) => {
|
|
2067
|
-
addSourceFile(file);
|
|
2068
|
-
});
|
|
2069
2078
|
const importMap = {
|
|
2070
2079
|
css: `${outdir}/css`,
|
|
2071
2080
|
recipe: `${outdir}/recipes`,
|
|
2072
2081
|
pattern: `${outdir}/patterns`,
|
|
2073
2082
|
jsx: `${outdir}/jsx`
|
|
2074
2083
|
};
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2084
|
+
const project = (0, import_parser.createProject)({
|
|
2085
|
+
getFiles,
|
|
2086
|
+
readFile(filePath) {
|
|
2087
|
+
return (0, import_fs3.readFileSync)(filePath, "utf8");
|
|
2088
|
+
},
|
|
2089
|
+
parserOptions: {
|
|
2090
|
+
importMap,
|
|
2091
|
+
jsx: {
|
|
2092
|
+
factory: jsxFactory,
|
|
2093
|
+
isStyleProp,
|
|
2094
|
+
nodes: [...patternNodes, ...recipeNodes]
|
|
2095
|
+
}
|
|
2081
2096
|
}
|
|
2082
2097
|
});
|
|
2083
2098
|
function getGlobalCss() {
|
|
2084
2099
|
const sheet = new import_core3.Stylesheet(context());
|
|
2085
2100
|
sheet.processGlobalCss({
|
|
2086
|
-
":root": {
|
|
2087
|
-
"--made-with-panda": `'\u{1F43C}'`
|
|
2088
|
-
},
|
|
2089
|
-
".panda-layout-grid": {
|
|
2090
|
-
display: "grid",
|
|
2091
|
-
gap: "var(--gutter)",
|
|
2092
|
-
gridTemplateColumns: "repeat(var(--count), 1fr)",
|
|
2093
|
-
height: "100%",
|
|
2094
|
-
width: "100%",
|
|
2095
|
-
position: "absolute",
|
|
2096
|
-
inset: "0",
|
|
2097
|
-
pointerEvents: "none",
|
|
2098
|
-
maxWidth: "var(--max-width)",
|
|
2099
|
-
marginInline: "var(--margin-x)",
|
|
2100
|
-
paddingInline: "var(--padding-x)"
|
|
2101
|
-
},
|
|
2102
|
-
".panda-layout-grid__item": {
|
|
2103
|
-
display: "flex",
|
|
2104
|
-
"--color": "rgba(255, 0, 0, 0.1)",
|
|
2105
|
-
height: "100%",
|
|
2106
|
-
"&[data-variant=bg]": {
|
|
2107
|
-
background: "var(--color)"
|
|
2108
|
-
},
|
|
2109
|
-
"&[data-variant=outline]": {
|
|
2110
|
-
borderInline: "1px solid var(--color)"
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2101
|
+
":root": { "--made-with-panda": `'\u{1F43C}'` }
|
|
2113
2102
|
});
|
|
2114
2103
|
if (globalCss) {
|
|
2115
2104
|
sheet.processGlobalCss(globalCss);
|
|
@@ -2129,8 +2118,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
2129
2118
|
return recipes2[recipe];
|
|
2130
2119
|
}
|
|
2131
2120
|
});
|
|
2132
|
-
results.css.forEach((
|
|
2133
|
-
sheet.processAtomic(
|
|
2121
|
+
results.css.forEach((css3) => {
|
|
2122
|
+
sheet.processAtomic(css3);
|
|
2134
2123
|
});
|
|
2135
2124
|
results.recipes.forEach((result) => {
|
|
2136
2125
|
Object.entries(result).forEach(([key, value]) => {
|
|
@@ -2152,8 +2141,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
2152
2141
|
});
|
|
2153
2142
|
collector.jsx.forEach((result) => {
|
|
2154
2143
|
const { data, type, name } = result;
|
|
2155
|
-
const { css:
|
|
2156
|
-
const styles = { ...
|
|
2144
|
+
const { css: css3 = {}, ...rest } = data;
|
|
2145
|
+
const styles = { ...css3, ...rest };
|
|
2157
2146
|
(0, import_ts_pattern5.match)([name, type]).with([import_ts_pattern5.P.string, "pattern"], ([name2]) => {
|
|
2158
2147
|
collector.setPattern(getPatternFnName(name2), { data: styles });
|
|
2159
2148
|
}).with([import_ts_pattern5.P.string, "recipe"], ([name2]) => {
|
|
@@ -2186,7 +2175,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
2186
2175
|
import_logger4.logger.error("pattern", error);
|
|
2187
2176
|
}
|
|
2188
2177
|
});
|
|
2189
|
-
if (collector.isEmpty) {
|
|
2178
|
+
if (collector.isEmpty()) {
|
|
2190
2179
|
return;
|
|
2191
2180
|
}
|
|
2192
2181
|
return {
|
|
@@ -2211,12 +2200,8 @@ function createContext(conf, io = fileSystem) {
|
|
|
2211
2200
|
exclude,
|
|
2212
2201
|
conditions,
|
|
2213
2202
|
importMap,
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
addSourceFile,
|
|
2217
|
-
reloadSourceFile,
|
|
2218
|
-
removeSourceFile,
|
|
2219
|
-
parseSourceFile,
|
|
2203
|
+
absPath,
|
|
2204
|
+
project,
|
|
2220
2205
|
getPath,
|
|
2221
2206
|
paths,
|
|
2222
2207
|
write,
|
|
@@ -2323,16 +2308,16 @@ var Builder = class {
|
|
|
2323
2308
|
fileCssMap = /* @__PURE__ */ new Map();
|
|
2324
2309
|
context;
|
|
2325
2310
|
configChanged = true;
|
|
2326
|
-
updateFile(file,
|
|
2311
|
+
updateFile(file, css3) {
|
|
2327
2312
|
const oldCss = this.fileCssMap?.get(file) ?? "";
|
|
2328
|
-
const newCss = (0, import_core4.mergeCss)(oldCss,
|
|
2313
|
+
const newCss = (0, import_core4.mergeCss)(oldCss, css3);
|
|
2329
2314
|
this.fileCssMap?.set(file, newCss);
|
|
2330
2315
|
}
|
|
2331
2316
|
async setup() {
|
|
2332
2317
|
const configHash = getConfigHash();
|
|
2333
2318
|
const cachedContext = contextCache.get(configHash);
|
|
2334
2319
|
if (cachedContext) {
|
|
2335
|
-
cachedContext.reloadSourceFiles();
|
|
2320
|
+
cachedContext.project.reloadSourceFiles();
|
|
2336
2321
|
this.context = cachedContext;
|
|
2337
2322
|
this.fileCssMap = builderCache.get(cachedContext).fileCssMap;
|
|
2338
2323
|
this.fileModifiedMap = builderCache.get(cachedContext).fileModifiedMap;
|
|
@@ -2373,8 +2358,8 @@ var Builder = class {
|
|
|
2373
2358
|
toString() {
|
|
2374
2359
|
const ctx = this.ensure();
|
|
2375
2360
|
const sheet = new import_core4.Stylesheet(ctx.context());
|
|
2376
|
-
const
|
|
2377
|
-
sheet.append(
|
|
2361
|
+
const css3 = Array.from(this.fileCssMap.values()).join("\n\n");
|
|
2362
|
+
sheet.append(css3);
|
|
2378
2363
|
return sheet.toCss({ minify: ctx.minify });
|
|
2379
2364
|
}
|
|
2380
2365
|
isValidRoot(root) {
|
|
@@ -2464,13 +2449,13 @@ async function createContentWatcher(ctx, callback) {
|
|
|
2464
2449
|
watcher.on("all", async (event, file) => {
|
|
2465
2450
|
import_logger7.logger.debug(`file:${event}`, file);
|
|
2466
2451
|
(0, import_ts_pattern6.match)(event).with("unlink", () => {
|
|
2467
|
-
ctx.removeSourceFile(file);
|
|
2452
|
+
ctx.project.removeSourceFile(ctx.absPath(file));
|
|
2468
2453
|
ctx.chunks.rm(file);
|
|
2469
2454
|
}).with("change", async () => {
|
|
2470
|
-
ctx.reloadSourceFile(file);
|
|
2455
|
+
ctx.project.reloadSourceFile(file);
|
|
2471
2456
|
await callback(file);
|
|
2472
2457
|
}).with("add", async () => {
|
|
2473
|
-
ctx.
|
|
2458
|
+
ctx.project.createSourceFile(file);
|
|
2474
2459
|
await callback(file);
|
|
2475
2460
|
}).otherwise(() => {
|
|
2476
2461
|
});
|
|
@@ -2529,9 +2514,9 @@ async function generate5(config, configPath) {
|
|
|
2529
2514
|
// src/git-ignore.ts
|
|
2530
2515
|
var import_fs5 = require("fs");
|
|
2531
2516
|
var import_look_it_up2 = require("look-it-up");
|
|
2532
|
-
var
|
|
2517
|
+
var import_outdent26 = __toESM(require("outdent"));
|
|
2533
2518
|
function setupGitIgnore(ctx) {
|
|
2534
|
-
const txt =
|
|
2519
|
+
const txt = import_outdent26.default`## CSS Panda
|
|
2535
2520
|
${ctx.outdir}
|
|
2536
2521
|
${ctx.outdir}-static
|
|
2537
2522
|
`;
|
|
@@ -2549,7 +2534,7 @@ function setupGitIgnore(ctx) {
|
|
|
2549
2534
|
var import_logger9 = require("@pandacss/logger");
|
|
2550
2535
|
var import_fs_extra4 = require("fs-extra");
|
|
2551
2536
|
var import_look_it_up3 = require("look-it-up");
|
|
2552
|
-
var
|
|
2537
|
+
var import_outdent27 = require("outdent");
|
|
2553
2538
|
var import_path5 = require("path");
|
|
2554
2539
|
var import_preferred_pm2 = __toESM(require("preferred-pm"));
|
|
2555
2540
|
async function setupConfig(cwd, { force }) {
|
|
@@ -2563,7 +2548,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2563
2548
|
if (!force && configFile) {
|
|
2564
2549
|
import_logger9.logger.warn("init:config", configExistsMessage(cmd));
|
|
2565
2550
|
} else {
|
|
2566
|
-
const content =
|
|
2551
|
+
const content = import_outdent27.outdent`
|
|
2567
2552
|
import { defineConfig } from "css-panda"
|
|
2568
2553
|
|
|
2569
2554
|
export default defineConfig({
|
|
@@ -2589,7 +2574,7 @@ async function setupConfig(cwd, { force }) {
|
|
|
2589
2574
|
}
|
|
2590
2575
|
async function setupPostcss(cwd) {
|
|
2591
2576
|
import_logger9.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger9.quote)("postcss.config.cjs")}`);
|
|
2592
|
-
const content =
|
|
2577
|
+
const content = import_outdent27.outdent`
|
|
2593
2578
|
module.exports = {
|
|
2594
2579
|
plugins: {
|
|
2595
2580
|
'css-panda/postcss': {},
|