@pandacss/generator 0.0.0-dev-20240130182551 → 0.0.0-dev-20240201214314
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -17
- package/dist/index.mjs +14 -17
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -219,6 +219,7 @@ function generateCssFn(ctx) {
|
|
|
219
219
|
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
220
220
|
}` : `(key, value) => ({ className: \`\${classNameByProp.get(key) || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
221
221
|
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
222
|
+
toHash: ${utility.toHash},
|
|
222
223
|
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
223
224
|
}
|
|
224
225
|
}
|
|
@@ -261,6 +262,7 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
261
262
|
prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
|
|
262
263
|
transform,
|
|
263
264
|
hasShorthand: false,
|
|
265
|
+
toHash: ${utility.toHash},
|
|
264
266
|
resolveShorthand(prop) {
|
|
265
267
|
return prop
|
|
266
268
|
},
|
|
@@ -418,7 +420,7 @@ var astish_mjs_default = {
|
|
|
418
420
|
|
|
419
421
|
// src/artifacts/generated/helpers.mjs.json
|
|
420
422
|
var helpers_mjs_default = {
|
|
421
|
-
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/
|
|
423
|
+
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/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/important.ts\nvar importantRegex = /\\s*!(important)?/i;\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/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/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 (Array.isArray(obj))\n return obj.map((value) => fn(value));\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 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(utility.toHash(baseArray, toHash));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return memo((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) => normalizeStyleObject(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: memo(mergeCss), assignCss };\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/is-css-function.ts\nvar fns = ["min", "max", "clamp", "calc"];\nvar fnRegExp = new RegExp(`^(${fns.join("|")})\\\\(.*\\\\)`);\nvar isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);\n\n// src/is-css-unit.ts\nvar lengthUnits = "cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%";\nvar lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;\nvar lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nvar isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);\n\n// src/is-css-var.ts\nvar isCssVar = (v) => typeof v === "string" && /^var\\(--.+\\)$/.test(v);\n\n// src/pattern-fns.ts\nvar patternFns = {\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit\n};\nvar getPatternStyles = (pattern, styles) => {\n if (!pattern.defaultValues)\n return styles;\n const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\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 getPatternStyles,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n patternFns,\n splitProps,\n toHash,\n uniq,\n walkObject,\n withoutSpace\n};\n'
|
|
422
424
|
};
|
|
423
425
|
|
|
424
426
|
// src/artifacts/generated/normalize-html.mjs.json
|
|
@@ -623,13 +625,7 @@ var import_ts_pattern4 = require("ts-pattern");
|
|
|
623
625
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
624
626
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
625
627
|
function generateCreateRecipe(ctx) {
|
|
626
|
-
const {
|
|
627
|
-
conditions,
|
|
628
|
-
recipes,
|
|
629
|
-
prefix,
|
|
630
|
-
hash,
|
|
631
|
-
utility: { separator }
|
|
632
|
-
} = ctx;
|
|
628
|
+
const { conditions, recipes, prefix, hash, utility } = ctx;
|
|
633
629
|
if (recipes.isEmpty())
|
|
634
630
|
return;
|
|
635
631
|
return {
|
|
@@ -660,7 +656,7 @@ function generateCreateRecipe(ctx) {
|
|
|
660
656
|
}
|
|
661
657
|
|
|
662
658
|
value = withoutSpace(value)
|
|
663
|
-
return { className: \`\${name}--\${prop}${separator}\${value}\` }
|
|
659
|
+
return { className: \`\${name}--\${prop}${utility.separator}\${value}\` }
|
|
664
660
|
}
|
|
665
661
|
|
|
666
662
|
const recipeCss = createCss({
|
|
@@ -672,6 +668,7 @@ function generateCreateRecipe(ctx) {
|
|
|
672
668
|
},
|
|
673
669
|
utility: {
|
|
674
670
|
${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
|
|
671
|
+
toHash: ${utility.toHash},
|
|
675
672
|
transform,
|
|
676
673
|
}
|
|
677
674
|
})
|
|
@@ -3026,16 +3023,16 @@ function generateTokenTypes(ctx) {
|
|
|
3026
3023
|
config: { theme }
|
|
3027
3024
|
} = ctx;
|
|
3028
3025
|
const set = /* @__PURE__ */ new Set();
|
|
3029
|
-
set.add(`export type Token = ${tokens.isEmpty ? "string" : (0, import_shared3.unionType)(tokens.
|
|
3026
|
+
set.add(`export type Token = ${tokens.isEmpty ? "string" : (0, import_shared3.unionType)(Array.from(tokens.byName.keys()))}`);
|
|
3030
3027
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
3031
3028
|
if (tokens.isEmpty) {
|
|
3032
3029
|
result.add("[token: string]: string");
|
|
3033
3030
|
} else {
|
|
3034
|
-
const colorPaletteKeys =
|
|
3031
|
+
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
3035
3032
|
if (colorPaletteKeys.length) {
|
|
3036
|
-
set.add(`export type ColorPalette = ${(0, import_shared3.unionType)(
|
|
3033
|
+
set.add(`export type ColorPalette = ${(0, import_shared3.unionType)(colorPaletteKeys)}`);
|
|
3037
3034
|
}
|
|
3038
|
-
for (const [key, value] of tokens.categoryMap.entries()) {
|
|
3035
|
+
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
3039
3036
|
const typeName = (0, import_shared3.capitalize)(import_pluralize.default.singular(key));
|
|
3040
3037
|
set.add(`export type ${typeName}Token = ${(0, import_shared3.unionType)(value.keys())}`);
|
|
3041
3038
|
result.add(` ${key}: ${typeName}Token`);
|
|
@@ -3446,8 +3443,8 @@ var entries = [
|
|
|
3446
3443
|
var getMatchingArtifacts = (ctx, filters) => {
|
|
3447
3444
|
const ids = filters?.ids;
|
|
3448
3445
|
if (!ids)
|
|
3449
|
-
return entries.map(([_artifactId, fn]) => fn(ctx));
|
|
3450
|
-
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters));
|
|
3446
|
+
return entries.map(([_artifactId, fn]) => fn(ctx)).filter(Boolean);
|
|
3447
|
+
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters)).filter(Boolean);
|
|
3451
3448
|
};
|
|
3452
3449
|
var transformArtifact = (ctx, artifact) => {
|
|
3453
3450
|
const files = (artifact?.files ?? []).filter((item) => !!item?.code).map((item) => {
|
|
@@ -3469,7 +3466,7 @@ var setupArtifacts = (ctx, ids) => {
|
|
|
3469
3466
|
// src/artifacts/index.ts
|
|
3470
3467
|
var generateArtifacts = (ctx, ids) => {
|
|
3471
3468
|
if (ctx.config.emitTokensOnly) {
|
|
3472
|
-
return [setupDesignTokens(ctx)];
|
|
3469
|
+
return [setupDesignTokens(ctx)].filter(Boolean);
|
|
3473
3470
|
}
|
|
3474
3471
|
return setupArtifacts(ctx, ids);
|
|
3475
3472
|
};
|
|
@@ -3803,7 +3800,7 @@ function generateTokenCss(ctx, sheet) {
|
|
|
3803
3800
|
} = ctx;
|
|
3804
3801
|
const root = cssVarRoot;
|
|
3805
3802
|
const results = [];
|
|
3806
|
-
for (const [key, values] of tokens.vars.entries()) {
|
|
3803
|
+
for (const [key, values] of tokens.view.vars.entries()) {
|
|
3807
3804
|
const varsObj = Object.fromEntries(values);
|
|
3808
3805
|
if (Object.keys(varsObj).length === 0)
|
|
3809
3806
|
continue;
|
package/dist/index.mjs
CHANGED
|
@@ -183,6 +183,7 @@ function generateCssFn(ctx) {
|
|
|
183
183
|
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
184
184
|
}` : `(key, value) => ({ className: \`\${classNameByProp.get(key) || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
185
185
|
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
186
|
+
toHash: ${utility.toHash},
|
|
186
187
|
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -225,6 +226,7 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
225
226
|
prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
|
|
226
227
|
transform,
|
|
227
228
|
hasShorthand: false,
|
|
229
|
+
toHash: ${utility.toHash},
|
|
228
230
|
resolveShorthand(prop) {
|
|
229
231
|
return prop
|
|
230
232
|
},
|
|
@@ -382,7 +384,7 @@ var astish_mjs_default = {
|
|
|
382
384
|
|
|
383
385
|
// src/artifacts/generated/helpers.mjs.json
|
|
384
386
|
var helpers_mjs_default = {
|
|
385
|
-
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/
|
|
387
|
+
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/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/important.ts\nvar importantRegex = /\\s*!(important)?/i;\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/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/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 (Array.isArray(obj))\n return obj.map((value) => fn(value));\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 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(utility.toHash(baseArray, toHash));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return memo((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) => normalizeStyleObject(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: memo(mergeCss), assignCss };\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/is-css-function.ts\nvar fns = ["min", "max", "clamp", "calc"];\nvar fnRegExp = new RegExp(`^(${fns.join("|")})\\\\(.*\\\\)`);\nvar isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);\n\n// src/is-css-unit.ts\nvar lengthUnits = "cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%";\nvar lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;\nvar lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nvar isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);\n\n// src/is-css-var.ts\nvar isCssVar = (v) => typeof v === "string" && /^var\\(--.+\\)$/.test(v);\n\n// src/pattern-fns.ts\nvar patternFns = {\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit\n};\nvar getPatternStyles = (pattern, styles) => {\n if (!pattern.defaultValues)\n return styles;\n const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\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 getPatternStyles,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n patternFns,\n splitProps,\n toHash,\n uniq,\n walkObject,\n withoutSpace\n};\n'
|
|
386
388
|
};
|
|
387
389
|
|
|
388
390
|
// src/artifacts/generated/normalize-html.mjs.json
|
|
@@ -587,13 +589,7 @@ import { match as match4 } from "ts-pattern";
|
|
|
587
589
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
588
590
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
589
591
|
function generateCreateRecipe(ctx) {
|
|
590
|
-
const {
|
|
591
|
-
conditions,
|
|
592
|
-
recipes,
|
|
593
|
-
prefix,
|
|
594
|
-
hash,
|
|
595
|
-
utility: { separator }
|
|
596
|
-
} = ctx;
|
|
592
|
+
const { conditions, recipes, prefix, hash, utility } = ctx;
|
|
597
593
|
if (recipes.isEmpty())
|
|
598
594
|
return;
|
|
599
595
|
return {
|
|
@@ -624,7 +620,7 @@ function generateCreateRecipe(ctx) {
|
|
|
624
620
|
}
|
|
625
621
|
|
|
626
622
|
value = withoutSpace(value)
|
|
627
|
-
return { className: \`\${name}--\${prop}${separator}\${value}\` }
|
|
623
|
+
return { className: \`\${name}--\${prop}${utility.separator}\${value}\` }
|
|
628
624
|
}
|
|
629
625
|
|
|
630
626
|
const recipeCss = createCss({
|
|
@@ -636,6 +632,7 @@ function generateCreateRecipe(ctx) {
|
|
|
636
632
|
},
|
|
637
633
|
utility: {
|
|
638
634
|
${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
|
|
635
|
+
toHash: ${utility.toHash},
|
|
639
636
|
transform,
|
|
640
637
|
}
|
|
641
638
|
})
|
|
@@ -2990,16 +2987,16 @@ function generateTokenTypes(ctx) {
|
|
|
2990
2987
|
config: { theme }
|
|
2991
2988
|
} = ctx;
|
|
2992
2989
|
const set = /* @__PURE__ */ new Set();
|
|
2993
|
-
set.add(`export type Token = ${tokens.isEmpty ? "string" : unionType3(tokens.
|
|
2990
|
+
set.add(`export type Token = ${tokens.isEmpty ? "string" : unionType3(Array.from(tokens.byName.keys()))}`);
|
|
2994
2991
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
2995
2992
|
if (tokens.isEmpty) {
|
|
2996
2993
|
result.add("[token: string]: string");
|
|
2997
2994
|
} else {
|
|
2998
|
-
const colorPaletteKeys =
|
|
2995
|
+
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
2999
2996
|
if (colorPaletteKeys.length) {
|
|
3000
|
-
set.add(`export type ColorPalette = ${unionType3(
|
|
2997
|
+
set.add(`export type ColorPalette = ${unionType3(colorPaletteKeys)}`);
|
|
3001
2998
|
}
|
|
3002
|
-
for (const [key, value] of tokens.categoryMap.entries()) {
|
|
2999
|
+
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
3003
3000
|
const typeName = capitalize(pluralize.singular(key));
|
|
3004
3001
|
set.add(`export type ${typeName}Token = ${unionType3(value.keys())}`);
|
|
3005
3002
|
result.add(` ${key}: ${typeName}Token`);
|
|
@@ -3410,8 +3407,8 @@ var entries = [
|
|
|
3410
3407
|
var getMatchingArtifacts = (ctx, filters) => {
|
|
3411
3408
|
const ids = filters?.ids;
|
|
3412
3409
|
if (!ids)
|
|
3413
|
-
return entries.map(([_artifactId, fn]) => fn(ctx));
|
|
3414
|
-
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters));
|
|
3410
|
+
return entries.map(([_artifactId, fn]) => fn(ctx)).filter(Boolean);
|
|
3411
|
+
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters)).filter(Boolean);
|
|
3415
3412
|
};
|
|
3416
3413
|
var transformArtifact = (ctx, artifact) => {
|
|
3417
3414
|
const files = (artifact?.files ?? []).filter((item) => !!item?.code).map((item) => {
|
|
@@ -3433,7 +3430,7 @@ var setupArtifacts = (ctx, ids) => {
|
|
|
3433
3430
|
// src/artifacts/index.ts
|
|
3434
3431
|
var generateArtifacts = (ctx, ids) => {
|
|
3435
3432
|
if (ctx.config.emitTokensOnly) {
|
|
3436
|
-
return [setupDesignTokens(ctx)];
|
|
3433
|
+
return [setupDesignTokens(ctx)].filter(Boolean);
|
|
3437
3434
|
}
|
|
3438
3435
|
return setupArtifacts(ctx, ids);
|
|
3439
3436
|
};
|
|
@@ -3767,7 +3764,7 @@ function generateTokenCss(ctx, sheet) {
|
|
|
3767
3764
|
} = ctx;
|
|
3768
3765
|
const root = cssVarRoot;
|
|
3769
3766
|
const results = [];
|
|
3770
|
-
for (const [key, values] of tokens.vars.entries()) {
|
|
3767
|
+
for (const [key, values] of tokens.view.vars.entries()) {
|
|
3771
3768
|
const varsObj = Object.fromEntries(values);
|
|
3772
3769
|
if (Object.keys(varsObj).length === 0)
|
|
3773
3770
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20240201214314",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"pluralize": "8.0.0",
|
|
38
38
|
"postcss": "^8.4.31",
|
|
39
39
|
"ts-pattern": "5.0.5",
|
|
40
|
-
"@pandacss/core": "0.0.0-dev-
|
|
41
|
-
"@pandacss/is-valid-prop": "^0.0.0-dev-
|
|
42
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
43
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
44
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
45
|
-
"@pandacss/types": "0.0.0-dev-
|
|
40
|
+
"@pandacss/core": "0.0.0-dev-20240201214314",
|
|
41
|
+
"@pandacss/is-valid-prop": "^0.0.0-dev-20240201214314",
|
|
42
|
+
"@pandacss/logger": "0.0.0-dev-20240201214314",
|
|
43
|
+
"@pandacss/shared": "0.0.0-dev-20240201214314",
|
|
44
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20240201214314",
|
|
45
|
+
"@pandacss/types": "0.0.0-dev-20240201214314"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/pluralize": "0.0.33"
|