@pandacss/generator 0.22.0 → 0.23.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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +189 -70
- package/dist/index.mjs +189 -70
- package/package.json +8 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
2
2
|
import { UserConfig, PatternConfig, Dict, ArtifactFilters, ConfigResultWithHooks, RequiredBy, StudioOptions, HashOptions, PrefixOptions, Theme, CascadeLayers, TSConfig, ArtifactId, ParserResultType } from '@pandacss/types';
|
|
3
3
|
import { Utility, Recipes, Conditions, Layers, Stylesheet, RecipeContext, RecipeNode } from '@pandacss/core';
|
|
4
|
+
import { mapObject } from '@pandacss/shared';
|
|
4
5
|
import { TokenDictionary } from '@pandacss/token-dictionary';
|
|
5
6
|
|
|
6
7
|
declare class FileEngine {
|
|
@@ -108,7 +109,15 @@ declare class Context {
|
|
|
108
109
|
createLayers(layers: CascadeLayers): Layers;
|
|
109
110
|
setupCompositions(theme: Theme): void;
|
|
110
111
|
setupProperties(): void;
|
|
111
|
-
|
|
112
|
+
get baseSheetContext(): {
|
|
113
|
+
conditions: Conditions;
|
|
114
|
+
layers: Layers;
|
|
115
|
+
utility: Utility;
|
|
116
|
+
helpers: {
|
|
117
|
+
map: typeof mapObject;
|
|
118
|
+
};
|
|
119
|
+
hash: boolean | undefined;
|
|
120
|
+
};
|
|
112
121
|
createSheet(): Stylesheet;
|
|
113
122
|
createRecipes(theme: Theme, context: RecipeContext): Recipes;
|
|
114
123
|
}
|
|
@@ -175,6 +184,7 @@ interface ParserJsxOptions {
|
|
|
175
184
|
interface ParserOptions {
|
|
176
185
|
importMap: ParserImportMap;
|
|
177
186
|
jsx: ParserJsxOptions;
|
|
187
|
+
isTemplateLiteralSyntax: boolean;
|
|
178
188
|
patternKeys: Context['patterns']['keys'];
|
|
179
189
|
recipeKeys: Context['recipes']['keys'];
|
|
180
190
|
getRecipesByJsxName: Context['recipes']['filter'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _pandacss_types from '@pandacss/types';
|
|
2
2
|
import { UserConfig, PatternConfig, Dict, ArtifactFilters, ConfigResultWithHooks, RequiredBy, StudioOptions, HashOptions, PrefixOptions, Theme, CascadeLayers, TSConfig, ArtifactId, ParserResultType } from '@pandacss/types';
|
|
3
3
|
import { Utility, Recipes, Conditions, Layers, Stylesheet, RecipeContext, RecipeNode } from '@pandacss/core';
|
|
4
|
+
import { mapObject } from '@pandacss/shared';
|
|
4
5
|
import { TokenDictionary } from '@pandacss/token-dictionary';
|
|
5
6
|
|
|
6
7
|
declare class FileEngine {
|
|
@@ -108,7 +109,15 @@ declare class Context {
|
|
|
108
109
|
createLayers(layers: CascadeLayers): Layers;
|
|
109
110
|
setupCompositions(theme: Theme): void;
|
|
110
111
|
setupProperties(): void;
|
|
111
|
-
|
|
112
|
+
get baseSheetContext(): {
|
|
113
|
+
conditions: Conditions;
|
|
114
|
+
layers: Layers;
|
|
115
|
+
utility: Utility;
|
|
116
|
+
helpers: {
|
|
117
|
+
map: typeof mapObject;
|
|
118
|
+
};
|
|
119
|
+
hash: boolean | undefined;
|
|
120
|
+
};
|
|
112
121
|
createSheet(): Stylesheet;
|
|
113
122
|
createRecipes(theme: Theme, context: RecipeContext): Recipes;
|
|
114
123
|
}
|
|
@@ -175,6 +184,7 @@ interface ParserJsxOptions {
|
|
|
175
184
|
interface ParserOptions {
|
|
176
185
|
importMap: ParserImportMap;
|
|
177
186
|
jsx: ParserJsxOptions;
|
|
187
|
+
isTemplateLiteralSyntax: boolean;
|
|
178
188
|
patternKeys: Context['patterns']['keys'];
|
|
179
189
|
recipeKeys: Context['recipes']['keys'];
|
|
180
190
|
getRecipesByJsxName: Context['recipes']['filter'];
|
package/dist/index.js
CHANGED
|
@@ -132,7 +132,7 @@ var getMessages = (ctx) => ({
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
// src/generator.ts
|
|
135
|
-
var
|
|
135
|
+
var import_ts_pattern12 = require("ts-pattern");
|
|
136
136
|
|
|
137
137
|
// src/artifacts/setup-artifacts.ts
|
|
138
138
|
var import_outdent44 = __toESM(require("outdent"));
|
|
@@ -509,7 +509,7 @@ var import_outdent8 = require("outdent");
|
|
|
509
509
|
|
|
510
510
|
// src/artifacts/generated/helpers.mjs.json
|
|
511
511
|
var helpers_mjs_default = {
|
|
512
|
-
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)
|
|
512
|
+
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 (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 (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'
|
|
513
513
|
};
|
|
514
514
|
|
|
515
515
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -1092,7 +1092,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1092
1092
|
var import_outdent16 = require("outdent");
|
|
1093
1093
|
var import_ts_pattern5 = require("ts-pattern");
|
|
1094
1094
|
function generatePreactJsxPattern(ctx, filters) {
|
|
1095
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1095
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1096
1096
|
const details = ctx.patterns.filterDetails(filters);
|
|
1097
1097
|
return details.map((pattern) => {
|
|
1098
1098
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1102,23 +1102,44 @@ function generatePreactJsxPattern(ctx, filters) {
|
|
|
1102
1102
|
js: import_outdent16.outdent`
|
|
1103
1103
|
import { h } from 'preact'
|
|
1104
1104
|
import { forwardRef } from 'preact/compat'
|
|
1105
|
-
${ctx.file.import(
|
|
1105
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1106
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1106
1107
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1108
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1107
1109
|
|
|
1108
1110
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1109
|
-
${(0, import_ts_pattern5.match)(
|
|
1110
|
-
|
|
1111
|
+
${(0, import_ts_pattern5.match)(jsxStyleProps2).with(
|
|
1112
|
+
"none",
|
|
1111
1113
|
() => import_outdent16.outdent`
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1115
|
+
|
|
1116
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1117
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1118
|
+
|
|
1119
|
+
return h(Comp, { ref, ...restProps })
|
|
1114
1120
|
`
|
|
1115
|
-
).
|
|
1121
|
+
).with(
|
|
1122
|
+
"minimal",
|
|
1116
1123
|
() => import_outdent16.outdent`
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
|
|
1124
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1125
|
+
|
|
1126
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1127
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1128
|
+
const mergedProps = { ref, ...restProps, ...cssProps }
|
|
1129
|
+
|
|
1130
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1120
1131
|
`
|
|
1121
|
-
)
|
|
1132
|
+
).with(
|
|
1133
|
+
"all",
|
|
1134
|
+
() => import_outdent16.outdent`
|
|
1135
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1136
|
+
|
|
1137
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1138
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
1139
|
+
|
|
1140
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1141
|
+
`
|
|
1142
|
+
).exhaustive()}
|
|
1122
1143
|
})
|
|
1123
1144
|
`,
|
|
1124
1145
|
dts: import_outdent16.outdent`
|
|
@@ -1397,7 +1418,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1397
1418
|
var import_outdent21 = require("outdent");
|
|
1398
1419
|
var import_ts_pattern6 = require("ts-pattern");
|
|
1399
1420
|
function generateQwikJsxPattern(ctx, filters) {
|
|
1400
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1421
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1401
1422
|
const details = ctx.patterns.filterDetails(filters);
|
|
1402
1423
|
return details.map((pattern) => {
|
|
1403
1424
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1406,23 +1427,44 @@ function generateQwikJsxPattern(ctx, filters) {
|
|
|
1406
1427
|
name: dashName,
|
|
1407
1428
|
js: import_outdent21.outdent`
|
|
1408
1429
|
import { h } from '@builder.io/qwik'
|
|
1409
|
-
${ctx.file.import(
|
|
1430
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1431
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1410
1432
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1433
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1411
1434
|
|
|
1412
|
-
export const ${jsxName} = function ${jsxName}(props) {
|
|
1413
|
-
${(0, import_ts_pattern6.match)(
|
|
1414
|
-
|
|
1435
|
+
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
1436
|
+
${(0, import_ts_pattern6.match)(jsxStyleProps2).with(
|
|
1437
|
+
"none",
|
|
1438
|
+
() => import_outdent21.outdent`
|
|
1439
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1440
|
+
|
|
1441
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1442
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1443
|
+
|
|
1444
|
+
return h(Comp, restProps)
|
|
1445
|
+
`
|
|
1446
|
+
).with(
|
|
1447
|
+
"minimal",
|
|
1415
1448
|
() => import_outdent21.outdent`
|
|
1416
|
-
|
|
1417
|
-
|
|
1449
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1450
|
+
|
|
1451
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1452
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1453
|
+
const mergedProps = { ...restProps, ...cssProps }
|
|
1454
|
+
|
|
1455
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1418
1456
|
`
|
|
1419
|
-
).
|
|
1457
|
+
).with(
|
|
1458
|
+
"all",
|
|
1420
1459
|
() => import_outdent21.outdent`
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1460
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1461
|
+
|
|
1462
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1463
|
+
const mergedProps = { ...styleProps, ...restProps }
|
|
1464
|
+
|
|
1465
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1424
1466
|
`
|
|
1425
|
-
)}
|
|
1467
|
+
).exhaustive()}
|
|
1426
1468
|
}
|
|
1427
1469
|
`,
|
|
1428
1470
|
dts: import_outdent21.outdent`
|
|
@@ -1708,7 +1750,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1708
1750
|
var import_outdent26 = require("outdent");
|
|
1709
1751
|
var import_ts_pattern7 = require("ts-pattern");
|
|
1710
1752
|
function generateReactJsxPattern(ctx, filters) {
|
|
1711
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1753
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1712
1754
|
const details = ctx.patterns.filterDetails(filters);
|
|
1713
1755
|
return details.map((pattern) => {
|
|
1714
1756
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1717,24 +1759,45 @@ function generateReactJsxPattern(ctx, filters) {
|
|
|
1717
1759
|
name: dashName,
|
|
1718
1760
|
js: import_outdent26.outdent`
|
|
1719
1761
|
import { createElement, forwardRef } from 'react'
|
|
1720
|
-
${ctx.file.import(
|
|
1762
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1763
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1721
1764
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1765
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1722
1766
|
|
|
1723
1767
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1724
|
-
${(0, import_ts_pattern7.match)(
|
|
1725
|
-
|
|
1768
|
+
${(0, import_ts_pattern7.match)(jsxStyleProps2).with(
|
|
1769
|
+
"none",
|
|
1726
1770
|
() => import_outdent26.outdent`
|
|
1727
|
-
|
|
1728
|
-
|
|
1771
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1772
|
+
|
|
1773
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1774
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1775
|
+
|
|
1776
|
+
return createElement(Comp, { ref, ...restProps })
|
|
1777
|
+
`
|
|
1778
|
+
).with(
|
|
1779
|
+
"minimal",
|
|
1780
|
+
() => import_outdent26.outdent`
|
|
1781
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1782
|
+
|
|
1783
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1784
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1785
|
+
const mergedProps = { ref, ...restProps, ...cssProps }
|
|
1786
|
+
|
|
1787
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1729
1788
|
`
|
|
1730
|
-
).
|
|
1789
|
+
).with(
|
|
1790
|
+
"all",
|
|
1731
1791
|
() => import_outdent26.outdent`
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1792
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1793
|
+
|
|
1794
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1795
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
1796
|
+
|
|
1797
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1735
1798
|
`
|
|
1736
|
-
)}
|
|
1737
|
-
|
|
1799
|
+
).exhaustive()}
|
|
1800
|
+
})
|
|
1738
1801
|
`,
|
|
1739
1802
|
dts: import_outdent26.outdent`
|
|
1740
1803
|
import type { FunctionComponent } from 'react'
|
|
@@ -2044,7 +2107,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2044
2107
|
var import_outdent31 = require("outdent");
|
|
2045
2108
|
var import_ts_pattern8 = require("ts-pattern");
|
|
2046
2109
|
function generateSolidJsxPattern(ctx, filters) {
|
|
2047
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
2110
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
2048
2111
|
const details = ctx.patterns.filterDetails(filters);
|
|
2049
2112
|
return details.map((pattern) => {
|
|
2050
2113
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -2052,25 +2115,47 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2052
2115
|
return {
|
|
2053
2116
|
name: dashName,
|
|
2054
2117
|
js: import_outdent31.outdent`
|
|
2055
|
-
import {
|
|
2118
|
+
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2056
2119
|
import { createComponent } from 'solid-js/web'
|
|
2057
|
-
${ctx.file.import(
|
|
2120
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
2058
2121
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2122
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
2059
2123
|
|
|
2060
|
-
export function ${jsxName}(props) {
|
|
2061
|
-
${(0, import_ts_pattern8.match)(
|
|
2062
|
-
|
|
2124
|
+
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
2125
|
+
${(0, import_ts_pattern8.match)(jsxStyleProps2).with(
|
|
2126
|
+
"none",
|
|
2063
2127
|
() => import_outdent31.outdent`
|
|
2064
|
-
|
|
2065
|
-
|
|
2128
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2129
|
+
|
|
2130
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2131
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
2132
|
+
|
|
2133
|
+
return createComponent(Comp, restProps)
|
|
2066
2134
|
`
|
|
2067
|
-
).
|
|
2135
|
+
).with(
|
|
2136
|
+
"minimal",
|
|
2068
2137
|
() => import_outdent31.outdent`
|
|
2069
|
-
|
|
2138
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2139
|
+
|
|
2140
|
+
const cssProps = createMemo(() => {
|
|
2070
2141
|
const styleProps = ${styleFnName}(patternProps)
|
|
2071
|
-
return
|
|
2142
|
+
return { css: mergeCss(styleProps, props.css) }
|
|
2143
|
+
})
|
|
2144
|
+
const mergedProps = mergeProps(restProps, cssProps)
|
|
2145
|
+
|
|
2146
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2147
|
+
`
|
|
2148
|
+
).with(
|
|
2149
|
+
"all",
|
|
2150
|
+
() => import_outdent31.outdent`
|
|
2151
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2152
|
+
|
|
2153
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2154
|
+
const mergedProps = mergeProps(styleProps, restProps)
|
|
2155
|
+
|
|
2156
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2072
2157
|
`
|
|
2073
|
-
)}
|
|
2158
|
+
).exhaustive()}
|
|
2074
2159
|
}
|
|
2075
2160
|
`,
|
|
2076
2161
|
dts: import_outdent31.outdent`
|
|
@@ -2297,7 +2382,7 @@ function generateVueJsxFactory(ctx) {
|
|
|
2297
2382
|
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2298
2383
|
|
|
2299
2384
|
const splittedProps = computed(() => {
|
|
2300
|
-
return splitProps(combinedProps.value, normalizeHTMLProps.keys,
|
|
2385
|
+
return splitProps(combinedProps.value, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
|
|
2301
2386
|
})
|
|
2302
2387
|
|
|
2303
2388
|
const recipeClass = computed(() => {
|
|
@@ -2425,30 +2510,62 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2425
2510
|
|
|
2426
2511
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2427
2512
|
var import_outdent37 = require("outdent");
|
|
2513
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
2428
2514
|
function generateVueJsxPattern(ctx, filters) {
|
|
2429
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
2515
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
2430
2516
|
const details = ctx.patterns.filterDetails(filters);
|
|
2431
2517
|
return details.map((pattern) => {
|
|
2432
2518
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
2433
2519
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2434
|
-
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2435
2520
|
return {
|
|
2436
2521
|
name: dashName,
|
|
2437
2522
|
js: import_outdent37.outdent`
|
|
2438
2523
|
import { defineComponent, h, computed } from 'vue'
|
|
2439
|
-
${ctx.file.import(
|
|
2524
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
2440
2525
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2526
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
2441
2527
|
|
|
2442
|
-
export const ${jsxName} = defineComponent({
|
|
2528
|
+
export const ${jsxName} = /* @__PURE__ */ defineComponent({
|
|
2443
2529
|
name: '${jsxName}',
|
|
2444
2530
|
inheritAttrs: false,
|
|
2445
|
-
props:
|
|
2531
|
+
props: ${JSON.stringify(props)},
|
|
2446
2532
|
setup(props, { attrs, slots }) {
|
|
2533
|
+
${(0, import_ts_pattern9.match)(jsxStyleProps2).with(
|
|
2534
|
+
"none",
|
|
2535
|
+
() => import_outdent37.outdent`
|
|
2536
|
+
const Comp = computed(() => {
|
|
2537
|
+
const styleProps = ${styleFnName}(props)
|
|
2538
|
+
return ${factoryName}("${jsxElement}", { base: styleProps })
|
|
2539
|
+
})
|
|
2540
|
+
|
|
2541
|
+
return () => {
|
|
2542
|
+
return h(Comp.value, attrs, slots)
|
|
2543
|
+
}
|
|
2544
|
+
`
|
|
2545
|
+
).with(
|
|
2546
|
+
"minimal",
|
|
2547
|
+
() => import_outdent37.outdent`
|
|
2548
|
+
const cssProps = computed(() => {
|
|
2549
|
+
const styleProps = ${styleFnName}(props)
|
|
2550
|
+
return { css: mergeCss(styleProps, attrs.css) }
|
|
2551
|
+
})
|
|
2552
|
+
|
|
2553
|
+
return () => {
|
|
2554
|
+
const mergedProps = { ...attrs, ...cssProps.value }
|
|
2555
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2556
|
+
}
|
|
2557
|
+
`
|
|
2558
|
+
).with(
|
|
2559
|
+
"all",
|
|
2560
|
+
() => import_outdent37.outdent`
|
|
2447
2561
|
const styleProps = computed(() => ${styleFnName}(props))
|
|
2562
|
+
|
|
2448
2563
|
return () => {
|
|
2449
|
-
|
|
2450
|
-
|
|
2564
|
+
const mergedProps = { ...styleProps.value, ...attrs }
|
|
2565
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2451
2566
|
}
|
|
2567
|
+
`
|
|
2568
|
+
).exhaustive()}
|
|
2452
2569
|
}
|
|
2453
2570
|
})
|
|
2454
2571
|
`,
|
|
@@ -2695,7 +2812,7 @@ var composition_d_ts_default = {
|
|
|
2695
2812
|
|
|
2696
2813
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2697
2814
|
var recipe_d_ts_default = {
|
|
2698
|
-
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"
|
|
2815
|
+
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 * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\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"
|
|
2699
2816
|
};
|
|
2700
2817
|
|
|
2701
2818
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2719,7 +2836,7 @@ var static_css_d_ts_default = {
|
|
|
2719
2836
|
};
|
|
2720
2837
|
|
|
2721
2838
|
// src/artifacts/types/generated.ts
|
|
2722
|
-
var
|
|
2839
|
+
var import_ts_pattern10 = require("ts-pattern");
|
|
2723
2840
|
function getGeneratedTypes(ctx) {
|
|
2724
2841
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
2725
2842
|
return {
|
|
@@ -2737,7 +2854,7 @@ function getGeneratedSystemTypes(ctx) {
|
|
|
2737
2854
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
2738
2855
|
return {
|
|
2739
2856
|
system: rewriteImports(
|
|
2740
|
-
(0,
|
|
2857
|
+
(0, import_ts_pattern10.match)(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
2741
2858
|
"minimal",
|
|
2742
2859
|
() => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
|
|
2743
2860
|
).with(
|
|
@@ -2828,21 +2945,22 @@ function generatePropTypes(ctx) {
|
|
|
2828
2945
|
${strictTokens ? `
|
|
2829
2946
|
type FilterString<T> = T extends \`\${infer _}\` ? T : never;
|
|
2830
2947
|
type WithArbitraryValue<T> = T | \`[\${string}]\`
|
|
2948
|
+
type PropOrCondition<T> = ConditionalValue<WithArbitraryValue<T>>;
|
|
2831
2949
|
|
|
2832
2950
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
2833
|
-
?
|
|
2951
|
+
? PropOrCondition<FilterString<PropertyTypes[T]>>
|
|
2834
2952
|
: never;
|
|
2835
2953
|
|
|
2836
2954
|
type CssPropertyValue<T extends string> = T extends keyof CssProperties
|
|
2837
|
-
?
|
|
2955
|
+
? PropOrCondition<FilterString<CssProperties[T]>>
|
|
2838
2956
|
: never;
|
|
2839
2957
|
|
|
2840
|
-
export type PropertyValue<T extends string> =
|
|
2958
|
+
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2841
2959
|
? PropertyTypeValue<T>
|
|
2842
2960
|
: T extends keyof CssProperties
|
|
2843
2961
|
? CssPropertyValue<T>
|
|
2844
|
-
:
|
|
2845
|
-
|
|
2962
|
+
: PropOrCondition<string | number>
|
|
2963
|
+
` : `
|
|
2846
2964
|
|
|
2847
2965
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
2848
2966
|
? ConditionalValue<PropertyTypes[T] | CssValue<T> | (string & {})>
|
|
@@ -3424,7 +3542,7 @@ function generateKeyframeCss(ctx) {
|
|
|
3424
3542
|
|
|
3425
3543
|
// src/artifacts/css/parser-css.ts
|
|
3426
3544
|
var import_logger2 = require("@pandacss/logger");
|
|
3427
|
-
var
|
|
3545
|
+
var import_ts_pattern11 = require("ts-pattern");
|
|
3428
3546
|
var generateParserCss = (ctx, result) => {
|
|
3429
3547
|
const { patterns, recipes } = ctx;
|
|
3430
3548
|
result.css.forEach((css2) => {
|
|
@@ -3453,7 +3571,7 @@ var generateParserCss = (ctx, result) => {
|
|
|
3453
3571
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3454
3572
|
if (!recipeConfig)
|
|
3455
3573
|
continue;
|
|
3456
|
-
(0,
|
|
3574
|
+
(0, import_ts_pattern11.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3457
3575
|
recipe.data.forEach((data) => {
|
|
3458
3576
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3459
3577
|
ctx.stylesheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3472,7 +3590,7 @@ var generateParserCss = (ctx, result) => {
|
|
|
3472
3590
|
result.pattern.forEach((patternSet, name) => {
|
|
3473
3591
|
try {
|
|
3474
3592
|
for (const pattern of patternSet) {
|
|
3475
|
-
(0,
|
|
3593
|
+
(0, import_ts_pattern11.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern11.P.string }, ({ name: jsxName }) => {
|
|
3476
3594
|
pattern.data.forEach((data) => {
|
|
3477
3595
|
const fnName = patterns.find(jsxName);
|
|
3478
3596
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -4137,7 +4255,7 @@ var Context = class {
|
|
|
4137
4255
|
return new import_core5.Utility({
|
|
4138
4256
|
prefix: this.prefix.className,
|
|
4139
4257
|
tokens: this.tokens,
|
|
4140
|
-
config: this.isTemplateLiteralSyntax ? {} : config.utilities,
|
|
4258
|
+
config: this.isTemplateLiteralSyntax ? {} : Object.assign({}, config.utilities),
|
|
4141
4259
|
separator: config.separator,
|
|
4142
4260
|
shorthands: config.shorthands,
|
|
4143
4261
|
strictTokens: config.strictTokens
|
|
@@ -4216,6 +4334,7 @@ var getParserOptions = (ctx) => {
|
|
|
4216
4334
|
isStyleProp: isValidProperty,
|
|
4217
4335
|
nodes: [...patterns.details, ...recipes.details]
|
|
4218
4336
|
},
|
|
4337
|
+
isTemplateLiteralSyntax: ctx.isTemplateLiteralSyntax,
|
|
4219
4338
|
patternKeys: patterns.keys,
|
|
4220
4339
|
recipeKeys: recipes.keys,
|
|
4221
4340
|
getRecipesByJsxName: recipes.filter,
|
|
@@ -4238,7 +4357,7 @@ var Generator = class extends Context {
|
|
|
4238
4357
|
return generateArtifacts(this, ids);
|
|
4239
4358
|
}
|
|
4240
4359
|
appendCss(type) {
|
|
4241
|
-
(0,
|
|
4360
|
+
(0, import_ts_pattern12.match)(type).with("preflight", () => generateResetCss(this)).with("tokens", () => generateTokenCss(this)).with("static", () => generateStaticCss(this)).with("global", () => generateGlobalCss(this)).with("keyframes", () => generateKeyframeCss(this)).otherwise(() => {
|
|
4242
4361
|
throw new Error(`Unknown css artifact type <${type}>`);
|
|
4243
4362
|
});
|
|
4244
4363
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -101,7 +101,7 @@ var getMessages = (ctx) => ({
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// src/generator.ts
|
|
104
|
-
import { match as
|
|
104
|
+
import { match as match12 } from "ts-pattern";
|
|
105
105
|
|
|
106
106
|
// src/artifacts/setup-artifacts.ts
|
|
107
107
|
import outdent44 from "outdent";
|
|
@@ -478,7 +478,7 @@ import { outdent as outdent8 } from "outdent";
|
|
|
478
478
|
|
|
479
479
|
// src/artifacts/generated/helpers.mjs.json
|
|
480
480
|
var helpers_mjs_default = {
|
|
481
|
-
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)
|
|
481
|
+
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 (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 (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'
|
|
482
482
|
};
|
|
483
483
|
|
|
484
484
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -1061,7 +1061,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1061
1061
|
import { outdent as outdent16 } from "outdent";
|
|
1062
1062
|
import { match as match5 } from "ts-pattern";
|
|
1063
1063
|
function generatePreactJsxPattern(ctx, filters) {
|
|
1064
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1064
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1065
1065
|
const details = ctx.patterns.filterDetails(filters);
|
|
1066
1066
|
return details.map((pattern) => {
|
|
1067
1067
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1071,23 +1071,44 @@ function generatePreactJsxPattern(ctx, filters) {
|
|
|
1071
1071
|
js: outdent16`
|
|
1072
1072
|
import { h } from 'preact'
|
|
1073
1073
|
import { forwardRef } from 'preact/compat'
|
|
1074
|
-
${ctx.file.import(
|
|
1074
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1075
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1075
1076
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1077
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1076
1078
|
|
|
1077
1079
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1078
|
-
${match5(
|
|
1079
|
-
|
|
1080
|
+
${match5(jsxStyleProps2).with(
|
|
1081
|
+
"none",
|
|
1080
1082
|
() => outdent16`
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1083
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1084
|
+
|
|
1085
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1086
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1087
|
+
|
|
1088
|
+
return h(Comp, { ref, ...restProps })
|
|
1089
|
+
`
|
|
1090
|
+
).with(
|
|
1091
|
+
"minimal",
|
|
1092
|
+
() => outdent16`
|
|
1093
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1094
|
+
|
|
1095
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1096
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1097
|
+
const mergedProps = { ref, ...restProps, ...cssProps }
|
|
1098
|
+
|
|
1099
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1083
1100
|
`
|
|
1084
|
-
).
|
|
1101
|
+
).with(
|
|
1102
|
+
"all",
|
|
1085
1103
|
() => outdent16`
|
|
1086
|
-
const
|
|
1087
|
-
|
|
1088
|
-
|
|
1104
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1105
|
+
|
|
1106
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1107
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
1108
|
+
|
|
1109
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1089
1110
|
`
|
|
1090
|
-
)}
|
|
1111
|
+
).exhaustive()}
|
|
1091
1112
|
})
|
|
1092
1113
|
`,
|
|
1093
1114
|
dts: outdent16`
|
|
@@ -1366,7 +1387,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1366
1387
|
import { outdent as outdent21 } from "outdent";
|
|
1367
1388
|
import { match as match6 } from "ts-pattern";
|
|
1368
1389
|
function generateQwikJsxPattern(ctx, filters) {
|
|
1369
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1390
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1370
1391
|
const details = ctx.patterns.filterDetails(filters);
|
|
1371
1392
|
return details.map((pattern) => {
|
|
1372
1393
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1375,23 +1396,44 @@ function generateQwikJsxPattern(ctx, filters) {
|
|
|
1375
1396
|
name: dashName,
|
|
1376
1397
|
js: outdent21`
|
|
1377
1398
|
import { h } from '@builder.io/qwik'
|
|
1378
|
-
${ctx.file.import(
|
|
1399
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1400
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1379
1401
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1402
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1380
1403
|
|
|
1381
|
-
export const ${jsxName} = function ${jsxName}(props) {
|
|
1382
|
-
${match6(
|
|
1383
|
-
|
|
1404
|
+
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
1405
|
+
${match6(jsxStyleProps2).with(
|
|
1406
|
+
"none",
|
|
1407
|
+
() => outdent21`
|
|
1408
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1409
|
+
|
|
1410
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1411
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1412
|
+
|
|
1413
|
+
return h(Comp, restProps)
|
|
1414
|
+
`
|
|
1415
|
+
).with(
|
|
1416
|
+
"minimal",
|
|
1384
1417
|
() => outdent21`
|
|
1385
|
-
|
|
1386
|
-
|
|
1418
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1419
|
+
|
|
1420
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1421
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1422
|
+
const mergedProps = { ...restProps, ...cssProps }
|
|
1423
|
+
|
|
1424
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1387
1425
|
`
|
|
1388
|
-
).
|
|
1426
|
+
).with(
|
|
1427
|
+
"all",
|
|
1389
1428
|
() => outdent21`
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1429
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1430
|
+
|
|
1431
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1432
|
+
const mergedProps = { ...styleProps, ...restProps }
|
|
1433
|
+
|
|
1434
|
+
return h(${factoryName}.${jsxElement}, mergedProps)
|
|
1393
1435
|
`
|
|
1394
|
-
)}
|
|
1436
|
+
).exhaustive()}
|
|
1395
1437
|
}
|
|
1396
1438
|
`,
|
|
1397
1439
|
dts: outdent21`
|
|
@@ -1677,7 +1719,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1677
1719
|
import { outdent as outdent26 } from "outdent";
|
|
1678
1720
|
import { match as match7 } from "ts-pattern";
|
|
1679
1721
|
function generateReactJsxPattern(ctx, filters) {
|
|
1680
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
1722
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1681
1723
|
const details = ctx.patterns.filterDetails(filters);
|
|
1682
1724
|
return details.map((pattern) => {
|
|
1683
1725
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -1686,24 +1728,45 @@ function generateReactJsxPattern(ctx, filters) {
|
|
|
1686
1728
|
name: dashName,
|
|
1687
1729
|
js: outdent26`
|
|
1688
1730
|
import { createElement, forwardRef } from 'react'
|
|
1689
|
-
${ctx.file.import(
|
|
1731
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
1732
|
+
${ctx.file.import("splitProps", "../helpers")}
|
|
1690
1733
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1734
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
1691
1735
|
|
|
1692
1736
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1693
|
-
${match7(
|
|
1694
|
-
|
|
1737
|
+
${match7(jsxStyleProps2).with(
|
|
1738
|
+
"none",
|
|
1739
|
+
() => outdent26`
|
|
1740
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1741
|
+
|
|
1742
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1743
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
1744
|
+
|
|
1745
|
+
return createElement(Comp, { ref, ...restProps })
|
|
1746
|
+
`
|
|
1747
|
+
).with(
|
|
1748
|
+
"minimal",
|
|
1695
1749
|
() => outdent26`
|
|
1696
|
-
|
|
1697
|
-
|
|
1750
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1751
|
+
|
|
1752
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1753
|
+
const cssProps = { css: mergeCss(styleProps, props.css) }
|
|
1754
|
+
const mergedProps = { ref, ...restProps, ...cssProps }
|
|
1755
|
+
|
|
1756
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1698
1757
|
`
|
|
1699
|
-
).
|
|
1758
|
+
).with(
|
|
1759
|
+
"all",
|
|
1700
1760
|
() => outdent26`
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1761
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
1762
|
+
|
|
1763
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
1764
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
1765
|
+
|
|
1766
|
+
return createElement(${factoryName}.${jsxElement}, mergedProps)
|
|
1704
1767
|
`
|
|
1705
|
-
)}
|
|
1706
|
-
|
|
1768
|
+
).exhaustive()}
|
|
1769
|
+
})
|
|
1707
1770
|
`,
|
|
1708
1771
|
dts: outdent26`
|
|
1709
1772
|
import type { FunctionComponent } from 'react'
|
|
@@ -2013,7 +2076,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2013
2076
|
import { outdent as outdent31 } from "outdent";
|
|
2014
2077
|
import { match as match8 } from "ts-pattern";
|
|
2015
2078
|
function generateSolidJsxPattern(ctx, filters) {
|
|
2016
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
2079
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
2017
2080
|
const details = ctx.patterns.filterDetails(filters);
|
|
2018
2081
|
return details.map((pattern) => {
|
|
2019
2082
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
@@ -2021,25 +2084,47 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2021
2084
|
return {
|
|
2022
2085
|
name: dashName,
|
|
2023
2086
|
js: outdent31`
|
|
2024
|
-
import {
|
|
2087
|
+
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2025
2088
|
import { createComponent } from 'solid-js/web'
|
|
2026
|
-
${ctx.file.import(
|
|
2089
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
2027
2090
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2091
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
2028
2092
|
|
|
2029
|
-
export function ${jsxName}(props) {
|
|
2030
|
-
${match8(
|
|
2031
|
-
|
|
2093
|
+
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
2094
|
+
${match8(jsxStyleProps2).with(
|
|
2095
|
+
"none",
|
|
2032
2096
|
() => outdent31`
|
|
2033
|
-
|
|
2034
|
-
|
|
2097
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2098
|
+
|
|
2099
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2100
|
+
const Comp = ${factoryName}("${jsxElement}", { base: styleProps })
|
|
2101
|
+
|
|
2102
|
+
return createComponent(Comp, restProps)
|
|
2035
2103
|
`
|
|
2036
|
-
).
|
|
2104
|
+
).with(
|
|
2105
|
+
"minimal",
|
|
2037
2106
|
() => outdent31`
|
|
2038
|
-
|
|
2107
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2108
|
+
|
|
2109
|
+
const cssProps = createMemo(() => {
|
|
2039
2110
|
const styleProps = ${styleFnName}(patternProps)
|
|
2040
|
-
return
|
|
2111
|
+
return { css: mergeCss(styleProps, props.css) }
|
|
2112
|
+
})
|
|
2113
|
+
const mergedProps = mergeProps(restProps, cssProps)
|
|
2114
|
+
|
|
2115
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2116
|
+
`
|
|
2117
|
+
).with(
|
|
2118
|
+
"all",
|
|
2119
|
+
() => outdent31`
|
|
2120
|
+
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
2121
|
+
|
|
2122
|
+
const styleProps = ${styleFnName}(patternProps)
|
|
2123
|
+
const mergedProps = mergeProps(styleProps, restProps)
|
|
2124
|
+
|
|
2125
|
+
return createComponent(${factoryName}.${jsxElement}, mergedProps)
|
|
2041
2126
|
`
|
|
2042
|
-
)}
|
|
2127
|
+
).exhaustive()}
|
|
2043
2128
|
}
|
|
2044
2129
|
`,
|
|
2045
2130
|
dts: outdent31`
|
|
@@ -2266,7 +2351,7 @@ function generateVueJsxFactory(ctx) {
|
|
|
2266
2351
|
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2267
2352
|
|
|
2268
2353
|
const splittedProps = computed(() => {
|
|
2269
|
-
return splitProps(combinedProps.value, normalizeHTMLProps.keys,
|
|
2354
|
+
return splitProps(combinedProps.value, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
|
|
2270
2355
|
})
|
|
2271
2356
|
|
|
2272
2357
|
const recipeClass = computed(() => {
|
|
@@ -2394,30 +2479,62 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2394
2479
|
|
|
2395
2480
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2396
2481
|
import { outdent as outdent37 } from "outdent";
|
|
2482
|
+
import { match as match9 } from "ts-pattern";
|
|
2397
2483
|
function generateVueJsxPattern(ctx, filters) {
|
|
2398
|
-
const { typeName, factoryName } = ctx.jsx;
|
|
2484
|
+
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
2399
2485
|
const details = ctx.patterns.filterDetails(filters);
|
|
2400
2486
|
return details.map((pattern) => {
|
|
2401
2487
|
const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
|
|
2402
2488
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2403
|
-
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2404
2489
|
return {
|
|
2405
2490
|
name: dashName,
|
|
2406
2491
|
js: outdent37`
|
|
2407
2492
|
import { defineComponent, h, computed } from 'vue'
|
|
2408
|
-
${ctx.file.import(
|
|
2493
|
+
${ctx.file.import("mergeCss", "../css/css")}
|
|
2409
2494
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2495
|
+
${ctx.file.import(factoryName, "./factory")}
|
|
2410
2496
|
|
|
2411
|
-
export const ${jsxName} = defineComponent({
|
|
2497
|
+
export const ${jsxName} = /* @__PURE__ */ defineComponent({
|
|
2412
2498
|
name: '${jsxName}',
|
|
2413
2499
|
inheritAttrs: false,
|
|
2414
|
-
props:
|
|
2500
|
+
props: ${JSON.stringify(props)},
|
|
2415
2501
|
setup(props, { attrs, slots }) {
|
|
2502
|
+
${match9(jsxStyleProps2).with(
|
|
2503
|
+
"none",
|
|
2504
|
+
() => outdent37`
|
|
2505
|
+
const Comp = computed(() => {
|
|
2506
|
+
const styleProps = ${styleFnName}(props)
|
|
2507
|
+
return ${factoryName}("${jsxElement}", { base: styleProps })
|
|
2508
|
+
})
|
|
2509
|
+
|
|
2510
|
+
return () => {
|
|
2511
|
+
return h(Comp.value, attrs, slots)
|
|
2512
|
+
}
|
|
2513
|
+
`
|
|
2514
|
+
).with(
|
|
2515
|
+
"minimal",
|
|
2516
|
+
() => outdent37`
|
|
2517
|
+
const cssProps = computed(() => {
|
|
2518
|
+
const styleProps = ${styleFnName}(props)
|
|
2519
|
+
return { css: mergeCss(styleProps, attrs.css) }
|
|
2520
|
+
})
|
|
2521
|
+
|
|
2522
|
+
return () => {
|
|
2523
|
+
const mergedProps = { ...attrs, ...cssProps.value }
|
|
2524
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2525
|
+
}
|
|
2526
|
+
`
|
|
2527
|
+
).with(
|
|
2528
|
+
"all",
|
|
2529
|
+
() => outdent37`
|
|
2416
2530
|
const styleProps = computed(() => ${styleFnName}(props))
|
|
2531
|
+
|
|
2417
2532
|
return () => {
|
|
2418
|
-
|
|
2419
|
-
|
|
2533
|
+
const mergedProps = { ...styleProps.value, ...attrs }
|
|
2534
|
+
return h(${factoryName}.${jsxElement}, mergedProps, slots)
|
|
2420
2535
|
}
|
|
2536
|
+
`
|
|
2537
|
+
).exhaustive()}
|
|
2421
2538
|
}
|
|
2422
2539
|
})
|
|
2423
2540
|
`,
|
|
@@ -2664,7 +2781,7 @@ var composition_d_ts_default = {
|
|
|
2664
2781
|
|
|
2665
2782
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2666
2783
|
var recipe_d_ts_default = {
|
|
2667
|
-
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"
|
|
2784
|
+
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 * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\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"
|
|
2668
2785
|
};
|
|
2669
2786
|
|
|
2670
2787
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2688,7 +2805,7 @@ var static_css_d_ts_default = {
|
|
|
2688
2805
|
};
|
|
2689
2806
|
|
|
2690
2807
|
// src/artifacts/types/generated.ts
|
|
2691
|
-
import { match as
|
|
2808
|
+
import { match as match10 } from "ts-pattern";
|
|
2692
2809
|
function getGeneratedTypes(ctx) {
|
|
2693
2810
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
2694
2811
|
return {
|
|
@@ -2706,7 +2823,7 @@ function getGeneratedSystemTypes(ctx) {
|
|
|
2706
2823
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
2707
2824
|
return {
|
|
2708
2825
|
system: rewriteImports(
|
|
2709
|
-
|
|
2826
|
+
match10(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
2710
2827
|
"minimal",
|
|
2711
2828
|
() => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
|
|
2712
2829
|
).with(
|
|
@@ -2797,21 +2914,22 @@ function generatePropTypes(ctx) {
|
|
|
2797
2914
|
${strictTokens ? `
|
|
2798
2915
|
type FilterString<T> = T extends \`\${infer _}\` ? T : never;
|
|
2799
2916
|
type WithArbitraryValue<T> = T | \`[\${string}]\`
|
|
2917
|
+
type PropOrCondition<T> = ConditionalValue<WithArbitraryValue<T>>;
|
|
2800
2918
|
|
|
2801
2919
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
2802
|
-
?
|
|
2920
|
+
? PropOrCondition<FilterString<PropertyTypes[T]>>
|
|
2803
2921
|
: never;
|
|
2804
2922
|
|
|
2805
2923
|
type CssPropertyValue<T extends string> = T extends keyof CssProperties
|
|
2806
|
-
?
|
|
2924
|
+
? PropOrCondition<FilterString<CssProperties[T]>>
|
|
2807
2925
|
: never;
|
|
2808
2926
|
|
|
2809
|
-
export type PropertyValue<T extends string> =
|
|
2927
|
+
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2810
2928
|
? PropertyTypeValue<T>
|
|
2811
2929
|
: T extends keyof CssProperties
|
|
2812
2930
|
? CssPropertyValue<T>
|
|
2813
|
-
:
|
|
2814
|
-
|
|
2931
|
+
: PropOrCondition<string | number>
|
|
2932
|
+
` : `
|
|
2815
2933
|
|
|
2816
2934
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
2817
2935
|
? ConditionalValue<PropertyTypes[T] | CssValue<T> | (string & {})>
|
|
@@ -3393,7 +3511,7 @@ function generateKeyframeCss(ctx) {
|
|
|
3393
3511
|
|
|
3394
3512
|
// src/artifacts/css/parser-css.ts
|
|
3395
3513
|
import { logger } from "@pandacss/logger";
|
|
3396
|
-
import { P, match as
|
|
3514
|
+
import { P, match as match11 } from "ts-pattern";
|
|
3397
3515
|
var generateParserCss = (ctx, result) => {
|
|
3398
3516
|
const { patterns, recipes } = ctx;
|
|
3399
3517
|
result.css.forEach((css2) => {
|
|
@@ -3422,7 +3540,7 @@ var generateParserCss = (ctx, result) => {
|
|
|
3422
3540
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3423
3541
|
if (!recipeConfig)
|
|
3424
3542
|
continue;
|
|
3425
|
-
|
|
3543
|
+
match11(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3426
3544
|
recipe.data.forEach((data) => {
|
|
3427
3545
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3428
3546
|
ctx.stylesheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3441,7 +3559,7 @@ var generateParserCss = (ctx, result) => {
|
|
|
3441
3559
|
result.pattern.forEach((patternSet, name) => {
|
|
3442
3560
|
try {
|
|
3443
3561
|
for (const pattern of patternSet) {
|
|
3444
|
-
|
|
3562
|
+
match11(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
|
|
3445
3563
|
pattern.data.forEach((data) => {
|
|
3446
3564
|
const fnName = patterns.find(jsxName);
|
|
3447
3565
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -4113,7 +4231,7 @@ var Context = class {
|
|
|
4113
4231
|
return new Utility({
|
|
4114
4232
|
prefix: this.prefix.className,
|
|
4115
4233
|
tokens: this.tokens,
|
|
4116
|
-
config: this.isTemplateLiteralSyntax ? {} : config.utilities,
|
|
4234
|
+
config: this.isTemplateLiteralSyntax ? {} : Object.assign({}, config.utilities),
|
|
4117
4235
|
separator: config.separator,
|
|
4118
4236
|
shorthands: config.shorthands,
|
|
4119
4237
|
strictTokens: config.strictTokens
|
|
@@ -4192,6 +4310,7 @@ var getParserOptions = (ctx) => {
|
|
|
4192
4310
|
isStyleProp: isValidProperty,
|
|
4193
4311
|
nodes: [...patterns.details, ...recipes.details]
|
|
4194
4312
|
},
|
|
4313
|
+
isTemplateLiteralSyntax: ctx.isTemplateLiteralSyntax,
|
|
4195
4314
|
patternKeys: patterns.keys,
|
|
4196
4315
|
recipeKeys: recipes.keys,
|
|
4197
4316
|
getRecipesByJsxName: recipes.filter,
|
|
@@ -4214,7 +4333,7 @@ var Generator = class extends Context {
|
|
|
4214
4333
|
return generateArtifacts(this, ids);
|
|
4215
4334
|
}
|
|
4216
4335
|
appendCss(type) {
|
|
4217
|
-
|
|
4336
|
+
match12(type).with("preflight", () => generateResetCss(this)).with("tokens", () => generateTokenCss(this)).with("static", () => generateStaticCss(this)).with("global", () => generateGlobalCss(this)).with("keyframes", () => generateKeyframeCss(this)).otherwise(() => {
|
|
4218
4337
|
throw new Error(`Unknown css artifact type <${type}>`);
|
|
4219
4338
|
});
|
|
4220
4339
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"pluralize": "8.0.0",
|
|
33
33
|
"postcss": "^8.4.31",
|
|
34
34
|
"ts-pattern": "5.0.5",
|
|
35
|
-
"@pandacss/core": "0.
|
|
36
|
-
"@pandacss/is-valid-prop": "0.
|
|
37
|
-
"@pandacss/logger": "0.
|
|
38
|
-
"@pandacss/shared": "0.
|
|
39
|
-
"@pandacss/token-dictionary": "0.
|
|
40
|
-
"@pandacss/types": "0.
|
|
35
|
+
"@pandacss/core": "0.23.0",
|
|
36
|
+
"@pandacss/is-valid-prop": "0.23.0",
|
|
37
|
+
"@pandacss/logger": "0.23.0",
|
|
38
|
+
"@pandacss/shared": "0.23.0",
|
|
39
|
+
"@pandacss/token-dictionary": "0.23.0",
|
|
40
|
+
"@pandacss/types": "0.23.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/pluralize": "0.0.33",
|
|
44
|
-
"hookable": "5.5.3"
|
|
45
|
-
"@pandacss/fixture": "0.22.0"
|
|
44
|
+
"hookable": "5.5.3"
|
|
46
45
|
},
|
|
47
46
|
"scripts": {
|
|
48
47
|
"build": "tsup src/index.ts --format=esm,cjs --dts",
|