@pandacss/generator 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +94 -67
- package/dist/index.d.ts +94 -67
- package/dist/index.js +757 -389
- package/dist/index.mjs +755 -387
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
|
|
33
|
+
Generator: () => Generator,
|
|
34
34
|
messages: () => messages_exports
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -128,7 +128,7 @@ var getMessages = (ctx) => ({
|
|
|
128
128
|
configWatch
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
// src/artifacts/
|
|
131
|
+
// src/artifacts/setup-artifacts.ts
|
|
132
132
|
var import_shared4 = require("@pandacss/shared");
|
|
133
133
|
var import_outdent44 = __toESM(require("outdent"));
|
|
134
134
|
|
|
@@ -427,9 +427,16 @@ function generateResetCss(ctx, scope = "") {
|
|
|
427
427
|
// src/artifacts/css/static-css.ts
|
|
428
428
|
var import_core2 = require("@pandacss/core");
|
|
429
429
|
var generateStaticCss = (ctx) => {
|
|
430
|
-
const { config,
|
|
430
|
+
const { config, utility, recipes } = ctx;
|
|
431
431
|
const { staticCss = {}, theme = {}, optimize = true } = config;
|
|
432
|
-
|
|
432
|
+
staticCss.recipes = staticCss.recipes ?? {};
|
|
433
|
+
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
434
|
+
Object.entries(recipeConfigs).forEach(([name, recipe]) => {
|
|
435
|
+
if (recipe.staticCss) {
|
|
436
|
+
staticCss.recipes[name] = recipe.staticCss;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
const sheet = ctx.createSheet();
|
|
433
440
|
const fn = (0, import_core2.getStaticCss)(staticCss);
|
|
434
441
|
const results = fn({
|
|
435
442
|
breakpoints: Object.keys(theme.breakpoints ?? {}),
|
|
@@ -921,7 +928,7 @@ var import_outdent8 = require("outdent");
|
|
|
921
928
|
|
|
922
929
|
// src/artifacts/generated/helpers.mjs.json
|
|
923
930
|
var helpers_mjs_default = {
|
|
924
|
-
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const objects = sources.filter(Boolean);\n return objects.reduce((prev, obj) => {\n Object.keys(obj).forEach((key) => {\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) {\n prev[key] = mergeProps(prevValue, value);\n } else {\n prev[key] = value;\n }\n });\n return prev;\n }, {});\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) =>
|
|
931
|
+
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const objects = sources.filter(Boolean);\n return objects.reduce((prev, obj) => {\n Object.keys(obj).forEach((key) => {\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) {\n prev[key] = mergeProps(prevValue, value);\n } else {\n prev[key] = value;\n }\n });\n return prev;\n }, {});\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context, shorthand = true) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate-property.ts\nvar wordRegex = /([A-Z])/g;\nvar msRegex = /^ms-/;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();\n});\n\n// src/slot.ts\nvar getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join("__"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const slots = recipe.slots ?? [];\n const recipeParts = slots.map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {\n for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {\n recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n }\n }\n return Object.fromEntries(recipeParts);\n};\nvar getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));\n\n// src/split-props.ts\nfunction splitProps(props, ...keys) {\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const dKeys = Object.keys(descriptors);\n const split = (k) => {\n const clone = {};\n for (let i = 0; i < k.length; i++) {\n const key = k[i];\n if (descriptors[key]) {\n Object.defineProperty(clone, key, descriptors[key]);\n delete descriptors[key];\n }\n }\n return clone;\n };\n const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));\n return keys.map(fn).concat(split(dKeys));\n}\n\n// src/uniq.ts\nvar uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(/* @__PURE__ */ new Set([...acc, ...item])), []);\nexport {\n compact,\n createCss,\n createMergeCss,\n filterBaseConditions,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n splitProps,\n toHash,\n uniq,\n walkObject,\n withoutSpace\n};\n'
|
|
925
932
|
};
|
|
926
933
|
|
|
927
934
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -970,7 +977,7 @@ function generateIsValidProp(ctx) {
|
|
|
970
977
|
let content = is_valid_prop_mjs_default.content;
|
|
971
978
|
content = content.replace(
|
|
972
979
|
'var userGeneratedStr = "";',
|
|
973
|
-
`var userGeneratedStr = "${(0, import_ts_pattern.match)(ctx.jsx.styleProps).with("all", () => Array.from(
|
|
980
|
+
`var userGeneratedStr = "${(0, import_ts_pattern.match)(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
974
981
|
);
|
|
975
982
|
content = content.replace(memoFnDeclarationRegex, "var cssPropertySelectorRegex");
|
|
976
983
|
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
@@ -1038,10 +1045,11 @@ var import_shared = require("@pandacss/shared");
|
|
|
1038
1045
|
var import_javascript_stringify = require("javascript-stringify");
|
|
1039
1046
|
var import_outdent11 = require("outdent");
|
|
1040
1047
|
var import_ts_pattern3 = require("ts-pattern");
|
|
1041
|
-
function generatePattern(ctx) {
|
|
1048
|
+
function generatePattern(ctx, filters) {
|
|
1042
1049
|
if (ctx.patterns.isEmpty())
|
|
1043
1050
|
return;
|
|
1044
|
-
|
|
1051
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
1052
|
+
return details.map((pattern) => {
|
|
1045
1053
|
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
1046
1054
|
const { properties, transform, strict, description } = config;
|
|
1047
1055
|
const transformFn = (0, import_javascript_stringify.stringify)({ transform }) ?? "";
|
|
@@ -1116,18 +1124,21 @@ var import_outdent12 = require("outdent");
|
|
|
1116
1124
|
var import_ts_pattern4 = require("ts-pattern");
|
|
1117
1125
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
1118
1126
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
1119
|
-
function
|
|
1127
|
+
function generateCreateRecipe(ctx) {
|
|
1120
1128
|
const {
|
|
1129
|
+
conditions,
|
|
1121
1130
|
recipes,
|
|
1122
|
-
|
|
1123
|
-
|
|
1131
|
+
prefix,
|
|
1132
|
+
hash,
|
|
1133
|
+
utility: { separator }
|
|
1124
1134
|
} = ctx;
|
|
1125
1135
|
if (recipes.isEmpty())
|
|
1126
1136
|
return;
|
|
1127
|
-
|
|
1137
|
+
return {
|
|
1128
1138
|
name: "create-recipe",
|
|
1129
1139
|
dts: "",
|
|
1130
1140
|
js: import_outdent12.outdent`
|
|
1141
|
+
${ctx.file.import("finalizeConditions, sortConditions", "../css/conditions")}
|
|
1131
1142
|
${ctx.file.import("css", "../css/css")}
|
|
1132
1143
|
${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
|
|
1133
1144
|
${ctx.file.import("cx", "../css/cx")}
|
|
@@ -1155,9 +1166,14 @@ function generateRecipes(ctx) {
|
|
|
1155
1166
|
}
|
|
1156
1167
|
|
|
1157
1168
|
const recipeCss = createCss({
|
|
1158
|
-
${hash ? "hash: true," : ""}
|
|
1169
|
+
${hash.className ? "hash: true," : ""}
|
|
1170
|
+
conditions: {
|
|
1171
|
+
shift: sortConditions,
|
|
1172
|
+
finalize: finalizeConditions,
|
|
1173
|
+
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
1174
|
+
},
|
|
1159
1175
|
utility: {
|
|
1160
|
-
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
1176
|
+
${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
|
|
1161
1177
|
transform,
|
|
1162
1178
|
}
|
|
1163
1179
|
})
|
|
@@ -1189,7 +1205,7 @@ function generateRecipes(ctx) {
|
|
|
1189
1205
|
acc[key] = uniq(recipeA.variantMap[key], recipeB.variantMap[key])
|
|
1190
1206
|
return acc
|
|
1191
1207
|
}, {})
|
|
1192
|
-
|
|
1208
|
+
|
|
1193
1209
|
return Object.assign(recipeFn, {
|
|
1194
1210
|
__recipe__: true,
|
|
1195
1211
|
__name__: \`$\{recipeA.__name__} \${recipeB.__name__}\`,
|
|
@@ -1204,14 +1220,18 @@ function generateRecipes(ctx) {
|
|
|
1204
1220
|
}
|
|
1205
1221
|
`
|
|
1206
1222
|
};
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1223
|
+
}
|
|
1224
|
+
function generateRecipes(ctx, filters) {
|
|
1225
|
+
const { recipes } = ctx;
|
|
1226
|
+
if (recipes.isEmpty())
|
|
1227
|
+
return;
|
|
1228
|
+
const details = ctx.recipes.filterDetails(filters);
|
|
1229
|
+
return details.map((recipe) => {
|
|
1230
|
+
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
1231
|
+
const { description, defaultVariants, compoundVariants } = config;
|
|
1232
|
+
const jsCode = (0, import_ts_pattern4.match)(config).when(
|
|
1233
|
+
import_core4.isSlotRecipe,
|
|
1234
|
+
(config2) => import_outdent12.outdent`
|
|
1215
1235
|
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1216
1236
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1217
1237
|
|
|
@@ -1238,19 +1258,19 @@ function generateRecipes(ctx) {
|
|
|
1238
1258
|
},
|
|
1239
1259
|
})
|
|
1240
1260
|
`
|
|
1241
|
-
|
|
1242
|
-
|
|
1261
|
+
).otherwise(
|
|
1262
|
+
(config2) => import_outdent12.outdent`
|
|
1243
1263
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1244
1264
|
${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
|
|
1245
1265
|
|
|
1246
1266
|
const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
|
|
1247
|
-
|
|
1248
|
-
|
|
1267
|
+
defaultVariants ?? {}
|
|
1268
|
+
)}, ${stringify2(compoundVariants ?? [])})
|
|
1249
1269
|
|
|
1250
1270
|
const ${baseName}VariantMap = ${stringify2(variantKeyMap)}
|
|
1251
|
-
|
|
1271
|
+
|
|
1252
1272
|
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1253
|
-
|
|
1273
|
+
|
|
1254
1274
|
export const ${baseName} = /* @__PURE__ */ Object.assign(${baseName}Fn, {
|
|
1255
1275
|
__recipe__: true,
|
|
1256
1276
|
__name__: '${baseName}',
|
|
@@ -1265,21 +1285,21 @@ function generateRecipes(ctx) {
|
|
|
1265
1285
|
},
|
|
1266
1286
|
})
|
|
1267
1287
|
`
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1288
|
+
);
|
|
1289
|
+
return {
|
|
1290
|
+
name: dashName,
|
|
1291
|
+
js: jsCode,
|
|
1292
|
+
dts: import_outdent12.outdent`
|
|
1273
1293
|
${ctx.file.importType("ConditionalValue", "../types/index")}
|
|
1274
1294
|
${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
|
|
1275
1295
|
|
|
1276
1296
|
interface ${upperName}Variant {
|
|
1277
1297
|
${Object.keys(variantKeyMap).map((key) => {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1298
|
+
const values = variantKeyMap[key];
|
|
1299
|
+
if (values.every(isBooleanValue))
|
|
1300
|
+
return `${key}: boolean`;
|
|
1301
|
+
return `${key}: ${(0, import_shared2.unionType)(values)}`;
|
|
1302
|
+
}).join("\n")}
|
|
1283
1303
|
}
|
|
1284
1304
|
|
|
1285
1305
|
type ${upperName}VariantMap = {
|
|
@@ -1302,9 +1322,8 @@ function generateRecipes(ctx) {
|
|
|
1302
1322
|
${description ? `/** ${description} */` : ""}
|
|
1303
1323
|
export declare const ${baseName}: ${upperName}Recipe
|
|
1304
1324
|
`
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
];
|
|
1325
|
+
};
|
|
1326
|
+
});
|
|
1308
1327
|
}
|
|
1309
1328
|
|
|
1310
1329
|
// src/artifacts/js/sva.ts
|
|
@@ -1492,9 +1511,10 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1492
1511
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1493
1512
|
var import_outdent16 = require("outdent");
|
|
1494
1513
|
var import_ts_pattern5 = require("ts-pattern");
|
|
1495
|
-
function generatePreactJsxPattern(ctx) {
|
|
1514
|
+
function generatePreactJsxPattern(ctx, filters) {
|
|
1496
1515
|
const { typeName, factoryName } = ctx.jsx;
|
|
1497
|
-
|
|
1516
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
1517
|
+
return details.map((pattern) => {
|
|
1498
1518
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
1499
1519
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1500
1520
|
return {
|
|
@@ -1560,7 +1580,7 @@ interface Dict {
|
|
|
1560
1580
|
}
|
|
1561
1581
|
|
|
1562
1582
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
1563
|
-
(props: JsxHTMLProps<ComponentProps<T>, P
|
|
1583
|
+
(props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
|
|
1564
1584
|
displayName?: string
|
|
1565
1585
|
}
|
|
1566
1586
|
|
|
@@ -1797,9 +1817,10 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1797
1817
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1798
1818
|
var import_outdent21 = require("outdent");
|
|
1799
1819
|
var import_ts_pattern6 = require("ts-pattern");
|
|
1800
|
-
function generateQwikJsxPattern(ctx) {
|
|
1820
|
+
function generateQwikJsxPattern(ctx, filters) {
|
|
1801
1821
|
const { typeName, factoryName } = ctx.jsx;
|
|
1802
|
-
|
|
1822
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
1823
|
+
return details.map((pattern) => {
|
|
1803
1824
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
1804
1825
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1805
1826
|
return {
|
|
@@ -2108,9 +2129,10 @@ function generateReactJsxFactory(ctx) {
|
|
|
2108
2129
|
// src/artifacts/react-jsx/pattern.ts
|
|
2109
2130
|
var import_outdent26 = require("outdent");
|
|
2110
2131
|
var import_ts_pattern7 = require("ts-pattern");
|
|
2111
|
-
function generateReactJsxPattern(ctx) {
|
|
2132
|
+
function generateReactJsxPattern(ctx, filters) {
|
|
2112
2133
|
const { typeName, factoryName } = ctx.jsx;
|
|
2113
|
-
|
|
2134
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
2135
|
+
return details.map((pattern) => {
|
|
2114
2136
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
2115
2137
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2116
2138
|
return {
|
|
@@ -2443,9 +2465,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2443
2465
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2444
2466
|
var import_outdent31 = require("outdent");
|
|
2445
2467
|
var import_ts_pattern8 = require("ts-pattern");
|
|
2446
|
-
function generateSolidJsxPattern(ctx) {
|
|
2468
|
+
function generateSolidJsxPattern(ctx, filters) {
|
|
2447
2469
|
const { typeName, factoryName } = ctx.jsx;
|
|
2448
|
-
|
|
2470
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
2471
|
+
return details.map((pattern) => {
|
|
2449
2472
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
2450
2473
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2451
2474
|
return {
|
|
@@ -2703,14 +2726,14 @@ function generateVueJsxFactory(ctx) {
|
|
|
2703
2726
|
const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
|
|
2704
2727
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2705
2728
|
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
2706
|
-
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2729
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className, combinedProps.value.class)
|
|
2707
2730
|
})
|
|
2708
2731
|
|
|
2709
2732
|
const cvaClass = computed(() => {
|
|
2710
2733
|
const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
|
|
2711
2734
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2712
2735
|
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
2713
|
-
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2736
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className, combinedProps.value.class)
|
|
2714
2737
|
})
|
|
2715
2738
|
|
|
2716
2739
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
@@ -2824,9 +2847,10 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2824
2847
|
|
|
2825
2848
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2826
2849
|
var import_outdent37 = require("outdent");
|
|
2827
|
-
function generateVueJsxPattern(ctx) {
|
|
2850
|
+
function generateVueJsxPattern(ctx, filters) {
|
|
2828
2851
|
const { typeName, factoryName } = ctx.jsx;
|
|
2829
|
-
|
|
2852
|
+
const details = ctx.patterns.filterDetails(filters);
|
|
2853
|
+
return details.map((pattern) => {
|
|
2830
2854
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
2831
2855
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2832
2856
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
@@ -3025,12 +3049,10 @@ var patternMap = {
|
|
|
3025
3049
|
vue: generateVueJsxPattern,
|
|
3026
3050
|
qwik: generateQwikJsxPattern
|
|
3027
3051
|
};
|
|
3028
|
-
function generateJsxPatterns(ctx) {
|
|
3029
|
-
if (ctx.isTemplateLiteralSyntax)
|
|
3030
|
-
return [];
|
|
3031
|
-
if (ctx.patterns.isEmpty() && !ctx.jsx.framework)
|
|
3052
|
+
function generateJsxPatterns(ctx, filters) {
|
|
3053
|
+
if (ctx.isTemplateLiteralSyntax || ctx.patterns.isEmpty() || !ctx.jsx.framework)
|
|
3032
3054
|
return [];
|
|
3033
|
-
return patternMap[ctx.jsx.framework](ctx);
|
|
3055
|
+
return patternMap[ctx.jsx.framework](ctx, filters);
|
|
3034
3056
|
}
|
|
3035
3057
|
|
|
3036
3058
|
// src/artifacts/pkg-json.ts
|
|
@@ -3095,7 +3117,7 @@ var composition_d_ts_default = {
|
|
|
3095
3117
|
|
|
3096
3118
|
// src/artifacts/generated/recipe.d.ts.json
|
|
3097
3119
|
var recipe_d_ts_default = {
|
|
3098
|
-
content: "import type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>,\n RecipeConfigMeta {}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>>\n extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
|
|
3120
|
+
content: "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>,\n RecipeConfigMeta {}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>>\n extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> {\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n"
|
|
3099
3121
|
};
|
|
3100
3122
|
|
|
3101
3123
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -3115,7 +3137,6 @@ var selectors_d_ts_default = {
|
|
|
3115
3137
|
|
|
3116
3138
|
// src/artifacts/types/generated.ts
|
|
3117
3139
|
var import_ts_pattern9 = require("ts-pattern");
|
|
3118
|
-
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
3119
3140
|
function getGeneratedTypes(ctx) {
|
|
3120
3141
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3121
3142
|
return {
|
|
@@ -3124,7 +3145,13 @@ function getGeneratedTypes(ctx) {
|
|
|
3124
3145
|
pattern: rewriteImports(pattern_d_ts_default.content.replace("../tokens", "../tokens/index")),
|
|
3125
3146
|
parts: rewriteImports(parts_d_ts_default.content),
|
|
3126
3147
|
composition: rewriteImports(composition_d_ts_default.content),
|
|
3127
|
-
selectors: rewriteImports(selectors_d_ts_default.content)
|
|
3148
|
+
selectors: rewriteImports(selectors_d_ts_default.content)
|
|
3149
|
+
};
|
|
3150
|
+
}
|
|
3151
|
+
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
3152
|
+
function getGeneratedSystemTypes(ctx) {
|
|
3153
|
+
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
3154
|
+
return {
|
|
3128
3155
|
system: rewriteImports(
|
|
3129
3156
|
(0, import_ts_pattern9.match)(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
3130
3157
|
"minimal",
|
|
@@ -3214,12 +3241,39 @@ function generatePropTypes(ctx) {
|
|
|
3214
3241
|
return import_outdent41.outdent`
|
|
3215
3242
|
${result.join("\n")}
|
|
3216
3243
|
|
|
3217
|
-
${strictTokens ? `
|
|
3244
|
+
${strictTokens ? `
|
|
3245
|
+
type FilterString<T> = T extends \`\${infer _}\` ? T : never;
|
|
3246
|
+
type WithArbitraryValue<T> = T | \`[\${string}]\`
|
|
3247
|
+
|
|
3248
|
+
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
3249
|
+
? ConditionalValue<FilterString<PropertyTypes[T]>>
|
|
3250
|
+
: never;
|
|
3251
|
+
|
|
3252
|
+
type CssPropertyValue<T extends string> = T extends keyof CssProperties
|
|
3253
|
+
? ConditionalValue<FilterString<CssProperties[T]>>
|
|
3254
|
+
: never;
|
|
3255
|
+
|
|
3256
|
+
export type PropertyValue<T extends string> = WithArbitraryValue<T extends keyof PropertyTypes
|
|
3257
|
+
? PropertyTypeValue<T>
|
|
3258
|
+
: T extends keyof CssProperties
|
|
3259
|
+
? CssPropertyValue<T>
|
|
3260
|
+
: ConditionalValue<string | number>
|
|
3261
|
+
>` : `
|
|
3262
|
+
|
|
3263
|
+
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
3264
|
+
? ConditionalValue<PropertyTypes[T] | CssValue<T> | (string & {})>
|
|
3265
|
+
: never;
|
|
3266
|
+
|
|
3267
|
+
type CssPropertyValue<T extends string> = T extends keyof CssProperties
|
|
3268
|
+
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
3269
|
+
: never;
|
|
3270
|
+
|
|
3218
3271
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
3219
|
-
?
|
|
3272
|
+
? PropertyTypeValue<T>
|
|
3220
3273
|
: T extends keyof CssProperties
|
|
3221
|
-
|
|
3222
|
-
|
|
3274
|
+
? CssPropertyValue<T>
|
|
3275
|
+
: ConditionalValue<string | number>
|
|
3276
|
+
`}
|
|
3223
3277
|
`;
|
|
3224
3278
|
}
|
|
3225
3279
|
|
|
@@ -3299,16 +3353,18 @@ function generateTokenTypes(ctx) {
|
|
|
3299
3353
|
return import_outdent43.outdent.string(Array.from(set).join("\n\n"));
|
|
3300
3354
|
}
|
|
3301
3355
|
|
|
3302
|
-
// src/artifacts/
|
|
3356
|
+
// src/artifacts/setup-artifacts.ts
|
|
3303
3357
|
function setupHelpers(ctx) {
|
|
3304
3358
|
const code = generateHelpers(ctx);
|
|
3305
3359
|
return {
|
|
3360
|
+
id: "helpers",
|
|
3306
3361
|
files: [{ file: ctx.file.ext("helpers"), code: code.js }]
|
|
3307
3362
|
};
|
|
3308
3363
|
}
|
|
3309
3364
|
function setupKeyframes(ctx) {
|
|
3310
3365
|
const code = generateKeyframeCss(ctx);
|
|
3311
3366
|
return {
|
|
3367
|
+
id: "keyframes",
|
|
3312
3368
|
dir: ctx.paths.token,
|
|
3313
3369
|
files: [{ file: "keyframes.css", code }]
|
|
3314
3370
|
};
|
|
@@ -3319,6 +3375,7 @@ function setupDesignTokens(ctx) {
|
|
|
3319
3375
|
const code = generateTokenJs(ctx);
|
|
3320
3376
|
const css2 = generateTokenCss(ctx);
|
|
3321
3377
|
return {
|
|
3378
|
+
id: "design-tokens",
|
|
3322
3379
|
dir: ctx.paths.token,
|
|
3323
3380
|
files: [
|
|
3324
3381
|
{ file: "index.css", code: css2 },
|
|
@@ -3328,34 +3385,73 @@ function setupDesignTokens(ctx) {
|
|
|
3328
3385
|
]
|
|
3329
3386
|
};
|
|
3330
3387
|
}
|
|
3331
|
-
function
|
|
3332
|
-
|
|
3333
|
-
|
|
3388
|
+
function setupJsxTypes(ctx) {
|
|
3389
|
+
if (!ctx.jsx.framework)
|
|
3390
|
+
return;
|
|
3334
3391
|
const jsx = generateJsxTypes(ctx);
|
|
3335
|
-
const entry = generateTypesEntry(ctx, jsx != null);
|
|
3336
3392
|
return {
|
|
3393
|
+
id: "types-jsx",
|
|
3394
|
+
dir: ctx.paths.types,
|
|
3395
|
+
files: [{ file: ctx.file.extDts("jsx"), code: jsx.jsxType }]
|
|
3396
|
+
};
|
|
3397
|
+
}
|
|
3398
|
+
function setupEntryTypes(ctx) {
|
|
3399
|
+
const entry = generateTypesEntry(ctx, Boolean(ctx.jsx.framework));
|
|
3400
|
+
return {
|
|
3401
|
+
id: "types-entry",
|
|
3402
|
+
dir: ctx.paths.types,
|
|
3403
|
+
files: [
|
|
3404
|
+
{ file: ctx.file.extDts("global"), code: entry.global },
|
|
3405
|
+
{ file: ctx.file.extDts("index"), code: entry.index }
|
|
3406
|
+
]
|
|
3407
|
+
};
|
|
3408
|
+
}
|
|
3409
|
+
function setupStyleTypes(ctx) {
|
|
3410
|
+
return {
|
|
3411
|
+
id: "types-styles",
|
|
3412
|
+
dir: ctx.paths.types,
|
|
3413
|
+
files: [
|
|
3414
|
+
{ file: ctx.file.extDts("prop-type"), code: generatePropTypes(ctx) },
|
|
3415
|
+
{ file: ctx.file.extDts("style-props"), code: generateStyleProps(ctx) }
|
|
3416
|
+
]
|
|
3417
|
+
};
|
|
3418
|
+
}
|
|
3419
|
+
function setupConditionsTypes(ctx) {
|
|
3420
|
+
const conditions = generateConditions(ctx);
|
|
3421
|
+
return {
|
|
3422
|
+
id: "types-conditions",
|
|
3423
|
+
dir: ctx.paths.types,
|
|
3424
|
+
files: [{ file: ctx.file.extDts("conditions"), code: conditions.dts }]
|
|
3425
|
+
};
|
|
3426
|
+
}
|
|
3427
|
+
function setupGeneratedTypes(ctx) {
|
|
3428
|
+
const gen = getGeneratedTypes(ctx);
|
|
3429
|
+
return {
|
|
3430
|
+
id: "types-gen",
|
|
3337
3431
|
dir: ctx.paths.types,
|
|
3338
3432
|
files: [
|
|
3339
|
-
jsx ? { file: ctx.file.extDts("jsx"), code: jsx.jsxType } : null,
|
|
3340
3433
|
{ file: ctx.file.extDts("csstype"), code: gen.cssType },
|
|
3341
|
-
{ file: ctx.file.extDts("system-types"), code: gen.system },
|
|
3342
3434
|
{ file: ctx.file.extDts("selectors"), code: gen.selectors },
|
|
3343
3435
|
{ file: ctx.file.extDts("composition"), code: gen.composition },
|
|
3344
|
-
{ file: ctx.file.extDts("global"), code: entry.global },
|
|
3345
3436
|
{ file: ctx.file.extDts("recipe"), code: gen.recipe },
|
|
3346
3437
|
{ file: ctx.file.extDts("pattern"), code: gen.pattern },
|
|
3347
|
-
{ file: ctx.file.extDts("parts"), code: gen.parts }
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3438
|
+
{ file: ctx.file.extDts("parts"), code: gen.parts }
|
|
3439
|
+
]
|
|
3440
|
+
};
|
|
3441
|
+
}
|
|
3442
|
+
function setupGeneratedSystemTypes(ctx) {
|
|
3443
|
+
const gen = getGeneratedSystemTypes(ctx);
|
|
3444
|
+
return {
|
|
3445
|
+
id: "types-gen-system",
|
|
3446
|
+
dir: ctx.paths.types,
|
|
3447
|
+
files: [{ file: ctx.file.extDts("system-types"), code: gen.system }]
|
|
3353
3448
|
};
|
|
3354
3449
|
}
|
|
3355
3450
|
function setupCss(ctx) {
|
|
3356
3451
|
const code = ctx.isTemplateLiteralSyntax ? generateStringLiteralCssFn(ctx) : generateCssFn(ctx);
|
|
3357
3452
|
const conditions = ctx.isTemplateLiteralSyntax ? generateStringLiteralConditions(ctx) : generateConditions(ctx);
|
|
3358
3453
|
return {
|
|
3454
|
+
id: "css-fn",
|
|
3359
3455
|
dir: ctx.paths.css,
|
|
3360
3456
|
files: [
|
|
3361
3457
|
{ file: ctx.file.ext("conditions"), code: conditions.js },
|
|
@@ -3369,6 +3465,7 @@ function setupCva(ctx) {
|
|
|
3369
3465
|
return;
|
|
3370
3466
|
const code = generateCvaFn(ctx);
|
|
3371
3467
|
return {
|
|
3468
|
+
id: "cva",
|
|
3372
3469
|
dir: ctx.paths.css,
|
|
3373
3470
|
files: [
|
|
3374
3471
|
{ file: ctx.file.ext("cva"), code: code.js },
|
|
@@ -3381,6 +3478,7 @@ function setupSva(ctx) {
|
|
|
3381
3478
|
return;
|
|
3382
3479
|
const code = generateSvaFn(ctx);
|
|
3383
3480
|
return {
|
|
3481
|
+
id: "sva",
|
|
3384
3482
|
dir: ctx.paths.css,
|
|
3385
3483
|
files: [
|
|
3386
3484
|
{ file: ctx.file.ext("sva"), code: code.js },
|
|
@@ -3391,6 +3489,7 @@ function setupSva(ctx) {
|
|
|
3391
3489
|
function setupCx(ctx) {
|
|
3392
3490
|
const code = generateCx();
|
|
3393
3491
|
return {
|
|
3492
|
+
id: "cx",
|
|
3394
3493
|
dir: ctx.paths.css,
|
|
3395
3494
|
files: [
|
|
3396
3495
|
{ file: ctx.file.ext("cx"), code: code.js },
|
|
@@ -3398,79 +3497,160 @@ function setupCx(ctx) {
|
|
|
3398
3497
|
]
|
|
3399
3498
|
};
|
|
3400
3499
|
}
|
|
3401
|
-
function
|
|
3402
|
-
|
|
3403
|
-
if (!files)
|
|
3500
|
+
function setupCreateRecipe(ctx) {
|
|
3501
|
+
if (ctx.recipes.isEmpty())
|
|
3404
3502
|
return;
|
|
3405
|
-
const
|
|
3503
|
+
const createRecipe = generateCreateRecipe(ctx);
|
|
3504
|
+
return {
|
|
3505
|
+
id: "create-recipe",
|
|
3506
|
+
dir: ctx.paths.recipe,
|
|
3507
|
+
files: [
|
|
3508
|
+
{ file: ctx.file.ext(createRecipe.name), code: createRecipe.js },
|
|
3509
|
+
{ file: ctx.file.extDts(createRecipe.name), code: createRecipe.dts }
|
|
3510
|
+
]
|
|
3511
|
+
};
|
|
3512
|
+
}
|
|
3513
|
+
function setupRecipesIndex(ctx) {
|
|
3514
|
+
if (ctx.recipes.isEmpty())
|
|
3515
|
+
return;
|
|
3516
|
+
const fileNames = ctx.recipes.details.map((recipe) => recipe.dashName);
|
|
3406
3517
|
const index = {
|
|
3407
|
-
js: import_outdent44.default.string(
|
|
3408
|
-
dts: import_outdent44.default.string(
|
|
3518
|
+
js: import_outdent44.default.string(fileNames.map((file) => ctx.file.exportStar(`./${file}`)).join("\n")),
|
|
3519
|
+
dts: import_outdent44.default.string(fileNames.map((file) => ctx.file.exportTypeStar(`./${file}`)).join("\n"))
|
|
3409
3520
|
};
|
|
3410
3521
|
return {
|
|
3522
|
+
id: "recipes-index",
|
|
3411
3523
|
dir: ctx.paths.recipe,
|
|
3412
3524
|
files: [
|
|
3413
|
-
...files.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
|
|
3414
|
-
...files.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
|
|
3415
3525
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
3416
3526
|
{ file: ctx.file.extDts("index"), code: index.dts }
|
|
3417
3527
|
]
|
|
3418
3528
|
};
|
|
3419
3529
|
}
|
|
3420
|
-
function
|
|
3421
|
-
if (ctx.
|
|
3530
|
+
function setupRecipes(ctx, filters) {
|
|
3531
|
+
if (ctx.recipes.isEmpty())
|
|
3422
3532
|
return;
|
|
3423
|
-
const files =
|
|
3533
|
+
const files = generateRecipes(ctx, filters);
|
|
3424
3534
|
if (!files)
|
|
3425
3535
|
return;
|
|
3536
|
+
return {
|
|
3537
|
+
id: "recipes",
|
|
3538
|
+
dir: ctx.paths.recipe,
|
|
3539
|
+
files: files.flatMap((file) => [
|
|
3540
|
+
{ file: ctx.file.ext(file.name), code: file.js },
|
|
3541
|
+
{ file: ctx.file.extDts(file.name), code: file.dts }
|
|
3542
|
+
])
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
function setupPatternsIndex(ctx) {
|
|
3546
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
3547
|
+
return;
|
|
3548
|
+
const fileNames = ctx.patterns.details.map((pattern) => pattern.dashName);
|
|
3426
3549
|
const index = {
|
|
3427
|
-
js: import_outdent44.default.string(
|
|
3428
|
-
dts: import_outdent44.default.string(
|
|
3550
|
+
js: import_outdent44.default.string(fileNames.map((file) => ctx.file.exportStar(`./${file}`)).join("\n")),
|
|
3551
|
+
dts: import_outdent44.default.string(fileNames.map((file) => ctx.file.exportTypeStar(`./${file}`)).join("\n"))
|
|
3429
3552
|
};
|
|
3430
3553
|
return {
|
|
3554
|
+
id: "patterns-index",
|
|
3431
3555
|
dir: ctx.paths.pattern,
|
|
3432
3556
|
files: [
|
|
3433
|
-
...files.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
|
|
3434
|
-
...files.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
|
|
3435
3557
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
3436
3558
|
{ file: ctx.file.extDts("index"), code: index.dts }
|
|
3437
3559
|
]
|
|
3438
3560
|
};
|
|
3439
3561
|
}
|
|
3440
|
-
function
|
|
3441
|
-
if (
|
|
3562
|
+
function setupPatterns(ctx, filters) {
|
|
3563
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
3564
|
+
return;
|
|
3565
|
+
const files = generatePattern(ctx, filters);
|
|
3566
|
+
if (!files)
|
|
3567
|
+
return;
|
|
3568
|
+
return {
|
|
3569
|
+
id: "patterns",
|
|
3570
|
+
dir: ctx.paths.pattern,
|
|
3571
|
+
files: files.flatMap((file) => [
|
|
3572
|
+
{ file: ctx.file.ext(file.name), code: file.js },
|
|
3573
|
+
{ file: ctx.file.extDts(file.name), code: file.dts }
|
|
3574
|
+
])
|
|
3575
|
+
};
|
|
3576
|
+
}
|
|
3577
|
+
function setupJsxIsValidProp(ctx) {
|
|
3578
|
+
if (!ctx.jsx.framework || ctx.isTemplateLiteralSyntax)
|
|
3442
3579
|
return;
|
|
3443
3580
|
const isValidProp = generateIsValidProp(ctx);
|
|
3581
|
+
return {
|
|
3582
|
+
id: "jsx-is-valid-prop",
|
|
3583
|
+
dir: ctx.paths.jsx,
|
|
3584
|
+
files: [
|
|
3585
|
+
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
3586
|
+
{ file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts }
|
|
3587
|
+
]
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
function setupJsxFactory(ctx) {
|
|
3591
|
+
if (!ctx.jsx.framework)
|
|
3592
|
+
return;
|
|
3444
3593
|
const types = generateJsxTypes(ctx);
|
|
3445
3594
|
const factory = generateJsxFactory(ctx);
|
|
3446
|
-
|
|
3595
|
+
return {
|
|
3596
|
+
id: "jsx-factory",
|
|
3597
|
+
dir: ctx.paths.jsx,
|
|
3598
|
+
files: [
|
|
3599
|
+
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
3600
|
+
{ file: ctx.file.extDts("factory"), code: types.jsxFactory }
|
|
3601
|
+
]
|
|
3602
|
+
};
|
|
3603
|
+
}
|
|
3604
|
+
function setupJsxHelpers(ctx) {
|
|
3605
|
+
if (!ctx.jsx.framework)
|
|
3606
|
+
return;
|
|
3447
3607
|
const helpers3 = generatedJsxHelpers(ctx);
|
|
3608
|
+
return {
|
|
3609
|
+
id: "jsx-helpers",
|
|
3610
|
+
dir: ctx.paths.jsx,
|
|
3611
|
+
files: [{ file: ctx.file.ext("factory-helper"), code: helpers3.js }]
|
|
3612
|
+
};
|
|
3613
|
+
}
|
|
3614
|
+
function setupJsxPatterns(ctx, filters) {
|
|
3615
|
+
if (!ctx.jsx.framework)
|
|
3616
|
+
return;
|
|
3617
|
+
const patterns = generateJsxPatterns(ctx, filters);
|
|
3618
|
+
return {
|
|
3619
|
+
id: "jsx-patterns",
|
|
3620
|
+
dir: ctx.paths.jsx,
|
|
3621
|
+
files: [
|
|
3622
|
+
...patterns.flatMap((file) => [
|
|
3623
|
+
{ file: ctx.file.ext(file.name), code: file.js },
|
|
3624
|
+
{ file: ctx.file.extDts(file.name), code: file.dts }
|
|
3625
|
+
])
|
|
3626
|
+
]
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
function setupJsxPatternsIndex(ctx) {
|
|
3630
|
+
if (!ctx.jsx.framework)
|
|
3631
|
+
return;
|
|
3632
|
+
const isStyleProp = !ctx.isTemplateLiteralSyntax;
|
|
3633
|
+
const patternNames = ctx.patterns.details.map((pattern) => pattern.dashName);
|
|
3448
3634
|
const index = {
|
|
3449
3635
|
js: import_outdent44.default`
|
|
3450
3636
|
${ctx.file.exportStar("./factory")}
|
|
3451
|
-
${
|
|
3452
|
-
${import_outdent44.default.string(
|
|
3637
|
+
${isStyleProp ? ctx.file.exportStar("./is-valid-prop") : ""}
|
|
3638
|
+
${import_outdent44.default.string(patternNames.map((file) => ctx.file.exportStar(`./${file}`)).join("\n"))}
|
|
3453
3639
|
`,
|
|
3454
3640
|
dts: import_outdent44.default`
|
|
3455
3641
|
${ctx.file.exportTypeStar("./factory")}
|
|
3456
3642
|
|
|
3457
|
-
${
|
|
3643
|
+
${isStyleProp ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3458
3644
|
|
|
3459
|
-
${import_outdent44.default.string(
|
|
3645
|
+
${import_outdent44.default.string(patternNames.map((file) => ctx.file.exportTypeStar(`./${file}`)).join("\n"))}
|
|
3460
3646
|
|
|
3461
3647
|
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3462
3648
|
`
|
|
3463
3649
|
};
|
|
3464
3650
|
return {
|
|
3651
|
+
id: "jsx-patterns-index",
|
|
3465
3652
|
dir: ctx.paths.jsx,
|
|
3466
3653
|
files: [
|
|
3467
|
-
...patterns.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
|
|
3468
|
-
...patterns.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
|
|
3469
|
-
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
3470
|
-
{ file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts },
|
|
3471
|
-
{ file: ctx.file.ext("factory-helper"), code: helpers3.js },
|
|
3472
|
-
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
3473
|
-
{ file: ctx.file.extDts("factory"), code: types.jsxFactory },
|
|
3474
3654
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
3475
3655
|
{ file: ctx.file.extDts("index"), code: index.dts }
|
|
3476
3656
|
]
|
|
@@ -3492,6 +3672,7 @@ function setupCssIndex(ctx) {
|
|
|
3492
3672
|
`
|
|
3493
3673
|
};
|
|
3494
3674
|
return {
|
|
3675
|
+
id: "css-index",
|
|
3495
3676
|
dir: ctx.paths.css,
|
|
3496
3677
|
files: [
|
|
3497
3678
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
@@ -3505,60 +3686,131 @@ function setupResetCss(ctx) {
|
|
|
3505
3686
|
return;
|
|
3506
3687
|
const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
|
|
3507
3688
|
const code = generateResetCss(ctx, scope);
|
|
3508
|
-
return { files: [{ file: "reset.css", code }] };
|
|
3689
|
+
return { id: "reset.css", files: [{ file: "reset.css", code }] };
|
|
3509
3690
|
}
|
|
3510
3691
|
function setupGlobalCss(ctx) {
|
|
3511
3692
|
const code = generateGlobalCss(ctx);
|
|
3512
|
-
return { files: [{ file: "global.css", code }] };
|
|
3693
|
+
return { id: "global.css", files: [{ file: "global.css", code }] };
|
|
3513
3694
|
}
|
|
3514
3695
|
function setupStaticCss(ctx) {
|
|
3515
3696
|
const code = generateStaticCss(ctx);
|
|
3516
|
-
return { files: [{ file: "static.css", code }] };
|
|
3697
|
+
return { id: "static.css", files: [{ file: "static.css", code }] };
|
|
3517
3698
|
}
|
|
3518
3699
|
function setupPackageJson(ctx) {
|
|
3519
3700
|
if (!ctx.config.emitPackage)
|
|
3520
3701
|
return;
|
|
3521
3702
|
return {
|
|
3703
|
+
id: "package.json",
|
|
3522
3704
|
files: [{ file: "package.json", code: generatePackageJson(ctx) }]
|
|
3523
3705
|
};
|
|
3524
3706
|
}
|
|
3525
|
-
var
|
|
3526
|
-
if (
|
|
3527
|
-
return
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3707
|
+
var getAffectedArtifacts = (ids) => {
|
|
3708
|
+
if (!ids)
|
|
3709
|
+
return;
|
|
3710
|
+
const hasSpecificArtifacts = ids.some(
|
|
3711
|
+
(id) => id.startsWith("recipes.") || id.startsWith("slot-recipes.") || id.startsWith("patterns.")
|
|
3712
|
+
);
|
|
3713
|
+
if (!hasSpecificArtifacts)
|
|
3714
|
+
return;
|
|
3715
|
+
return {
|
|
3716
|
+
recipes: ids.filter((id) => id.startsWith("recipes.") || id.startsWith("slot-recipes.")).map((id) => id.replace("slot-recipes.", "").replace("recipes.", "")),
|
|
3717
|
+
patterns: ids.filter((id) => id.startsWith("patterns.")).map((id) => id.replace("patterns.", ""))
|
|
3718
|
+
};
|
|
3719
|
+
};
|
|
3720
|
+
var filterArtifactsFiles = (artifacts, filters) => {
|
|
3721
|
+
const ids = filters?.ids;
|
|
3722
|
+
if (!ids)
|
|
3723
|
+
return artifacts;
|
|
3724
|
+
const affected = filters.affecteds;
|
|
3725
|
+
return artifacts.filter((artifact) => {
|
|
3726
|
+
if (!artifact)
|
|
3727
|
+
return false;
|
|
3728
|
+
return ids.includes(artifact.id);
|
|
3729
|
+
}).map((artifact) => {
|
|
3547
3730
|
const files = artifact?.files ?? [];
|
|
3548
|
-
files.
|
|
3549
|
-
if (!
|
|
3731
|
+
const filtered = files.filter((item) => {
|
|
3732
|
+
if (!item)
|
|
3550
3733
|
return;
|
|
3551
|
-
if (
|
|
3552
|
-
|
|
3553
|
-
|
|
3734
|
+
if (!affected)
|
|
3735
|
+
return true;
|
|
3736
|
+
if (affected.recipes && !item.file.includes("index") && artifact?.dir?.includes("recipes")) {
|
|
3737
|
+
const isAffected = affected.recipes.some((recipe) => item.file.includes(recipe));
|
|
3738
|
+
if (!isAffected)
|
|
3739
|
+
return;
|
|
3554
3740
|
}
|
|
3741
|
+
if (affected.patterns && !item.file.includes("index") && (artifact?.dir?.includes("patterns") || artifact?.dir?.includes("jsx"))) {
|
|
3742
|
+
const isAffected = affected.patterns.some((pattern) => item.file.includes(pattern));
|
|
3743
|
+
if (!isAffected)
|
|
3744
|
+
return;
|
|
3745
|
+
}
|
|
3746
|
+
return true;
|
|
3555
3747
|
});
|
|
3556
|
-
return artifact;
|
|
3748
|
+
return { ...artifact, files: filtered };
|
|
3749
|
+
});
|
|
3750
|
+
};
|
|
3751
|
+
var entries = [
|
|
3752
|
+
["helpers", setupHelpers],
|
|
3753
|
+
["design-tokens", setupDesignTokens],
|
|
3754
|
+
["keyframes", setupKeyframes],
|
|
3755
|
+
["types-jsx", setupJsxTypes],
|
|
3756
|
+
["types-entry", setupEntryTypes],
|
|
3757
|
+
["types-styles", setupStyleTypes],
|
|
3758
|
+
["types-conditions", setupConditionsTypes],
|
|
3759
|
+
["types-gen", setupGeneratedTypes],
|
|
3760
|
+
["types-gen-system", setupGeneratedSystemTypes],
|
|
3761
|
+
["css-fn", setupCss],
|
|
3762
|
+
["cva", setupCva],
|
|
3763
|
+
["sva", setupSva],
|
|
3764
|
+
["cx", setupCx],
|
|
3765
|
+
["create-recipe", setupCreateRecipe],
|
|
3766
|
+
["recipes-index", setupRecipesIndex],
|
|
3767
|
+
["recipes", setupRecipes],
|
|
3768
|
+
["patterns-index", setupPatternsIndex],
|
|
3769
|
+
["patterns", setupPatterns],
|
|
3770
|
+
["jsx-is-valid-prop", setupJsxIsValidProp],
|
|
3771
|
+
["jsx-factory", setupJsxFactory],
|
|
3772
|
+
["jsx-helpers", setupJsxHelpers],
|
|
3773
|
+
["jsx-patterns", setupJsxPatterns],
|
|
3774
|
+
["jsx-patterns-index", setupJsxPatternsIndex],
|
|
3775
|
+
["css-index", setupCssIndex],
|
|
3776
|
+
["reset.css", setupResetCss],
|
|
3777
|
+
["global.css", setupGlobalCss],
|
|
3778
|
+
["static.css", setupStaticCss],
|
|
3779
|
+
["package.json", setupPackageJson]
|
|
3780
|
+
];
|
|
3781
|
+
var getMatchingArtifacts = (ctx, filters) => {
|
|
3782
|
+
const ids = filters?.ids;
|
|
3783
|
+
if (!ids)
|
|
3784
|
+
return entries.map(([_artifactId, fn]) => fn(ctx));
|
|
3785
|
+
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters));
|
|
3786
|
+
};
|
|
3787
|
+
var transformArtifact = (ctx, artifact) => {
|
|
3788
|
+
const files = (artifact?.files ?? []).filter(Boolean).map((item) => {
|
|
3789
|
+
if (ctx.file.isTypeFile(item.file)) {
|
|
3790
|
+
return { ...item, code: `/* eslint-disable */
|
|
3791
|
+
${item.code}` };
|
|
3792
|
+
}
|
|
3793
|
+
return item;
|
|
3557
3794
|
});
|
|
3795
|
+
return { ...artifact, files };
|
|
3796
|
+
};
|
|
3797
|
+
var setupArtifacts = (ctx, ids) => {
|
|
3798
|
+
const affecteds = getAffectedArtifacts(ids);
|
|
3799
|
+
const artifacts = getMatchingArtifacts(ctx, { ids, affecteds });
|
|
3800
|
+
const matches = filterArtifactsFiles(artifacts, { ids, affecteds });
|
|
3801
|
+
return matches.map((artifact) => transformArtifact(ctx, artifact));
|
|
3802
|
+
};
|
|
3803
|
+
|
|
3804
|
+
// src/artifacts/index.ts
|
|
3805
|
+
var generateArtifacts = (ctx, ids) => {
|
|
3806
|
+
if (ctx.config.emitTokensOnly) {
|
|
3807
|
+
return [setupDesignTokens(ctx)];
|
|
3808
|
+
}
|
|
3809
|
+
return setupArtifacts(ctx, ids);
|
|
3558
3810
|
};
|
|
3559
3811
|
|
|
3560
3812
|
// src/artifacts/css/flat-css.ts
|
|
3561
|
-
var generateFlattenedCss = (ctx
|
|
3813
|
+
var generateFlattenedCss = (ctx, options) => {
|
|
3562
3814
|
const { files, resolve } = options;
|
|
3563
3815
|
const { theme: { keyframes } = {}, preflight, minify, staticCss } = ctx.config;
|
|
3564
3816
|
const unresolved = [
|
|
@@ -3587,7 +3839,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3587
3839
|
// src/artifacts/css/parser-css.ts
|
|
3588
3840
|
var import_logger2 = require("@pandacss/logger");
|
|
3589
3841
|
var import_ts_pattern10 = require("ts-pattern");
|
|
3590
|
-
var generateParserCss = (ctx
|
|
3842
|
+
var generateParserCss = (ctx, result) => {
|
|
3591
3843
|
const { patterns, recipes } = ctx;
|
|
3592
3844
|
const sheet = ctx.createSheet();
|
|
3593
3845
|
result.css.forEach((css2) => {
|
|
@@ -3671,161 +3923,26 @@ var filterProps = (ctx, props) => {
|
|
|
3671
3923
|
return clone;
|
|
3672
3924
|
};
|
|
3673
3925
|
|
|
3674
|
-
// src/engines/
|
|
3926
|
+
// src/engines/index.ts
|
|
3675
3927
|
var import_core5 = require("@pandacss/core");
|
|
3676
3928
|
var import_is_valid_prop3 = require("@pandacss/is-valid-prop");
|
|
3677
|
-
var
|
|
3929
|
+
var import_shared7 = require("@pandacss/shared");
|
|
3678
3930
|
var import_token_dictionary = require("@pandacss/token-dictionary");
|
|
3679
3931
|
var import_lil_fp = require("lil-fp");
|
|
3680
3932
|
var import_postcss3 = __toESM(require("postcss"));
|
|
3681
|
-
var helpers = {
|
|
3682
|
-
map: import_shared5.mapObject
|
|
3683
|
-
};
|
|
3684
|
-
var getBaseEngine = (conf) => {
|
|
3685
|
-
const { config } = conf;
|
|
3686
|
-
const theme = config.theme ?? {};
|
|
3687
|
-
const isTemplateLiteralSyntax = config.syntax === "template-literal";
|
|
3688
|
-
const hash = {
|
|
3689
|
-
tokens: (0, import_lil_fp.isBool)(config.hash) ? config.hash : config.hash?.cssVar,
|
|
3690
|
-
className: (0, import_lil_fp.isBool)(config.hash) ? config.hash : config.hash?.className
|
|
3691
|
-
};
|
|
3692
|
-
const prefix = {
|
|
3693
|
-
tokens: (0, import_lil_fp.isStr)(config.prefix) ? config.prefix : config.prefix?.cssVar,
|
|
3694
|
-
className: (0, import_lil_fp.isStr)(config.prefix) ? config.prefix : config.prefix?.className
|
|
3695
|
-
};
|
|
3696
|
-
const tokens = new import_token_dictionary.TokenDictionary({
|
|
3697
|
-
breakpoints: theme.breakpoints,
|
|
3698
|
-
tokens: theme.tokens,
|
|
3699
|
-
semanticTokens: theme.semanticTokens,
|
|
3700
|
-
prefix: prefix.tokens,
|
|
3701
|
-
hash: hash.tokens
|
|
3702
|
-
});
|
|
3703
|
-
const utility = new import_core5.Utility({
|
|
3704
|
-
prefix: prefix.className,
|
|
3705
|
-
tokens,
|
|
3706
|
-
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3707
|
-
separator: config.separator,
|
|
3708
|
-
shorthands: config.shorthands,
|
|
3709
|
-
strictTokens: config.strictTokens
|
|
3710
|
-
});
|
|
3711
|
-
const conditions = new import_core5.Conditions({
|
|
3712
|
-
conditions: config.conditions,
|
|
3713
|
-
breakpoints: config.theme?.breakpoints
|
|
3714
|
-
});
|
|
3715
|
-
const { textStyles, layerStyles } = theme;
|
|
3716
|
-
const compositions = (0, import_shared5.compact)({
|
|
3717
|
-
textStyle: textStyles,
|
|
3718
|
-
layerStyle: layerStyles
|
|
3719
|
-
});
|
|
3720
|
-
const compositionContext = { conditions, utility };
|
|
3721
|
-
(0, import_core5.assignCompositions)(compositions, compositionContext);
|
|
3722
|
-
const layers = config.layers;
|
|
3723
|
-
const layerNames = Object.values(layers);
|
|
3724
|
-
const isValidLayerRule = (0, import_shared5.memo)((layerRule) => {
|
|
3725
|
-
const names = new Set(layerRule.split(",").map((name) => name.trim()));
|
|
3726
|
-
return names.size >= 5 && layerNames.every((name) => names.has(name));
|
|
3727
|
-
});
|
|
3728
|
-
const layerString = `@layer ${layerNames.join(", ")};`;
|
|
3729
|
-
const createSheetContext = () => ({
|
|
3730
|
-
root: import_postcss3.default.root(),
|
|
3731
|
-
conditions,
|
|
3732
|
-
utility,
|
|
3733
|
-
hash: hash.className,
|
|
3734
|
-
helpers,
|
|
3735
|
-
layers
|
|
3736
|
-
});
|
|
3737
|
-
const createSheet = (options) => {
|
|
3738
|
-
const sheetContext = createSheetContext();
|
|
3739
|
-
return new import_core5.Stylesheet(sheetContext, {
|
|
3740
|
-
content: options?.content,
|
|
3741
|
-
recipes: theme?.recipes,
|
|
3742
|
-
slotRecipes: theme?.slotRecipes
|
|
3743
|
-
});
|
|
3744
|
-
};
|
|
3745
|
-
const recipeContext = createSheetContext();
|
|
3746
|
-
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
3747
|
-
const recipes = new import_core5.Recipes(recipeConfigs, recipeContext);
|
|
3748
|
-
recipes.save();
|
|
3749
|
-
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
3750
|
-
const propertyMap = new Map(properties.map((prop) => [prop, true]));
|
|
3751
|
-
const isValidProperty = (0, import_shared5.memo)((key) => {
|
|
3752
|
-
return propertyMap.has(key) || (0, import_is_valid_prop3.isCssProperty)(key);
|
|
3753
|
-
});
|
|
3754
|
-
const studio = {
|
|
3755
|
-
outdir: `${config.outdir}-studio`,
|
|
3756
|
-
...conf.config.studio
|
|
3757
|
-
};
|
|
3758
|
-
return {
|
|
3759
|
-
...conf,
|
|
3760
|
-
isTemplateLiteralSyntax,
|
|
3761
|
-
studio,
|
|
3762
|
-
hash,
|
|
3763
|
-
prefix,
|
|
3764
|
-
tokens,
|
|
3765
|
-
utility,
|
|
3766
|
-
properties,
|
|
3767
|
-
isValidProperty,
|
|
3768
|
-
recipes,
|
|
3769
|
-
conditions,
|
|
3770
|
-
createSheetContext,
|
|
3771
|
-
createSheet,
|
|
3772
|
-
// cascade layer
|
|
3773
|
-
layers,
|
|
3774
|
-
isValidLayerRule,
|
|
3775
|
-
layerString,
|
|
3776
|
-
layerNames
|
|
3777
|
-
};
|
|
3778
|
-
};
|
|
3779
|
-
|
|
3780
|
-
// src/engines/jsx.ts
|
|
3781
|
-
var import_shared6 = require("@pandacss/shared");
|
|
3782
|
-
var getJsxEngine = (config) => {
|
|
3783
|
-
const { jsxFactory, jsxFramework, jsxStyleProps: jsxStyleProps2 } = config;
|
|
3784
|
-
return {
|
|
3785
|
-
factoryName: jsxFactory,
|
|
3786
|
-
upperName: (0, import_shared6.capitalize)(jsxFactory),
|
|
3787
|
-
typeName: `HTML${(0, import_shared6.capitalize)(jsxFactory)}Props`,
|
|
3788
|
-
variantName: `${(0, import_shared6.capitalize)(jsxFactory)}VariantProps`,
|
|
3789
|
-
componentName: `${(0, import_shared6.capitalize)(jsxFactory)}Component`,
|
|
3790
|
-
framework: jsxFramework,
|
|
3791
|
-
styleProps: jsxStyleProps2 ?? "all"
|
|
3792
|
-
};
|
|
3793
|
-
};
|
|
3794
|
-
|
|
3795
|
-
// src/engines/path.ts
|
|
3796
|
-
var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
3797
|
-
const get = (file) => [cwd, emitPackage ? "node_modules" : void 0, outdir, file].filter(Boolean);
|
|
3798
|
-
return {
|
|
3799
|
-
get,
|
|
3800
|
-
root: get(),
|
|
3801
|
-
css: get("css"),
|
|
3802
|
-
token: get("tokens"),
|
|
3803
|
-
types: get("types"),
|
|
3804
|
-
recipe: get("recipes"),
|
|
3805
|
-
pattern: get("patterns"),
|
|
3806
|
-
chunk: get("chunks"),
|
|
3807
|
-
outCss: get("styles.css"),
|
|
3808
|
-
jsx: get("jsx")
|
|
3809
|
-
};
|
|
3810
|
-
};
|
|
3811
3933
|
|
|
3812
3934
|
// src/engines/pattern.ts
|
|
3813
|
-
var
|
|
3814
|
-
var
|
|
3815
|
-
var
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
jsxName: patterns[name]?.jsxName ?? upperName
|
|
3825
|
-
};
|
|
3826
|
-
};
|
|
3827
|
-
const details = Object.entries(patterns).map(([name, pattern]) => {
|
|
3828
|
-
const names = getNames(name);
|
|
3935
|
+
var import_shared5 = require("@pandacss/shared");
|
|
3936
|
+
var helpers = { map: import_shared5.mapObject };
|
|
3937
|
+
var Patterns = class {
|
|
3938
|
+
patterns;
|
|
3939
|
+
details;
|
|
3940
|
+
constructor(config) {
|
|
3941
|
+
this.patterns = config.patterns ?? {};
|
|
3942
|
+
this.details = Object.entries(this.patterns).map(([name, pattern]) => this.createDetail(name, pattern));
|
|
3943
|
+
}
|
|
3944
|
+
createDetail(name, pattern) {
|
|
3945
|
+
const names = this.getNames(name);
|
|
3829
3946
|
const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
|
|
3830
3947
|
return {
|
|
3831
3948
|
...names,
|
|
@@ -3833,77 +3950,334 @@ var getPatternEngine = (config) => {
|
|
|
3833
3950
|
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
|
|
3834
3951
|
config: pattern,
|
|
3835
3952
|
type: "pattern",
|
|
3836
|
-
match: (0,
|
|
3953
|
+
match: (0, import_shared5.createRegex)(jsx),
|
|
3837
3954
|
jsx
|
|
3838
3955
|
};
|
|
3956
|
+
}
|
|
3957
|
+
get keys() {
|
|
3958
|
+
return Object.keys(this.patterns);
|
|
3959
|
+
}
|
|
3960
|
+
getConfig(name) {
|
|
3961
|
+
return this.patterns[name];
|
|
3962
|
+
}
|
|
3963
|
+
transform(name, data) {
|
|
3964
|
+
return this.patterns[name]?.transform?.(data, helpers) ?? {};
|
|
3965
|
+
}
|
|
3966
|
+
getNames(name) {
|
|
3967
|
+
const upperName = (0, import_shared5.capitalize)(name);
|
|
3968
|
+
return {
|
|
3969
|
+
upperName,
|
|
3970
|
+
baseName: name,
|
|
3971
|
+
dashName: (0, import_shared5.dashCase)(name),
|
|
3972
|
+
styleFnName: `get${upperName}Style`,
|
|
3973
|
+
jsxName: this.patterns[name]?.jsxName ?? upperName
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
find = (0, import_shared5.memo)((jsxName) => {
|
|
3977
|
+
return this.details.find((node) => node.match.test(jsxName))?.baseName ?? (0, import_shared5.uncapitalize)(jsxName);
|
|
3839
3978
|
});
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
}
|
|
3979
|
+
filter = (0, import_shared5.memo)((jsxName) => {
|
|
3980
|
+
return this.details.filter((node) => node.match.test(jsxName));
|
|
3981
|
+
});
|
|
3982
|
+
isEmpty() {
|
|
3983
|
+
return this.keys.length === 0;
|
|
3984
|
+
}
|
|
3985
|
+
saveOne(name, pattern) {
|
|
3986
|
+
this.patterns[name] = pattern;
|
|
3987
|
+
const detailIndex = this.details.findIndex((detail) => detail.baseName === name);
|
|
3988
|
+
const updated = this.createDetail(name, pattern);
|
|
3989
|
+
if (detailIndex > -1) {
|
|
3990
|
+
this.details[detailIndex] = updated;
|
|
3991
|
+
} else {
|
|
3992
|
+
this.details.push(updated);
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
remove(name) {
|
|
3996
|
+
delete this.patterns[name];
|
|
3997
|
+
const detailIndex = this.details.findIndex((detail) => detail.baseName === name);
|
|
3998
|
+
if (detailIndex > -1) {
|
|
3999
|
+
this.details.splice(detailIndex, 1);
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
filterDetails(filters) {
|
|
4003
|
+
const patternDiffs = filters?.affecteds?.patterns;
|
|
4004
|
+
return patternDiffs ? this.details.filter((pattern) => patternDiffs.includes(pattern.dashName)) : this.details;
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
|
|
4008
|
+
// src/engines/jsx.ts
|
|
4009
|
+
var import_shared6 = require("@pandacss/shared");
|
|
4010
|
+
var JsxEngine = class {
|
|
4011
|
+
constructor(config) {
|
|
4012
|
+
this.config = config;
|
|
4013
|
+
}
|
|
4014
|
+
get jsxFactory() {
|
|
4015
|
+
return this.config.jsxFactory ?? "";
|
|
4016
|
+
}
|
|
4017
|
+
get styleProps() {
|
|
4018
|
+
return this.config.jsxStyleProps ?? "all";
|
|
4019
|
+
}
|
|
4020
|
+
get framework() {
|
|
4021
|
+
return this.config.jsxFramework;
|
|
4022
|
+
}
|
|
4023
|
+
get factoryName() {
|
|
4024
|
+
return this.jsxFactory;
|
|
4025
|
+
}
|
|
4026
|
+
get upperName() {
|
|
4027
|
+
return (0, import_shared6.capitalize)(this.jsxFactory);
|
|
4028
|
+
}
|
|
4029
|
+
get typeName() {
|
|
4030
|
+
return `HTML${(0, import_shared6.capitalize)(this.jsxFactory)}Props`;
|
|
4031
|
+
}
|
|
4032
|
+
get variantName() {
|
|
4033
|
+
return `${(0, import_shared6.capitalize)(this.jsxFactory)}VariantProps`;
|
|
4034
|
+
}
|
|
4035
|
+
get componentName() {
|
|
4036
|
+
return `${(0, import_shared6.capitalize)(this.jsxFactory)}Component`;
|
|
4037
|
+
}
|
|
4038
|
+
};
|
|
4039
|
+
|
|
4040
|
+
// src/engines/path.ts
|
|
4041
|
+
var PathEngine = class {
|
|
4042
|
+
constructor(config) {
|
|
4043
|
+
this.config = config;
|
|
4044
|
+
}
|
|
4045
|
+
get cwd() {
|
|
4046
|
+
return this.config.cwd;
|
|
4047
|
+
}
|
|
4048
|
+
get emitPackage() {
|
|
4049
|
+
return this.config.emitPackage || false;
|
|
4050
|
+
}
|
|
4051
|
+
get outdir() {
|
|
4052
|
+
return this.config.outdir;
|
|
4053
|
+
}
|
|
4054
|
+
getFilePath(file) {
|
|
4055
|
+
return [this.cwd, this.emitPackage ? "node_modules" : void 0, this.outdir, file].filter(Boolean);
|
|
4056
|
+
}
|
|
4057
|
+
get root() {
|
|
4058
|
+
return this.getFilePath();
|
|
4059
|
+
}
|
|
4060
|
+
get css() {
|
|
4061
|
+
return this.getFilePath("css");
|
|
4062
|
+
}
|
|
4063
|
+
get token() {
|
|
4064
|
+
return this.getFilePath("tokens");
|
|
4065
|
+
}
|
|
4066
|
+
get types() {
|
|
4067
|
+
return this.getFilePath("types");
|
|
4068
|
+
}
|
|
4069
|
+
get recipe() {
|
|
4070
|
+
return this.getFilePath("recipes");
|
|
4071
|
+
}
|
|
4072
|
+
get pattern() {
|
|
4073
|
+
return this.getFilePath("patterns");
|
|
4074
|
+
}
|
|
4075
|
+
get chunk() {
|
|
4076
|
+
return this.getFilePath("chunks");
|
|
4077
|
+
}
|
|
4078
|
+
get outCss() {
|
|
4079
|
+
return this.getFilePath("styles.css");
|
|
4080
|
+
}
|
|
4081
|
+
get jsx() {
|
|
4082
|
+
return this.getFilePath("jsx");
|
|
4083
|
+
}
|
|
3856
4084
|
};
|
|
3857
4085
|
|
|
3858
4086
|
// src/engines/file.ts
|
|
3859
|
-
var
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
}
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
}
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
}
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
}
|
|
3890
|
-
}
|
|
4087
|
+
var FileEngine = class {
|
|
4088
|
+
constructor(config) {
|
|
4089
|
+
this.config = config;
|
|
4090
|
+
}
|
|
4091
|
+
get forceConsistentTypeExtension() {
|
|
4092
|
+
return this.config.forceConsistentTypeExtension || false;
|
|
4093
|
+
}
|
|
4094
|
+
get outExtension() {
|
|
4095
|
+
return this.config.outExtension;
|
|
4096
|
+
}
|
|
4097
|
+
ext(file) {
|
|
4098
|
+
return `${file}.${this.outExtension}`;
|
|
4099
|
+
}
|
|
4100
|
+
extDts(file) {
|
|
4101
|
+
const dts = this.outExtension === "mjs" && this.forceConsistentTypeExtension ? "d.mts" : "d.ts";
|
|
4102
|
+
return `${file}.${dts}`;
|
|
4103
|
+
}
|
|
4104
|
+
__extDts(file) {
|
|
4105
|
+
return this.forceConsistentTypeExtension ? this.extDts(file) : file;
|
|
4106
|
+
}
|
|
4107
|
+
import(mod, file) {
|
|
4108
|
+
return `import { ${mod} } from '${this.ext(file)}';`;
|
|
4109
|
+
}
|
|
4110
|
+
importType(mod, file) {
|
|
4111
|
+
return `import type { ${mod} } from '${this.__extDts(file)}';`;
|
|
4112
|
+
}
|
|
4113
|
+
exportType(mod, file) {
|
|
4114
|
+
return `export type { ${mod} } from '${this.__extDts(file)}';`;
|
|
4115
|
+
}
|
|
4116
|
+
exportStar(file) {
|
|
4117
|
+
return `export * from '${this.ext(file)}';`;
|
|
4118
|
+
}
|
|
4119
|
+
exportTypeStar(file) {
|
|
4120
|
+
return `export * from '${this.__extDts(file)}';`;
|
|
4121
|
+
}
|
|
4122
|
+
isTypeFile(file) {
|
|
4123
|
+
return file.endsWith(".d.ts") || file.endsWith(".d.mts");
|
|
4124
|
+
}
|
|
3891
4125
|
};
|
|
3892
4126
|
|
|
3893
4127
|
// src/engines/index.ts
|
|
3894
|
-
var
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
4128
|
+
var helpers2 = { map: import_shared7.mapObject };
|
|
4129
|
+
var defaults = (config) => ({
|
|
4130
|
+
cssVarRoot: ":where(:root, :host)",
|
|
4131
|
+
jsxFactory: "styled",
|
|
4132
|
+
jsxStyleProps: "all",
|
|
4133
|
+
outExtension: "mjs",
|
|
4134
|
+
shorthands: true,
|
|
4135
|
+
syntax: "object-literal",
|
|
4136
|
+
...config,
|
|
4137
|
+
layers: {
|
|
4138
|
+
reset: "reset",
|
|
4139
|
+
base: "base",
|
|
4140
|
+
tokens: "tokens",
|
|
4141
|
+
recipes: "recipes",
|
|
4142
|
+
utilities: "utilities",
|
|
4143
|
+
...config.layers
|
|
4144
|
+
}
|
|
4145
|
+
});
|
|
4146
|
+
var Context = class {
|
|
4147
|
+
constructor(conf) {
|
|
4148
|
+
this.conf = conf;
|
|
4149
|
+
const config = defaults(conf.config);
|
|
4150
|
+
const theme = config.theme ?? {};
|
|
4151
|
+
conf.config = config;
|
|
4152
|
+
this.tokens = this.createTokenDictionary(theme);
|
|
4153
|
+
this.utility = this.createUtility(config);
|
|
4154
|
+
this.conditions = this.createConditions(config);
|
|
4155
|
+
this.patterns = new Patterns(config);
|
|
4156
|
+
this.jsx = new JsxEngine(config);
|
|
4157
|
+
this.paths = new PathEngine(config);
|
|
4158
|
+
this.file = new FileEngine(config);
|
|
4159
|
+
this.studio = { outdir: `${config.outdir}-studio`, ...conf.config.studio };
|
|
4160
|
+
this.setupCompositions(theme);
|
|
4161
|
+
this.setupLayers(config.layers);
|
|
4162
|
+
this.setupProperties();
|
|
4163
|
+
this.recipes = this.createRecipes(theme, this.createSheetContext());
|
|
4164
|
+
}
|
|
4165
|
+
studio;
|
|
4166
|
+
// Engines
|
|
4167
|
+
tokens;
|
|
4168
|
+
utility;
|
|
4169
|
+
recipes;
|
|
4170
|
+
conditions;
|
|
4171
|
+
patterns;
|
|
4172
|
+
jsx;
|
|
4173
|
+
paths;
|
|
4174
|
+
file;
|
|
4175
|
+
// Props
|
|
4176
|
+
properties;
|
|
4177
|
+
isValidProperty;
|
|
4178
|
+
// Layers
|
|
4179
|
+
layers;
|
|
4180
|
+
isValidLayerRule;
|
|
4181
|
+
layerString;
|
|
4182
|
+
layerNames;
|
|
4183
|
+
get config() {
|
|
4184
|
+
return this.conf.config;
|
|
4185
|
+
}
|
|
4186
|
+
get hooks() {
|
|
4187
|
+
return this.conf.hooks;
|
|
4188
|
+
}
|
|
4189
|
+
get isTemplateLiteralSyntax() {
|
|
4190
|
+
return this.config.syntax === "template-literal";
|
|
4191
|
+
}
|
|
4192
|
+
get hash() {
|
|
4193
|
+
return {
|
|
4194
|
+
tokens: (0, import_lil_fp.isBool)(this.config.hash) ? this.config.hash : this.config.hash?.cssVar,
|
|
4195
|
+
className: (0, import_lil_fp.isBool)(this.config.hash) ? this.config.hash : this.config.hash?.className
|
|
4196
|
+
};
|
|
4197
|
+
}
|
|
4198
|
+
get prefix() {
|
|
4199
|
+
return {
|
|
4200
|
+
tokens: (0, import_lil_fp.isStr)(this.config.prefix) ? this.config.prefix : this.config.prefix?.cssVar,
|
|
4201
|
+
className: (0, import_lil_fp.isStr)(this.config.prefix) ? this.config.prefix : this.config.prefix?.className
|
|
4202
|
+
};
|
|
4203
|
+
}
|
|
4204
|
+
createTokenDictionary(theme) {
|
|
4205
|
+
return new import_token_dictionary.TokenDictionary({
|
|
4206
|
+
breakpoints: theme.breakpoints,
|
|
4207
|
+
tokens: theme.tokens,
|
|
4208
|
+
semanticTokens: theme.semanticTokens,
|
|
4209
|
+
prefix: this.prefix.tokens,
|
|
4210
|
+
hash: this.hash.tokens
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
createUtility(config) {
|
|
4214
|
+
return new import_core5.Utility({
|
|
4215
|
+
prefix: this.prefix.className,
|
|
4216
|
+
tokens: this.tokens,
|
|
4217
|
+
config: this.isTemplateLiteralSyntax ? {} : config.utilities,
|
|
4218
|
+
separator: config.separator,
|
|
4219
|
+
shorthands: config.shorthands,
|
|
4220
|
+
strictTokens: config.strictTokens
|
|
4221
|
+
});
|
|
4222
|
+
}
|
|
4223
|
+
createConditions(config) {
|
|
4224
|
+
return new import_core5.Conditions({
|
|
4225
|
+
conditions: config.conditions,
|
|
4226
|
+
breakpoints: config.theme?.breakpoints
|
|
4227
|
+
});
|
|
4228
|
+
}
|
|
4229
|
+
setupCompositions(theme) {
|
|
4230
|
+
const { textStyles, layerStyles } = theme;
|
|
4231
|
+
const compositions = (0, import_shared7.compact)({ textStyle: textStyles, layerStyle: layerStyles });
|
|
4232
|
+
(0, import_core5.assignCompositions)(compositions, { conditions: this.conditions, utility: this.utility });
|
|
4233
|
+
}
|
|
4234
|
+
setupLayers(layers) {
|
|
4235
|
+
this.layers = layers;
|
|
4236
|
+
this.layerNames = Object.values(layers);
|
|
4237
|
+
this.isValidLayerRule = (0, import_shared7.memo)((layerRule) => {
|
|
4238
|
+
const names = new Set(layerRule.split(",").map((name) => name.trim()));
|
|
4239
|
+
return names.size >= 5 && this.layerNames.every((name) => names.has(name));
|
|
4240
|
+
});
|
|
4241
|
+
this.layerString = `@layer ${this.layerNames.join(", ")};`;
|
|
4242
|
+
}
|
|
4243
|
+
setupProperties() {
|
|
4244
|
+
this.properties = /* @__PURE__ */ new Set(["css", ...this.utility.keys(), ...this.conditions.keys()]);
|
|
4245
|
+
this.isValidProperty = (0, import_shared7.memo)((key) => this.properties.has(key) || (0, import_is_valid_prop3.isCssProperty)(key));
|
|
4246
|
+
}
|
|
4247
|
+
createSheetContext() {
|
|
4248
|
+
return {
|
|
4249
|
+
root: import_postcss3.default.root(),
|
|
4250
|
+
conditions: this.conditions,
|
|
4251
|
+
utility: this.utility,
|
|
4252
|
+
hash: this.hash.className,
|
|
4253
|
+
layers: this.layers,
|
|
4254
|
+
helpers: helpers2
|
|
4255
|
+
};
|
|
4256
|
+
}
|
|
4257
|
+
createSheet(options) {
|
|
4258
|
+
const sheetContext = this.createSheetContext();
|
|
4259
|
+
return new import_core5.Stylesheet(sheetContext, {
|
|
4260
|
+
content: options?.content,
|
|
4261
|
+
recipes: this.config.theme?.recipes,
|
|
4262
|
+
slotRecipes: this.config.theme?.slotRecipes
|
|
4263
|
+
});
|
|
4264
|
+
}
|
|
4265
|
+
createRecipes(theme, context) {
|
|
4266
|
+
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
4267
|
+
return new import_core5.Recipes(recipeConfigs, context);
|
|
4268
|
+
}
|
|
3903
4269
|
};
|
|
3904
4270
|
|
|
3905
4271
|
// src/parser-options.ts
|
|
3906
4272
|
var getImportMap = (outdir, configImportMap) => {
|
|
4273
|
+
if (typeof configImportMap === "string") {
|
|
4274
|
+
return {
|
|
4275
|
+
css: [configImportMap, "css"],
|
|
4276
|
+
recipe: [configImportMap, "recipes"],
|
|
4277
|
+
pattern: [configImportMap, "patterns"],
|
|
4278
|
+
jsx: [configImportMap, "jsx"]
|
|
4279
|
+
};
|
|
4280
|
+
}
|
|
3907
4281
|
const { css: css2, recipes, patterns, jsx } = configImportMap ?? {};
|
|
3908
4282
|
return {
|
|
3909
4283
|
css: css2 ? [css2] : [outdir, "css"],
|
|
@@ -3913,7 +4287,8 @@ var getImportMap = (outdir, configImportMap) => {
|
|
|
3913
4287
|
};
|
|
3914
4288
|
};
|
|
3915
4289
|
var getParserOptions = (ctx) => {
|
|
3916
|
-
const { config, jsx, isValidProperty, patterns, recipes
|
|
4290
|
+
const { config, jsx, isValidProperty, patterns, recipes } = ctx;
|
|
4291
|
+
const { tsconfig, tsOptions } = ctx.conf;
|
|
3917
4292
|
const compilerOptions = tsconfig?.compilerOptions ?? {};
|
|
3918
4293
|
const baseUrl = compilerOptions.baseUrl ?? "";
|
|
3919
4294
|
const cwd = config.cwd;
|
|
@@ -3937,48 +4312,41 @@ var getParserOptions = (ctx) => {
|
|
|
3937
4312
|
};
|
|
3938
4313
|
|
|
3939
4314
|
// src/generator.ts
|
|
3940
|
-
var
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4315
|
+
var Generator = class extends Context {
|
|
4316
|
+
messages;
|
|
4317
|
+
parserOptions;
|
|
4318
|
+
constructor(conf) {
|
|
4319
|
+
super(conf);
|
|
4320
|
+
this.parserOptions = getParserOptions(this);
|
|
4321
|
+
this.messages = getMessages(this);
|
|
4322
|
+
}
|
|
4323
|
+
getArtifacts(ids) {
|
|
4324
|
+
return generateArtifacts(this, ids);
|
|
4325
|
+
}
|
|
4326
|
+
getStaticCss() {
|
|
4327
|
+
return generateStaticCss(this);
|
|
4328
|
+
}
|
|
4329
|
+
getResetCss() {
|
|
4330
|
+
return generateResetCss(this);
|
|
4331
|
+
}
|
|
4332
|
+
getTokenCss() {
|
|
4333
|
+
return generateTokenCss(this);
|
|
4334
|
+
}
|
|
4335
|
+
getKeyframeCss() {
|
|
4336
|
+
return generateKeyframeCss(this);
|
|
4337
|
+
}
|
|
4338
|
+
getGlobalCss() {
|
|
4339
|
+
return generateGlobalCss(this);
|
|
4340
|
+
}
|
|
4341
|
+
getCss(options) {
|
|
4342
|
+
return generateFlattenedCss(this, options);
|
|
4343
|
+
}
|
|
4344
|
+
getParserCss(result) {
|
|
4345
|
+
return generateParserCss(this, result);
|
|
3958
4346
|
}
|
|
3959
|
-
});
|
|
3960
|
-
var createGenerator = (conf) => {
|
|
3961
|
-
const ctx = getEngine(defaults(conf));
|
|
3962
|
-
const parserOptions = getParserOptions(ctx);
|
|
3963
|
-
return {
|
|
3964
|
-
...ctx,
|
|
3965
|
-
getArtifacts: generateArtifacts(ctx),
|
|
3966
|
-
//
|
|
3967
|
-
getStaticCss: generateStaticCss,
|
|
3968
|
-
getResetCss: generateResetCss,
|
|
3969
|
-
getTokenCss: generateTokenCss,
|
|
3970
|
-
getKeyframeCss: generateKeyframeCss,
|
|
3971
|
-
getGlobalCss: generateGlobalCss,
|
|
3972
|
-
//
|
|
3973
|
-
getCss: generateFlattenedCss(ctx),
|
|
3974
|
-
getParserCss: generateParserCss(ctx),
|
|
3975
|
-
//
|
|
3976
|
-
messages: getMessages(ctx),
|
|
3977
|
-
parserOptions
|
|
3978
|
-
};
|
|
3979
4347
|
};
|
|
3980
4348
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3981
4349
|
0 && (module.exports = {
|
|
3982
|
-
|
|
4350
|
+
Generator,
|
|
3983
4351
|
messages
|
|
3984
4352
|
});
|