@pandacss/generator 0.27.3 → 0.29.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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +45 -26
- package/dist/index.mjs +46 -27
- package/package.json +8 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
2
|
-
import {
|
|
2
|
+
import { LoadConfigResult, ArtifactId, CssArtifactType } from '@pandacss/types';
|
|
3
3
|
import { Context, Stylesheet, StyleDecoder } from '@pandacss/core';
|
|
4
4
|
|
|
5
5
|
declare class Generator extends Context {
|
|
6
|
-
constructor(conf:
|
|
6
|
+
constructor(conf: LoadConfigResult);
|
|
7
7
|
getArtifacts: (ids?: ArtifactId[] | undefined) => _pandacss_types.Artifact[];
|
|
8
8
|
appendCssOfType: (type: CssArtifactType, sheet: Stylesheet) => void;
|
|
9
9
|
appendLayerParams: (sheet: Stylesheet) => void;
|
|
10
10
|
appendBaselineCss: (sheet: Stylesheet) => void;
|
|
11
11
|
appendParserCss: (sheet: Stylesheet) => void;
|
|
12
|
-
getParserCss: (decoder: StyleDecoder
|
|
12
|
+
getParserCss: (decoder: StyleDecoder) => string;
|
|
13
13
|
getCss: (stylesheet?: Stylesheet) => string;
|
|
14
14
|
}
|
|
15
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
2
|
-
import {
|
|
2
|
+
import { LoadConfigResult, ArtifactId, CssArtifactType } from '@pandacss/types';
|
|
3
3
|
import { Context, Stylesheet, StyleDecoder } from '@pandacss/core';
|
|
4
4
|
|
|
5
5
|
declare class Generator extends Context {
|
|
6
|
-
constructor(conf:
|
|
6
|
+
constructor(conf: LoadConfigResult);
|
|
7
7
|
getArtifacts: (ids?: ArtifactId[] | undefined) => _pandacss_types.Artifact[];
|
|
8
8
|
appendCssOfType: (type: CssArtifactType, sheet: Stylesheet) => void;
|
|
9
9
|
appendLayerParams: (sheet: Stylesheet) => void;
|
|
10
10
|
appendBaselineCss: (sheet: Stylesheet) => void;
|
|
11
11
|
appendParserCss: (sheet: Stylesheet) => void;
|
|
12
|
-
getParserCss: (decoder: StyleDecoder
|
|
12
|
+
getParserCss: (decoder: StyleDecoder) => string;
|
|
13
13
|
getCss: (stylesheet?: Stylesheet) => string;
|
|
14
14
|
}
|
|
15
15
|
|
package/dist/index.js
CHANGED
|
@@ -418,7 +418,7 @@ var astish_mjs_default = {
|
|
|
418
418
|
|
|
419
419
|
// src/artifacts/generated/helpers.mjs.json
|
|
420
420
|
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/
|
|
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/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/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/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/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 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 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) => 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: 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
422
|
};
|
|
423
423
|
|
|
424
424
|
// src/artifacts/generated/normalize-html.mjs.json
|
|
@@ -474,7 +474,7 @@ function generateIsValidProp(ctx) {
|
|
|
474
474
|
content = ctx.file.import("memo", "../helpers") + "\n" + content;
|
|
475
475
|
}
|
|
476
476
|
content = ctx.file.import("splitProps", "../helpers") + "\n" + content;
|
|
477
|
-
content += `export const splitCssProps =
|
|
477
|
+
content += `export const splitCssProps = (props) => splitProps(props, isCssProperty)`;
|
|
478
478
|
return {
|
|
479
479
|
js: content,
|
|
480
480
|
dts: import_outdent8.outdent`
|
|
@@ -545,13 +545,13 @@ function generatePattern(ctx, filters) {
|
|
|
545
545
|
const details = ctx.patterns.filterDetails(filters);
|
|
546
546
|
return details.map((pattern) => {
|
|
547
547
|
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
548
|
-
const { properties, transform, strict, description } = config;
|
|
549
|
-
const
|
|
550
|
-
const helperImports = ["
|
|
551
|
-
if (
|
|
548
|
+
const { properties, transform, strict, description, defaultValues } = config;
|
|
549
|
+
const patternConfigFn = (0, import_javascript_stringify.stringify)((0, import_shared.compact)({ transform, defaultValues })) ?? "";
|
|
550
|
+
const helperImports = ["getPatternStyles, patternFns"];
|
|
551
|
+
if (patternConfigFn.includes("__spreadValues")) {
|
|
552
552
|
helperImports.push("__spreadValues");
|
|
553
553
|
}
|
|
554
|
-
if (
|
|
554
|
+
if (patternConfigFn.includes("__objRest")) {
|
|
555
555
|
helperImports.push("__objRest");
|
|
556
556
|
}
|
|
557
557
|
return {
|
|
@@ -599,10 +599,14 @@ function generatePattern(ctx, filters) {
|
|
|
599
599
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
600
600
|
${ctx.file.import("css", "../css/index")}
|
|
601
601
|
|
|
602
|
-
const ${baseName}Config = ${
|
|
603
|
-
transform`)
|
|
602
|
+
const ${baseName}Config = ${patternConfigFn.replace(`{transform`, `{
|
|
603
|
+
transform`).replace(`,defaultValues`, `,
|
|
604
|
+
defaultValues`)}
|
|
604
605
|
|
|
605
|
-
export const ${styleFnName} = (styles = {}) =>
|
|
606
|
+
export const ${styleFnName} = (styles = {}) => {
|
|
607
|
+
const _styles = getPatternStyles(${baseName}Config, styles)
|
|
608
|
+
return ${baseName}Config.transform(_styles, patternFns)
|
|
609
|
+
}
|
|
606
610
|
|
|
607
611
|
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
608
612
|
${baseName}.raw = ${styleFnName}
|
|
@@ -2728,7 +2732,7 @@ var parts_d_ts_default = {
|
|
|
2728
2732
|
|
|
2729
2733
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2730
2734
|
var pattern_d_ts_default = {
|
|
2731
|
-
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype
|
|
2735
|
+
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
2732
2736
|
};
|
|
2733
2737
|
|
|
2734
2738
|
// src/artifacts/generated/recipe.d.ts.json
|
|
@@ -3007,6 +3011,7 @@ var categories = [
|
|
|
3007
3011
|
"spacing",
|
|
3008
3012
|
"radii",
|
|
3009
3013
|
"borders",
|
|
3014
|
+
"borderWidths",
|
|
3010
3015
|
"durations",
|
|
3011
3016
|
"easings",
|
|
3012
3017
|
"animations",
|
|
@@ -3445,7 +3450,7 @@ var getMatchingArtifacts = (ctx, filters) => {
|
|
|
3445
3450
|
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters));
|
|
3446
3451
|
};
|
|
3447
3452
|
var transformArtifact = (ctx, artifact) => {
|
|
3448
|
-
const files = (artifact?.files ?? []).filter(
|
|
3453
|
+
const files = (artifact?.files ?? []).filter((item) => !!item?.code).map((item) => {
|
|
3449
3454
|
if (ctx.file.isTypeFile(item.file)) {
|
|
3450
3455
|
return { ...item, code: `/* eslint-disable */
|
|
3451
3456
|
${item.code}` };
|
|
@@ -3508,7 +3513,6 @@ var generateGlobalCss = (ctx, sheet) => {
|
|
|
3508
3513
|
}
|
|
3509
3514
|
});
|
|
3510
3515
|
sheet.processGlobalCss(globalCss);
|
|
3511
|
-
void ctx.hooks.callHook("generator:css", "global.css", "");
|
|
3512
3516
|
};
|
|
3513
3517
|
|
|
3514
3518
|
// src/artifacts/css/keyframe-css.ts
|
|
@@ -3519,14 +3523,16 @@ function generateKeyframeCss(ctx, sheet) {
|
|
|
3519
3523
|
for (const [name, definition] of Object.entries(keyframes)) {
|
|
3520
3524
|
result[`@keyframes ${name}`] = definition;
|
|
3521
3525
|
}
|
|
3522
|
-
|
|
3526
|
+
let css2 = (0, import_core2.stringify)(sheet.serialize(result));
|
|
3527
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3528
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "keyframes", content: css2 }) ?? css2;
|
|
3529
|
+
}
|
|
3523
3530
|
sheet.layers.tokens.append(css2);
|
|
3524
|
-
void ctx.hooks.callHook("generator:css", "keyframes.css", "");
|
|
3525
3531
|
}
|
|
3526
3532
|
|
|
3527
3533
|
// src/artifacts/css/parser-css.ts
|
|
3528
3534
|
var import_logger = require("@pandacss/logger");
|
|
3529
|
-
var generateParserCss = (ctx, decoder
|
|
3535
|
+
var generateParserCss = (ctx, decoder) => {
|
|
3530
3536
|
if (!decoder)
|
|
3531
3537
|
return "";
|
|
3532
3538
|
const sheet = ctx.createSheet();
|
|
@@ -3534,7 +3540,6 @@ var generateParserCss = (ctx, decoder, filePath) => {
|
|
|
3534
3540
|
sheet.processDecoder(decoder);
|
|
3535
3541
|
try {
|
|
3536
3542
|
const css2 = sheet.toCss({ minify, optimize });
|
|
3537
|
-
ctx.hooks.callHook("parser:css", filePath ?? "", css2);
|
|
3538
3543
|
return css2;
|
|
3539
3544
|
} catch (err) {
|
|
3540
3545
|
import_logger.logger.error("serializer:css", "Failed to serialize CSS: " + err);
|
|
@@ -3549,7 +3554,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
3549
3554
|
const { preflight } = ctx.config;
|
|
3550
3555
|
const scope = (0, import_shared4.isObject)(preflight) ? preflight.scope : void 0;
|
|
3551
3556
|
const selector = scope ? `${scope} ` : "";
|
|
3552
|
-
|
|
3557
|
+
let output = css`
|
|
3553
3558
|
${selector}* {
|
|
3554
3559
|
margin: 0;
|
|
3555
3560
|
padding: 0;
|
|
@@ -3762,9 +3767,15 @@ function generateResetCss(ctx, sheet) {
|
|
|
3762
3767
|
${selector}:-moz-focusring {
|
|
3763
3768
|
outline: auto;
|
|
3764
3769
|
}
|
|
3770
|
+
|
|
3771
|
+
${selector}[hidden] {
|
|
3772
|
+
display: none !important;
|
|
3773
|
+
}
|
|
3765
3774
|
`;
|
|
3775
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3776
|
+
output = ctx.hooks["cssgen:done"]({ artifact: "reset", content: output }) ?? output;
|
|
3777
|
+
}
|
|
3766
3778
|
sheet.layers.reset.append(output);
|
|
3767
|
-
void ctx.hooks.callHook("generator:css", "reset.css", "");
|
|
3768
3779
|
}
|
|
3769
3780
|
|
|
3770
3781
|
// src/artifacts/css/static-css.ts
|
|
@@ -3773,9 +3784,11 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
3773
3784
|
const engine = staticCss.process(ctx.config.staticCss ?? {}, sheet);
|
|
3774
3785
|
if (!sheet) {
|
|
3775
3786
|
const { optimize = true, minify } = config;
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3787
|
+
let css2 = engine.sheet.toCss({ optimize, minify });
|
|
3788
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3789
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "static", content: css2 }) ?? css2;
|
|
3790
|
+
}
|
|
3791
|
+
return css2;
|
|
3779
3792
|
}
|
|
3780
3793
|
};
|
|
3781
3794
|
|
|
@@ -3813,8 +3826,10 @@ function generateTokenCss(ctx, sheet) {
|
|
|
3813
3826
|
}
|
|
3814
3827
|
let css2 = results.join("\n\n");
|
|
3815
3828
|
css2 = "\n\n" + cleanupSelectors(css2, root);
|
|
3829
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3830
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "tokens", content: css2 }) ?? css2;
|
|
3831
|
+
}
|
|
3816
3832
|
sheet.layers.tokens.append(css2);
|
|
3817
|
-
void ctx.hooks.callHook("generator:css", "tokens.css", "");
|
|
3818
3833
|
}
|
|
3819
3834
|
function getDeepestRule(root, selectors) {
|
|
3820
3835
|
const rule = import_postcss.default.rule({ selector: "" });
|
|
@@ -3892,15 +3907,19 @@ var Generator = class extends import_core4.Context {
|
|
|
3892
3907
|
const decoder = this.decoder.collect(this.encoder);
|
|
3893
3908
|
sheet.processDecoder(decoder);
|
|
3894
3909
|
};
|
|
3895
|
-
getParserCss = (decoder
|
|
3896
|
-
return generateParserCss(this, decoder
|
|
3910
|
+
getParserCss = (decoder) => {
|
|
3911
|
+
return generateParserCss(this, decoder);
|
|
3897
3912
|
};
|
|
3898
3913
|
getCss = (stylesheet) => {
|
|
3899
3914
|
const sheet = stylesheet ?? this.createSheet();
|
|
3900
|
-
|
|
3915
|
+
let css2 = sheet.toCss({
|
|
3901
3916
|
optimize: true,
|
|
3902
3917
|
minify: this.config.minify
|
|
3903
3918
|
});
|
|
3919
|
+
if (this.hooks["cssgen:done"]) {
|
|
3920
|
+
css2 = this.hooks["cssgen:done"]({ artifact: "styles.css", content: css2 }) ?? css2;
|
|
3921
|
+
}
|
|
3922
|
+
return css2;
|
|
3904
3923
|
};
|
|
3905
3924
|
};
|
|
3906
3925
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -382,7 +382,7 @@ var astish_mjs_default = {
|
|
|
382
382
|
|
|
383
383
|
// src/artifacts/generated/helpers.mjs.json
|
|
384
384
|
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/
|
|
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/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/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/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/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 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 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) => 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: 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
386
|
};
|
|
387
387
|
|
|
388
388
|
// src/artifacts/generated/normalize-html.mjs.json
|
|
@@ -438,7 +438,7 @@ function generateIsValidProp(ctx) {
|
|
|
438
438
|
content = ctx.file.import("memo", "../helpers") + "\n" + content;
|
|
439
439
|
}
|
|
440
440
|
content = ctx.file.import("splitProps", "../helpers") + "\n" + content;
|
|
441
|
-
content += `export const splitCssProps =
|
|
441
|
+
content += `export const splitCssProps = (props) => splitProps(props, isCssProperty)`;
|
|
442
442
|
return {
|
|
443
443
|
js: content,
|
|
444
444
|
dts: outdent8`
|
|
@@ -499,7 +499,7 @@ function generatedJsxHelpers(ctx) {
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
// src/artifacts/js/pattern.ts
|
|
502
|
-
import { unionType } from "@pandacss/shared";
|
|
502
|
+
import { compact, unionType } from "@pandacss/shared";
|
|
503
503
|
import { stringify } from "javascript-stringify";
|
|
504
504
|
import { outdent as outdent10 } from "outdent";
|
|
505
505
|
import { match as match3 } from "ts-pattern";
|
|
@@ -509,13 +509,13 @@ function generatePattern(ctx, filters) {
|
|
|
509
509
|
const details = ctx.patterns.filterDetails(filters);
|
|
510
510
|
return details.map((pattern) => {
|
|
511
511
|
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
512
|
-
const { properties, transform, strict, description } = config;
|
|
513
|
-
const
|
|
514
|
-
const helperImports = ["
|
|
515
|
-
if (
|
|
512
|
+
const { properties, transform, strict, description, defaultValues } = config;
|
|
513
|
+
const patternConfigFn = stringify(compact({ transform, defaultValues })) ?? "";
|
|
514
|
+
const helperImports = ["getPatternStyles, patternFns"];
|
|
515
|
+
if (patternConfigFn.includes("__spreadValues")) {
|
|
516
516
|
helperImports.push("__spreadValues");
|
|
517
517
|
}
|
|
518
|
-
if (
|
|
518
|
+
if (patternConfigFn.includes("__objRest")) {
|
|
519
519
|
helperImports.push("__objRest");
|
|
520
520
|
}
|
|
521
521
|
return {
|
|
@@ -563,10 +563,14 @@ function generatePattern(ctx, filters) {
|
|
|
563
563
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
564
564
|
${ctx.file.import("css", "../css/index")}
|
|
565
565
|
|
|
566
|
-
const ${baseName}Config = ${
|
|
567
|
-
transform`)
|
|
566
|
+
const ${baseName}Config = ${patternConfigFn.replace(`{transform`, `{
|
|
567
|
+
transform`).replace(`,defaultValues`, `,
|
|
568
|
+
defaultValues`)}
|
|
568
569
|
|
|
569
|
-
export const ${styleFnName} = (styles = {}) =>
|
|
570
|
+
export const ${styleFnName} = (styles = {}) => {
|
|
571
|
+
const _styles = getPatternStyles(${baseName}Config, styles)
|
|
572
|
+
return ${baseName}Config.transform(_styles, patternFns)
|
|
573
|
+
}
|
|
570
574
|
|
|
571
575
|
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
572
576
|
${baseName}.raw = ${styleFnName}
|
|
@@ -2692,7 +2696,7 @@ var parts_d_ts_default = {
|
|
|
2692
2696
|
|
|
2693
2697
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2694
2698
|
var pattern_d_ts_default = {
|
|
2695
|
-
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype
|
|
2699
|
+
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
2696
2700
|
};
|
|
2697
2701
|
|
|
2698
2702
|
// src/artifacts/generated/recipe.d.ts.json
|
|
@@ -2971,6 +2975,7 @@ var categories = [
|
|
|
2971
2975
|
"spacing",
|
|
2972
2976
|
"radii",
|
|
2973
2977
|
"borders",
|
|
2978
|
+
"borderWidths",
|
|
2974
2979
|
"durations",
|
|
2975
2980
|
"easings",
|
|
2976
2981
|
"animations",
|
|
@@ -3409,7 +3414,7 @@ var getMatchingArtifacts = (ctx, filters) => {
|
|
|
3409
3414
|
return entries.filter(([artifactId]) => ids.includes(artifactId)).map(([_artifactId, fn]) => fn(ctx, filters));
|
|
3410
3415
|
};
|
|
3411
3416
|
var transformArtifact = (ctx, artifact) => {
|
|
3412
|
-
const files = (artifact?.files ?? []).filter(
|
|
3417
|
+
const files = (artifact?.files ?? []).filter((item) => !!item?.code).map((item) => {
|
|
3413
3418
|
if (ctx.file.isTypeFile(item.file)) {
|
|
3414
3419
|
return { ...item, code: `/* eslint-disable */
|
|
3415
3420
|
${item.code}` };
|
|
@@ -3472,7 +3477,6 @@ var generateGlobalCss = (ctx, sheet) => {
|
|
|
3472
3477
|
}
|
|
3473
3478
|
});
|
|
3474
3479
|
sheet.processGlobalCss(globalCss);
|
|
3475
|
-
void ctx.hooks.callHook("generator:css", "global.css", "");
|
|
3476
3480
|
};
|
|
3477
3481
|
|
|
3478
3482
|
// src/artifacts/css/keyframe-css.ts
|
|
@@ -3483,14 +3487,16 @@ function generateKeyframeCss(ctx, sheet) {
|
|
|
3483
3487
|
for (const [name, definition] of Object.entries(keyframes)) {
|
|
3484
3488
|
result[`@keyframes ${name}`] = definition;
|
|
3485
3489
|
}
|
|
3486
|
-
|
|
3490
|
+
let css2 = stringify3(sheet.serialize(result));
|
|
3491
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3492
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "keyframes", content: css2 }) ?? css2;
|
|
3493
|
+
}
|
|
3487
3494
|
sheet.layers.tokens.append(css2);
|
|
3488
|
-
void ctx.hooks.callHook("generator:css", "keyframes.css", "");
|
|
3489
3495
|
}
|
|
3490
3496
|
|
|
3491
3497
|
// src/artifacts/css/parser-css.ts
|
|
3492
3498
|
import { logger } from "@pandacss/logger";
|
|
3493
|
-
var generateParserCss = (ctx, decoder
|
|
3499
|
+
var generateParserCss = (ctx, decoder) => {
|
|
3494
3500
|
if (!decoder)
|
|
3495
3501
|
return "";
|
|
3496
3502
|
const sheet = ctx.createSheet();
|
|
@@ -3498,7 +3504,6 @@ var generateParserCss = (ctx, decoder, filePath) => {
|
|
|
3498
3504
|
sheet.processDecoder(decoder);
|
|
3499
3505
|
try {
|
|
3500
3506
|
const css2 = sheet.toCss({ minify, optimize });
|
|
3501
|
-
ctx.hooks.callHook("parser:css", filePath ?? "", css2);
|
|
3502
3507
|
return css2;
|
|
3503
3508
|
} catch (err) {
|
|
3504
3509
|
logger.error("serializer:css", "Failed to serialize CSS: " + err);
|
|
@@ -3513,7 +3518,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
3513
3518
|
const { preflight } = ctx.config;
|
|
3514
3519
|
const scope = isObject(preflight) ? preflight.scope : void 0;
|
|
3515
3520
|
const selector = scope ? `${scope} ` : "";
|
|
3516
|
-
|
|
3521
|
+
let output = css`
|
|
3517
3522
|
${selector}* {
|
|
3518
3523
|
margin: 0;
|
|
3519
3524
|
padding: 0;
|
|
@@ -3726,9 +3731,15 @@ function generateResetCss(ctx, sheet) {
|
|
|
3726
3731
|
${selector}:-moz-focusring {
|
|
3727
3732
|
outline: auto;
|
|
3728
3733
|
}
|
|
3734
|
+
|
|
3735
|
+
${selector}[hidden] {
|
|
3736
|
+
display: none !important;
|
|
3737
|
+
}
|
|
3729
3738
|
`;
|
|
3739
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3740
|
+
output = ctx.hooks["cssgen:done"]({ artifact: "reset", content: output }) ?? output;
|
|
3741
|
+
}
|
|
3730
3742
|
sheet.layers.reset.append(output);
|
|
3731
|
-
void ctx.hooks.callHook("generator:css", "reset.css", "");
|
|
3732
3743
|
}
|
|
3733
3744
|
|
|
3734
3745
|
// src/artifacts/css/static-css.ts
|
|
@@ -3737,9 +3748,11 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
3737
3748
|
const engine = staticCss.process(ctx.config.staticCss ?? {}, sheet);
|
|
3738
3749
|
if (!sheet) {
|
|
3739
3750
|
const { optimize = true, minify } = config;
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3751
|
+
let css2 = engine.sheet.toCss({ optimize, minify });
|
|
3752
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3753
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "static", content: css2 }) ?? css2;
|
|
3754
|
+
}
|
|
3755
|
+
return css2;
|
|
3743
3756
|
}
|
|
3744
3757
|
};
|
|
3745
3758
|
|
|
@@ -3777,8 +3790,10 @@ function generateTokenCss(ctx, sheet) {
|
|
|
3777
3790
|
}
|
|
3778
3791
|
let css2 = results.join("\n\n");
|
|
3779
3792
|
css2 = "\n\n" + cleanupSelectors(css2, root);
|
|
3793
|
+
if (ctx.hooks["cssgen:done"]) {
|
|
3794
|
+
css2 = ctx.hooks["cssgen:done"]({ artifact: "tokens", content: css2 }) ?? css2;
|
|
3795
|
+
}
|
|
3780
3796
|
sheet.layers.tokens.append(css2);
|
|
3781
|
-
void ctx.hooks.callHook("generator:css", "tokens.css", "");
|
|
3782
3797
|
}
|
|
3783
3798
|
function getDeepestRule(root, selectors) {
|
|
3784
3799
|
const rule = postcss.rule({ selector: "" });
|
|
@@ -3856,15 +3871,19 @@ var Generator = class extends Context2 {
|
|
|
3856
3871
|
const decoder = this.decoder.collect(this.encoder);
|
|
3857
3872
|
sheet.processDecoder(decoder);
|
|
3858
3873
|
};
|
|
3859
|
-
getParserCss = (decoder
|
|
3860
|
-
return generateParserCss(this, decoder
|
|
3874
|
+
getParserCss = (decoder) => {
|
|
3875
|
+
return generateParserCss(this, decoder);
|
|
3861
3876
|
};
|
|
3862
3877
|
getCss = (stylesheet) => {
|
|
3863
3878
|
const sheet = stylesheet ?? this.createSheet();
|
|
3864
|
-
|
|
3879
|
+
let css2 = sheet.toCss({
|
|
3865
3880
|
optimize: true,
|
|
3866
3881
|
minify: this.config.minify
|
|
3867
3882
|
});
|
|
3883
|
+
if (this.hooks["cssgen:done"]) {
|
|
3884
|
+
css2 = this.hooks["cssgen:done"]({ artifact: "styles.css", content: css2 }) ?? css2;
|
|
3885
|
+
}
|
|
3886
|
+
return css2;
|
|
3868
3887
|
};
|
|
3869
3888
|
};
|
|
3870
3889
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,16 +37,15 @@
|
|
|
37
37
|
"pluralize": "8.0.0",
|
|
38
38
|
"postcss": "^8.4.31",
|
|
39
39
|
"ts-pattern": "5.0.5",
|
|
40
|
-
"@pandacss/core": "0.
|
|
41
|
-
"@pandacss/is-valid-prop": "^0.
|
|
42
|
-
"@pandacss/logger": "0.
|
|
43
|
-
"@pandacss/shared": "0.
|
|
44
|
-
"@pandacss/token-dictionary": "0.
|
|
45
|
-
"@pandacss/types": "0.
|
|
40
|
+
"@pandacss/core": "0.29.0",
|
|
41
|
+
"@pandacss/is-valid-prop": "^0.29.0",
|
|
42
|
+
"@pandacss/logger": "0.29.0",
|
|
43
|
+
"@pandacss/shared": "0.29.0",
|
|
44
|
+
"@pandacss/token-dictionary": "0.29.0",
|
|
45
|
+
"@pandacss/types": "0.29.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/pluralize": "0.0.33"
|
|
49
|
-
"hookable": "5.5.3"
|
|
48
|
+
"@types/pluralize": "0.0.33"
|
|
50
49
|
},
|
|
51
50
|
"scripts": {
|
|
52
51
|
"build": "tsup src/index.ts --format=esm,cjs --dts",
|