@pandacss/generator 0.13.1 → 0.15.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.js +84 -299
- package/dist/index.mjs +84 -299
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -558,7 +558,9 @@ function generateConditions(ctx) {
|
|
|
558
558
|
${ctx.file.importType("AnySelector, Selectors", "./selectors")}
|
|
559
559
|
|
|
560
560
|
export type Conditions = {
|
|
561
|
-
${keys.map(
|
|
561
|
+
${keys.map(
|
|
562
|
+
(key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */` : ctx.conditions.get(key) ? `/** \`${ctx.conditions.get(key)}\` */` : ""}${JSON.stringify(key)}: string`
|
|
563
|
+
).join("\n")}
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
export type Condition = keyof Conditions
|
|
@@ -629,8 +631,8 @@ function generateCssFn(ctx) {
|
|
|
629
631
|
${ctx.file.importType("SystemStyleObject", "../types/index")}
|
|
630
632
|
|
|
631
633
|
interface CssFunction {
|
|
632
|
-
(...styles: SystemStyleObject
|
|
633
|
-
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
634
|
+
(...styles: Array<SystemStyleObject | undefined | null | false>): string
|
|
635
|
+
raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
|
|
634
636
|
}
|
|
635
637
|
|
|
636
638
|
export declare const css: CssFunction;
|
|
@@ -697,7 +699,7 @@ function generateCssFn(ctx) {
|
|
|
697
699
|
|
|
698
700
|
const cssFn = createCss(context)
|
|
699
701
|
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
700
|
-
css.raw = (styles) => styles
|
|
702
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
701
703
|
|
|
702
704
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
703
705
|
`
|
|
@@ -815,7 +817,7 @@ function generateCvaFn(ctx) {
|
|
|
815
817
|
}
|
|
816
818
|
|
|
817
819
|
export function assertCompoundVariant(name, compoundVariants, variants, prop) {
|
|
818
|
-
if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
|
|
820
|
+
if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
|
|
819
821
|
throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
|
|
820
822
|
}
|
|
821
823
|
}
|
|
@@ -866,7 +868,7 @@ var import_outdent8 = require("outdent");
|
|
|
866
868
|
|
|
867
869
|
// src/artifacts/generated/helpers.mjs.json
|
|
868
870
|
var helpers_mjs_default = {
|
|
869
|
-
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 result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\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
|
|
871
|
+
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 result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\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 recipeParts = recipe.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}\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 walkObject,\n withoutSpace\n};\n'
|
|
870
872
|
};
|
|
871
873
|
|
|
872
874
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -986,7 +988,7 @@ function generatePattern(ctx) {
|
|
|
986
988
|
|
|
987
989
|
interface ${upperName}PatternFn {
|
|
988
990
|
(styles?: ${upperName}Styles): string
|
|
989
|
-
raw: (styles
|
|
991
|
+
raw: (styles?: ${upperName}Styles) => SystemStyleObject
|
|
990
992
|
}
|
|
991
993
|
|
|
992
994
|
${description ? `/** ${description} */` : ""}
|
|
@@ -1175,12 +1177,17 @@ function generateSvaFn(ctx) {
|
|
|
1175
1177
|
|
|
1176
1178
|
export function sva(config) {
|
|
1177
1179
|
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1178
|
-
|
|
1180
|
+
|
|
1179
1181
|
function svaFn(props) {
|
|
1180
1182
|
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1181
1183
|
return Object.fromEntries(result)
|
|
1182
1184
|
}
|
|
1183
1185
|
|
|
1186
|
+
function raw(props) {
|
|
1187
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
|
|
1188
|
+
return Object.fromEntries(result)
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1184
1191
|
const variants = config.variants ?? {};
|
|
1185
1192
|
const variantKeys = Object.keys(variants);
|
|
1186
1193
|
|
|
@@ -1194,6 +1201,7 @@ function generateSvaFn(ctx) {
|
|
|
1194
1201
|
|
|
1195
1202
|
return Object.assign(svaFn, {
|
|
1196
1203
|
__cva__: false,
|
|
1204
|
+
raw,
|
|
1197
1205
|
variantMap,
|
|
1198
1206
|
variantKeys,
|
|
1199
1207
|
splitVariantProps,
|
|
@@ -2469,158 +2477,40 @@ ${ctx.file.importType(upperName, "../types/jsx")}
|
|
|
2469
2477
|
export declare const ${factoryName}: ${upperName}
|
|
2470
2478
|
`,
|
|
2471
2479
|
jsxType: import_outdent37.outdent`
|
|
2472
|
-
import type { Component, FunctionalComponent } from 'vue'
|
|
2480
|
+
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2473
2481
|
|
|
2474
2482
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2475
2483
|
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
2476
2484
|
|
|
2477
|
-
type IntrinsicElement =
|
|
2478
|
-
|
|
2479
|
-
| 'abbr'
|
|
2480
|
-
| 'address'
|
|
2481
|
-
| 'area'
|
|
2482
|
-
| 'article'
|
|
2483
|
-
| 'aside'
|
|
2484
|
-
| 'audio'
|
|
2485
|
-
| 'b'
|
|
2486
|
-
| 'base'
|
|
2487
|
-
| 'bdi'
|
|
2488
|
-
| 'bdo'
|
|
2489
|
-
| 'blockquote'
|
|
2490
|
-
| 'body'
|
|
2491
|
-
| 'br'
|
|
2492
|
-
| 'button'
|
|
2493
|
-
| 'canvas'
|
|
2494
|
-
| 'caption'
|
|
2495
|
-
| 'cite'
|
|
2496
|
-
| 'code'
|
|
2497
|
-
| 'col'
|
|
2498
|
-
| 'colgroup'
|
|
2499
|
-
| 'data'
|
|
2500
|
-
| 'datalist'
|
|
2501
|
-
| 'dd'
|
|
2502
|
-
| 'del'
|
|
2503
|
-
| 'details'
|
|
2504
|
-
| 'dfn'
|
|
2505
|
-
| 'dialog'
|
|
2506
|
-
| 'div'
|
|
2507
|
-
| 'dl'
|
|
2508
|
-
| 'dt'
|
|
2509
|
-
| 'em'
|
|
2510
|
-
| 'embed'
|
|
2511
|
-
| 'fieldset'
|
|
2512
|
-
| 'figcaption'
|
|
2513
|
-
| 'figure'
|
|
2514
|
-
| 'footer'
|
|
2515
|
-
| 'form'
|
|
2516
|
-
| 'h1'
|
|
2517
|
-
| 'h2'
|
|
2518
|
-
| 'h3'
|
|
2519
|
-
| 'h4'
|
|
2520
|
-
| 'h5'
|
|
2521
|
-
| 'h6'
|
|
2522
|
-
| 'head'
|
|
2523
|
-
| 'header'
|
|
2524
|
-
| 'hgroup'
|
|
2525
|
-
| 'hr'
|
|
2526
|
-
| 'html'
|
|
2527
|
-
| 'i'
|
|
2528
|
-
| 'iframe'
|
|
2529
|
-
| 'img'
|
|
2530
|
-
| 'input'
|
|
2531
|
-
| 'ins'
|
|
2532
|
-
| 'kbd'
|
|
2533
|
-
| 'label'
|
|
2534
|
-
| 'legend'
|
|
2535
|
-
| 'li'
|
|
2536
|
-
| 'link'
|
|
2537
|
-
| 'main'
|
|
2538
|
-
| 'map'
|
|
2539
|
-
| 'mark'
|
|
2540
|
-
| 'math'
|
|
2541
|
-
| 'menu'
|
|
2542
|
-
| 'menuitem'
|
|
2543
|
-
| 'meta'
|
|
2544
|
-
| 'meter'
|
|
2545
|
-
| 'nav'
|
|
2546
|
-
| 'noscript'
|
|
2547
|
-
| 'object'
|
|
2548
|
-
| 'ol'
|
|
2549
|
-
| 'optgroup'
|
|
2550
|
-
| 'option'
|
|
2551
|
-
| 'output'
|
|
2552
|
-
| 'p'
|
|
2553
|
-
| 'param'
|
|
2554
|
-
| 'picture'
|
|
2555
|
-
| 'pre'
|
|
2556
|
-
| 'progress'
|
|
2557
|
-
| 'q'
|
|
2558
|
-
| 'rb'
|
|
2559
|
-
| 'rp'
|
|
2560
|
-
| 'rt'
|
|
2561
|
-
| 'rtc'
|
|
2562
|
-
| 'ruby'
|
|
2563
|
-
| 's'
|
|
2564
|
-
| 'samp'
|
|
2565
|
-
| 'script'
|
|
2566
|
-
| 'section'
|
|
2567
|
-
| 'select'
|
|
2568
|
-
| 'slot'
|
|
2569
|
-
| 'small'
|
|
2570
|
-
| 'source'
|
|
2571
|
-
| 'span'
|
|
2572
|
-
| 'strong'
|
|
2573
|
-
| 'style'
|
|
2574
|
-
| 'sub'
|
|
2575
|
-
| 'summary'
|
|
2576
|
-
| 'sup'
|
|
2577
|
-
| 'svg'
|
|
2578
|
-
| 'table'
|
|
2579
|
-
| 'tbody'
|
|
2580
|
-
| 'td'
|
|
2581
|
-
| 'template'
|
|
2582
|
-
| 'textarea'
|
|
2583
|
-
| 'tfoot'
|
|
2584
|
-
| 'th'
|
|
2585
|
-
| 'thead'
|
|
2586
|
-
| 'time'
|
|
2587
|
-
| 'title'
|
|
2588
|
-
| 'tr'
|
|
2589
|
-
| 'track'
|
|
2590
|
-
| 'u'
|
|
2591
|
-
| 'ul'
|
|
2592
|
-
| 'var'
|
|
2593
|
-
| 'video'
|
|
2594
|
-
| 'wbr'
|
|
2595
|
-
|
|
2596
|
-
type ElementType = IntrinsicElement | Component
|
|
2597
|
-
|
|
2598
|
-
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2599
|
-
? JSX.IntrinsicElements[T]
|
|
2600
|
-
: T extends Component<infer Props>
|
|
2601
|
-
? Props
|
|
2602
|
-
: never
|
|
2603
|
-
|
|
2604
|
-
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
2605
|
-
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2606
|
-
>
|
|
2485
|
+
type IntrinsicElement = keyof NativeElements
|
|
2486
|
+
type ElementType = IntrinsicElement | Component
|
|
2607
2487
|
|
|
2608
|
-
|
|
2488
|
+
type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2489
|
+
? NativeElements[T]
|
|
2490
|
+
: T extends Component<infer Props>
|
|
2491
|
+
? Props
|
|
2492
|
+
: never
|
|
2609
2493
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
T,
|
|
2614
|
-
RecipeSelection<P>
|
|
2615
|
-
>
|
|
2616
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2617
|
-
}
|
|
2494
|
+
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
2495
|
+
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2496
|
+
>
|
|
2618
2497
|
|
|
2619
|
-
|
|
2498
|
+
type RecipeFn = { __type: any }
|
|
2620
2499
|
|
|
2621
|
-
|
|
2500
|
+
interface JsxFactory {
|
|
2501
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2502
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2503
|
+
T,
|
|
2504
|
+
RecipeSelection<P>
|
|
2505
|
+
>
|
|
2506
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
|
|
2622
2510
|
|
|
2623
|
-
|
|
2511
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2512
|
+
|
|
2513
|
+
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2624
2514
|
`
|
|
2625
2515
|
};
|
|
2626
2516
|
}
|
|
@@ -2636,147 +2526,29 @@ ${ctx.file.importType(upperName, "../types/jsx")}
|
|
|
2636
2526
|
export declare const ${factoryName}: ${upperName}
|
|
2637
2527
|
`,
|
|
2638
2528
|
jsxType: import_outdent38.outdent`
|
|
2639
|
-
import type { Component, FunctionalComponent } from 'vue'
|
|
2640
|
-
|
|
2641
|
-
type IntrinsicElement =
|
|
2642
|
-
| 'a'
|
|
2643
|
-
| 'abbr'
|
|
2644
|
-
| 'address'
|
|
2645
|
-
| 'area'
|
|
2646
|
-
| 'article'
|
|
2647
|
-
| 'aside'
|
|
2648
|
-
| 'audio'
|
|
2649
|
-
| 'b'
|
|
2650
|
-
| 'base'
|
|
2651
|
-
| 'bdi'
|
|
2652
|
-
| 'bdo'
|
|
2653
|
-
| 'blockquote'
|
|
2654
|
-
| 'body'
|
|
2655
|
-
| 'br'
|
|
2656
|
-
| 'button'
|
|
2657
|
-
| 'canvas'
|
|
2658
|
-
| 'caption'
|
|
2659
|
-
| 'cite'
|
|
2660
|
-
| 'code'
|
|
2661
|
-
| 'col'
|
|
2662
|
-
| 'colgroup'
|
|
2663
|
-
| 'data'
|
|
2664
|
-
| 'datalist'
|
|
2665
|
-
| 'dd'
|
|
2666
|
-
| 'del'
|
|
2667
|
-
| 'details'
|
|
2668
|
-
| 'dfn'
|
|
2669
|
-
| 'dialog'
|
|
2670
|
-
| 'div'
|
|
2671
|
-
| 'dl'
|
|
2672
|
-
| 'dt'
|
|
2673
|
-
| 'em'
|
|
2674
|
-
| 'embed'
|
|
2675
|
-
| 'fieldset'
|
|
2676
|
-
| 'figcaption'
|
|
2677
|
-
| 'figure'
|
|
2678
|
-
| 'footer'
|
|
2679
|
-
| 'form'
|
|
2680
|
-
| 'h1'
|
|
2681
|
-
| 'h2'
|
|
2682
|
-
| 'h3'
|
|
2683
|
-
| 'h4'
|
|
2684
|
-
| 'h5'
|
|
2685
|
-
| 'h6'
|
|
2686
|
-
| 'head'
|
|
2687
|
-
| 'header'
|
|
2688
|
-
| 'hgroup'
|
|
2689
|
-
| 'hr'
|
|
2690
|
-
| 'html'
|
|
2691
|
-
| 'i'
|
|
2692
|
-
| 'iframe'
|
|
2693
|
-
| 'img'
|
|
2694
|
-
| 'input'
|
|
2695
|
-
| 'ins'
|
|
2696
|
-
| 'kbd'
|
|
2697
|
-
| 'label'
|
|
2698
|
-
| 'legend'
|
|
2699
|
-
| 'li'
|
|
2700
|
-
| 'link'
|
|
2701
|
-
| 'main'
|
|
2702
|
-
| 'map'
|
|
2703
|
-
| 'mark'
|
|
2704
|
-
| 'math'
|
|
2705
|
-
| 'menu'
|
|
2706
|
-
| 'menuitem'
|
|
2707
|
-
| 'meta'
|
|
2708
|
-
| 'meter'
|
|
2709
|
-
| 'nav'
|
|
2710
|
-
| 'noscript'
|
|
2711
|
-
| 'object'
|
|
2712
|
-
| 'ol'
|
|
2713
|
-
| 'optgroup'
|
|
2714
|
-
| 'option'
|
|
2715
|
-
| 'output'
|
|
2716
|
-
| 'p'
|
|
2717
|
-
| 'param'
|
|
2718
|
-
| 'picture'
|
|
2719
|
-
| 'pre'
|
|
2720
|
-
| 'progress'
|
|
2721
|
-
| 'q'
|
|
2722
|
-
| 'rb'
|
|
2723
|
-
| 'rp'
|
|
2724
|
-
| 'rt'
|
|
2725
|
-
| 'rtc'
|
|
2726
|
-
| 'ruby'
|
|
2727
|
-
| 's'
|
|
2728
|
-
| 'samp'
|
|
2729
|
-
| 'script'
|
|
2730
|
-
| 'section'
|
|
2731
|
-
| 'select'
|
|
2732
|
-
| 'slot'
|
|
2733
|
-
| 'small'
|
|
2734
|
-
| 'source'
|
|
2735
|
-
| 'span'
|
|
2736
|
-
| 'strong'
|
|
2737
|
-
| 'style'
|
|
2738
|
-
| 'sub'
|
|
2739
|
-
| 'summary'
|
|
2740
|
-
| 'sup'
|
|
2741
|
-
| 'svg'
|
|
2742
|
-
| 'table'
|
|
2743
|
-
| 'tbody'
|
|
2744
|
-
| 'td'
|
|
2745
|
-
| 'template'
|
|
2746
|
-
| 'textarea'
|
|
2747
|
-
| 'tfoot'
|
|
2748
|
-
| 'th'
|
|
2749
|
-
| 'thead'
|
|
2750
|
-
| 'time'
|
|
2751
|
-
| 'title'
|
|
2752
|
-
| 'tr'
|
|
2753
|
-
| 'track'
|
|
2754
|
-
| 'u'
|
|
2755
|
-
| 'ul'
|
|
2756
|
-
| 'var'
|
|
2757
|
-
| 'video'
|
|
2758
|
-
| 'wbr'
|
|
2759
|
-
|
|
2760
|
-
type ElementType = IntrinsicElement | Component
|
|
2761
|
-
|
|
2762
|
-
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2763
|
-
? JSX.IntrinsicElements[T]
|
|
2764
|
-
: T extends Component<infer Props>
|
|
2765
|
-
? Props
|
|
2766
|
-
: never
|
|
2767
|
-
|
|
2768
|
-
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2769
|
-
>
|
|
2529
|
+
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2770
2530
|
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
}
|
|
2531
|
+
type IntrinsicElement = keyof NativeElements
|
|
2532
|
+
type ElementType = IntrinsicElement | Component
|
|
2774
2533
|
|
|
2775
|
-
|
|
2534
|
+
type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2535
|
+
? NativeElements[T]
|
|
2536
|
+
: T extends Component<infer Props>
|
|
2537
|
+
? Props
|
|
2538
|
+
: never
|
|
2539
|
+
|
|
2540
|
+
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2541
|
+
>
|
|
2776
2542
|
|
|
2777
|
-
|
|
2543
|
+
interface JsxFactory {
|
|
2544
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
|
|
2548
|
+
|
|
2549
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2778
2550
|
|
|
2779
|
-
|
|
2551
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2780
2552
|
`
|
|
2781
2553
|
};
|
|
2782
2554
|
}
|
|
@@ -2899,7 +2671,7 @@ var composition_d_ts_default = {
|
|
|
2899
2671
|
|
|
2900
2672
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2901
2673
|
var recipe_d_ts_default = {
|
|
2902
|
-
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\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]>\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 type RecipeRuntimeFn<T extends RecipeVariantRecord> = 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\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type 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 | RecipeVariantRecord\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?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype 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 type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & 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 type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {\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 extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type 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 | SlotRecipeVariantRecord<S>\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?: Array<SlotRecipeCompoundVariant<S, 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"
|
|
2674
|
+
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\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]>\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 type RecipeRuntimeFn<T extends RecipeVariantRecord> = 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\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type 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 | RecipeVariantRecord\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?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype 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 type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & 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 type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = 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 extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type 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 | SlotRecipeVariantRecord<S>\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?: Array<SlotRecipeCompoundVariant<S, 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"
|
|
2903
2675
|
};
|
|
2904
2676
|
|
|
2905
2677
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2958,9 +2730,12 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2958
2730
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2959
2731
|
}
|
|
2960
2732
|
`,
|
|
2733
|
+
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
|
|
2961
2734
|
index: import_outdent39.outdent`
|
|
2962
2735
|
import '${ctx.file.extDts("./global")}'
|
|
2963
2736
|
${ctx.file.exportType("ConditionalValue", "./conditions")}
|
|
2737
|
+
${ctx.file.exportType("PatternConfig, PatternProperties", "./pattern")}
|
|
2738
|
+
${ctx.file.exportType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
2964
2739
|
${ctx.file.exportType("GlobalStyleObject, JsxStyleProps, SystemStyleObject", "./system-types")}
|
|
2965
2740
|
|
|
2966
2741
|
`,
|
|
@@ -3005,9 +2780,9 @@ function generatePropTypes(ctx) {
|
|
|
3005
2780
|
${result.join("\n")}
|
|
3006
2781
|
|
|
3007
2782
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
3008
|
-
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2783
|
+
? ConditionalValue<PropertyTypes[T]${strictText}${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
3009
2784
|
: T extends keyof CssProperties
|
|
3010
|
-
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2785
|
+
? ConditionalValue<CssProperties[T]${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
3011
2786
|
: ConditionalValue<string | number>
|
|
3012
2787
|
`;
|
|
3013
2788
|
}
|
|
@@ -3242,12 +3017,12 @@ function setupJsx(ctx) {
|
|
|
3242
3017
|
`,
|
|
3243
3018
|
dts: import_outdent43.default`
|
|
3244
3019
|
${ctx.file.exportTypeStar("./factory")}
|
|
3245
|
-
|
|
3020
|
+
|
|
3246
3021
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3247
|
-
|
|
3022
|
+
|
|
3248
3023
|
${import_outdent43.default.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3249
|
-
|
|
3250
|
-
${ctx.file.exportType(ctx.jsx.typeName, "../types/jsx")}
|
|
3024
|
+
|
|
3025
|
+
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3251
3026
|
`
|
|
3252
3027
|
};
|
|
3253
3028
|
return {
|
|
@@ -3394,7 +3169,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3394
3169
|
});
|
|
3395
3170
|
result2.jsx.forEach((jsx) => {
|
|
3396
3171
|
jsx.data.forEach((data) => {
|
|
3397
|
-
sheet.processStyleProps(data);
|
|
3172
|
+
sheet.processStyleProps(filterProps(ctx, data));
|
|
3398
3173
|
});
|
|
3399
3174
|
});
|
|
3400
3175
|
result2.recipe.forEach((recipeSet, recipeName) => {
|
|
@@ -3406,7 +3181,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3406
3181
|
(0, import_ts_pattern10.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3407
3182
|
recipe.data.forEach((data) => {
|
|
3408
3183
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3409
|
-
sheet.processStyleProps(styleProps);
|
|
3184
|
+
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
3410
3185
|
sheet.processRecipe(recipeName, recipeConfig, recipeProps);
|
|
3411
3186
|
});
|
|
3412
3187
|
}).otherwise(() => {
|
|
@@ -3426,7 +3201,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3426
3201
|
pattern.data.forEach((data) => {
|
|
3427
3202
|
const fnName = patterns.find(jsxName);
|
|
3428
3203
|
const styleProps = patterns.transform(fnName, data);
|
|
3429
|
-
sheet.processStyleProps(styleProps);
|
|
3204
|
+
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
3430
3205
|
});
|
|
3431
3206
|
}).otherwise(() => {
|
|
3432
3207
|
pattern.data.forEach((data) => {
|
|
@@ -3451,6 +3226,15 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3451
3226
|
}
|
|
3452
3227
|
)
|
|
3453
3228
|
);
|
|
3229
|
+
var filterProps = (ctx, props) => {
|
|
3230
|
+
const clone = {};
|
|
3231
|
+
for (const [key, value] of Object.entries(props)) {
|
|
3232
|
+
if (ctx.isValidProperty(key)) {
|
|
3233
|
+
clone[key] = value;
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
return clone;
|
|
3237
|
+
};
|
|
3454
3238
|
|
|
3455
3239
|
// src/engines/base.ts
|
|
3456
3240
|
var import_core5 = require("@pandacss/core");
|
|
@@ -3486,7 +3270,8 @@ var getBaseEngine = (conf) => {
|
|
|
3486
3270
|
tokens,
|
|
3487
3271
|
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3488
3272
|
separator: config.separator,
|
|
3489
|
-
shorthands: config.shorthands
|
|
3273
|
+
shorthands: config.shorthands,
|
|
3274
|
+
strictTokens: config.strictTokens
|
|
3490
3275
|
});
|
|
3491
3276
|
const conditions = new import_core5.Conditions({
|
|
3492
3277
|
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
package/dist/index.mjs
CHANGED
|
@@ -527,7 +527,9 @@ function generateConditions(ctx) {
|
|
|
527
527
|
${ctx.file.importType("AnySelector, Selectors", "./selectors")}
|
|
528
528
|
|
|
529
529
|
export type Conditions = {
|
|
530
|
-
${keys.map(
|
|
530
|
+
${keys.map(
|
|
531
|
+
(key) => ` ${key === "base" ? `/** The base (=no conditions) styles to apply */` : ctx.conditions.get(key) ? `/** \`${ctx.conditions.get(key)}\` */` : ""}${JSON.stringify(key)}: string`
|
|
532
|
+
).join("\n")}
|
|
531
533
|
}
|
|
532
534
|
|
|
533
535
|
export type Condition = keyof Conditions
|
|
@@ -598,8 +600,8 @@ function generateCssFn(ctx) {
|
|
|
598
600
|
${ctx.file.importType("SystemStyleObject", "../types/index")}
|
|
599
601
|
|
|
600
602
|
interface CssFunction {
|
|
601
|
-
(...styles: SystemStyleObject
|
|
602
|
-
raw: (styles: SystemStyleObject) => SystemStyleObject
|
|
603
|
+
(...styles: Array<SystemStyleObject | undefined | null | false>): string
|
|
604
|
+
raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
|
|
603
605
|
}
|
|
604
606
|
|
|
605
607
|
export declare const css: CssFunction;
|
|
@@ -666,7 +668,7 @@ function generateCssFn(ctx) {
|
|
|
666
668
|
|
|
667
669
|
const cssFn = createCss(context)
|
|
668
670
|
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
669
|
-
css.raw = (styles) => styles
|
|
671
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
670
672
|
|
|
671
673
|
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
672
674
|
`
|
|
@@ -784,7 +786,7 @@ function generateCvaFn(ctx) {
|
|
|
784
786
|
}
|
|
785
787
|
|
|
786
788
|
export function assertCompoundVariant(name, compoundVariants, variants, prop) {
|
|
787
|
-
if (compoundVariants.length > 0 && typeof variants[prop] === 'object') {
|
|
789
|
+
if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
|
|
788
790
|
throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
|
|
789
791
|
}
|
|
790
792
|
}
|
|
@@ -835,7 +837,7 @@ import { outdent as outdent8 } from "outdent";
|
|
|
835
837
|
|
|
836
838
|
// src/artifacts/generated/helpers.mjs.json
|
|
837
839
|
var helpers_mjs_default = {
|
|
838
|
-
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 result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\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
|
|
840
|
+
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 result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\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 recipeParts = recipe.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}\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 walkObject,\n withoutSpace\n};\n'
|
|
839
841
|
};
|
|
840
842
|
|
|
841
843
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -955,7 +957,7 @@ function generatePattern(ctx) {
|
|
|
955
957
|
|
|
956
958
|
interface ${upperName}PatternFn {
|
|
957
959
|
(styles?: ${upperName}Styles): string
|
|
958
|
-
raw: (styles
|
|
960
|
+
raw: (styles?: ${upperName}Styles) => SystemStyleObject
|
|
959
961
|
}
|
|
960
962
|
|
|
961
963
|
${description ? `/** ${description} */` : ""}
|
|
@@ -1144,12 +1146,17 @@ function generateSvaFn(ctx) {
|
|
|
1144
1146
|
|
|
1145
1147
|
export function sva(config) {
|
|
1146
1148
|
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1147
|
-
|
|
1149
|
+
|
|
1148
1150
|
function svaFn(props) {
|
|
1149
1151
|
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1150
1152
|
return Object.fromEntries(result)
|
|
1151
1153
|
}
|
|
1152
1154
|
|
|
1155
|
+
function raw(props) {
|
|
1156
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
|
|
1157
|
+
return Object.fromEntries(result)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1153
1160
|
const variants = config.variants ?? {};
|
|
1154
1161
|
const variantKeys = Object.keys(variants);
|
|
1155
1162
|
|
|
@@ -1163,6 +1170,7 @@ function generateSvaFn(ctx) {
|
|
|
1163
1170
|
|
|
1164
1171
|
return Object.assign(svaFn, {
|
|
1165
1172
|
__cva__: false,
|
|
1173
|
+
raw,
|
|
1166
1174
|
variantMap,
|
|
1167
1175
|
variantKeys,
|
|
1168
1176
|
splitVariantProps,
|
|
@@ -2438,158 +2446,40 @@ ${ctx.file.importType(upperName, "../types/jsx")}
|
|
|
2438
2446
|
export declare const ${factoryName}: ${upperName}
|
|
2439
2447
|
`,
|
|
2440
2448
|
jsxType: outdent37`
|
|
2441
|
-
import type { Component, FunctionalComponent } from 'vue'
|
|
2449
|
+
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2442
2450
|
|
|
2443
2451
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2444
2452
|
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
2445
2453
|
|
|
2446
|
-
type IntrinsicElement =
|
|
2447
|
-
|
|
2448
|
-
| 'abbr'
|
|
2449
|
-
| 'address'
|
|
2450
|
-
| 'area'
|
|
2451
|
-
| 'article'
|
|
2452
|
-
| 'aside'
|
|
2453
|
-
| 'audio'
|
|
2454
|
-
| 'b'
|
|
2455
|
-
| 'base'
|
|
2456
|
-
| 'bdi'
|
|
2457
|
-
| 'bdo'
|
|
2458
|
-
| 'blockquote'
|
|
2459
|
-
| 'body'
|
|
2460
|
-
| 'br'
|
|
2461
|
-
| 'button'
|
|
2462
|
-
| 'canvas'
|
|
2463
|
-
| 'caption'
|
|
2464
|
-
| 'cite'
|
|
2465
|
-
| 'code'
|
|
2466
|
-
| 'col'
|
|
2467
|
-
| 'colgroup'
|
|
2468
|
-
| 'data'
|
|
2469
|
-
| 'datalist'
|
|
2470
|
-
| 'dd'
|
|
2471
|
-
| 'del'
|
|
2472
|
-
| 'details'
|
|
2473
|
-
| 'dfn'
|
|
2474
|
-
| 'dialog'
|
|
2475
|
-
| 'div'
|
|
2476
|
-
| 'dl'
|
|
2477
|
-
| 'dt'
|
|
2478
|
-
| 'em'
|
|
2479
|
-
| 'embed'
|
|
2480
|
-
| 'fieldset'
|
|
2481
|
-
| 'figcaption'
|
|
2482
|
-
| 'figure'
|
|
2483
|
-
| 'footer'
|
|
2484
|
-
| 'form'
|
|
2485
|
-
| 'h1'
|
|
2486
|
-
| 'h2'
|
|
2487
|
-
| 'h3'
|
|
2488
|
-
| 'h4'
|
|
2489
|
-
| 'h5'
|
|
2490
|
-
| 'h6'
|
|
2491
|
-
| 'head'
|
|
2492
|
-
| 'header'
|
|
2493
|
-
| 'hgroup'
|
|
2494
|
-
| 'hr'
|
|
2495
|
-
| 'html'
|
|
2496
|
-
| 'i'
|
|
2497
|
-
| 'iframe'
|
|
2498
|
-
| 'img'
|
|
2499
|
-
| 'input'
|
|
2500
|
-
| 'ins'
|
|
2501
|
-
| 'kbd'
|
|
2502
|
-
| 'label'
|
|
2503
|
-
| 'legend'
|
|
2504
|
-
| 'li'
|
|
2505
|
-
| 'link'
|
|
2506
|
-
| 'main'
|
|
2507
|
-
| 'map'
|
|
2508
|
-
| 'mark'
|
|
2509
|
-
| 'math'
|
|
2510
|
-
| 'menu'
|
|
2511
|
-
| 'menuitem'
|
|
2512
|
-
| 'meta'
|
|
2513
|
-
| 'meter'
|
|
2514
|
-
| 'nav'
|
|
2515
|
-
| 'noscript'
|
|
2516
|
-
| 'object'
|
|
2517
|
-
| 'ol'
|
|
2518
|
-
| 'optgroup'
|
|
2519
|
-
| 'option'
|
|
2520
|
-
| 'output'
|
|
2521
|
-
| 'p'
|
|
2522
|
-
| 'param'
|
|
2523
|
-
| 'picture'
|
|
2524
|
-
| 'pre'
|
|
2525
|
-
| 'progress'
|
|
2526
|
-
| 'q'
|
|
2527
|
-
| 'rb'
|
|
2528
|
-
| 'rp'
|
|
2529
|
-
| 'rt'
|
|
2530
|
-
| 'rtc'
|
|
2531
|
-
| 'ruby'
|
|
2532
|
-
| 's'
|
|
2533
|
-
| 'samp'
|
|
2534
|
-
| 'script'
|
|
2535
|
-
| 'section'
|
|
2536
|
-
| 'select'
|
|
2537
|
-
| 'slot'
|
|
2538
|
-
| 'small'
|
|
2539
|
-
| 'source'
|
|
2540
|
-
| 'span'
|
|
2541
|
-
| 'strong'
|
|
2542
|
-
| 'style'
|
|
2543
|
-
| 'sub'
|
|
2544
|
-
| 'summary'
|
|
2545
|
-
| 'sup'
|
|
2546
|
-
| 'svg'
|
|
2547
|
-
| 'table'
|
|
2548
|
-
| 'tbody'
|
|
2549
|
-
| 'td'
|
|
2550
|
-
| 'template'
|
|
2551
|
-
| 'textarea'
|
|
2552
|
-
| 'tfoot'
|
|
2553
|
-
| 'th'
|
|
2554
|
-
| 'thead'
|
|
2555
|
-
| 'time'
|
|
2556
|
-
| 'title'
|
|
2557
|
-
| 'tr'
|
|
2558
|
-
| 'track'
|
|
2559
|
-
| 'u'
|
|
2560
|
-
| 'ul'
|
|
2561
|
-
| 'var'
|
|
2562
|
-
| 'video'
|
|
2563
|
-
| 'wbr'
|
|
2564
|
-
|
|
2565
|
-
type ElementType = IntrinsicElement | Component
|
|
2566
|
-
|
|
2567
|
-
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2568
|
-
? JSX.IntrinsicElements[T]
|
|
2569
|
-
: T extends Component<infer Props>
|
|
2570
|
-
? Props
|
|
2571
|
-
: never
|
|
2572
|
-
|
|
2573
|
-
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
2574
|
-
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2575
|
-
>
|
|
2454
|
+
type IntrinsicElement = keyof NativeElements
|
|
2455
|
+
type ElementType = IntrinsicElement | Component
|
|
2576
2456
|
|
|
2577
|
-
|
|
2457
|
+
type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2458
|
+
? NativeElements[T]
|
|
2459
|
+
: T extends Component<infer Props>
|
|
2460
|
+
? Props
|
|
2461
|
+
: never
|
|
2578
2462
|
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
T,
|
|
2583
|
-
RecipeSelection<P>
|
|
2584
|
-
>
|
|
2585
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2586
|
-
}
|
|
2463
|
+
type ${componentName}<T extends ElementType, P extends Dict = {}> = FunctionalComponent<
|
|
2464
|
+
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2465
|
+
>
|
|
2587
2466
|
|
|
2588
|
-
|
|
2467
|
+
type RecipeFn = { __type: any }
|
|
2589
2468
|
|
|
2590
|
-
|
|
2469
|
+
interface JsxFactory {
|
|
2470
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2471
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2472
|
+
T,
|
|
2473
|
+
RecipeSelection<P>
|
|
2474
|
+
>
|
|
2475
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K, {}> }
|
|
2591
2479
|
|
|
2592
|
-
|
|
2480
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2481
|
+
|
|
2482
|
+
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2593
2483
|
`
|
|
2594
2484
|
};
|
|
2595
2485
|
}
|
|
@@ -2605,147 +2495,29 @@ ${ctx.file.importType(upperName, "../types/jsx")}
|
|
|
2605
2495
|
export declare const ${factoryName}: ${upperName}
|
|
2606
2496
|
`,
|
|
2607
2497
|
jsxType: outdent38`
|
|
2608
|
-
import type { Component, FunctionalComponent } from 'vue'
|
|
2609
|
-
|
|
2610
|
-
type IntrinsicElement =
|
|
2611
|
-
| 'a'
|
|
2612
|
-
| 'abbr'
|
|
2613
|
-
| 'address'
|
|
2614
|
-
| 'area'
|
|
2615
|
-
| 'article'
|
|
2616
|
-
| 'aside'
|
|
2617
|
-
| 'audio'
|
|
2618
|
-
| 'b'
|
|
2619
|
-
| 'base'
|
|
2620
|
-
| 'bdi'
|
|
2621
|
-
| 'bdo'
|
|
2622
|
-
| 'blockquote'
|
|
2623
|
-
| 'body'
|
|
2624
|
-
| 'br'
|
|
2625
|
-
| 'button'
|
|
2626
|
-
| 'canvas'
|
|
2627
|
-
| 'caption'
|
|
2628
|
-
| 'cite'
|
|
2629
|
-
| 'code'
|
|
2630
|
-
| 'col'
|
|
2631
|
-
| 'colgroup'
|
|
2632
|
-
| 'data'
|
|
2633
|
-
| 'datalist'
|
|
2634
|
-
| 'dd'
|
|
2635
|
-
| 'del'
|
|
2636
|
-
| 'details'
|
|
2637
|
-
| 'dfn'
|
|
2638
|
-
| 'dialog'
|
|
2639
|
-
| 'div'
|
|
2640
|
-
| 'dl'
|
|
2641
|
-
| 'dt'
|
|
2642
|
-
| 'em'
|
|
2643
|
-
| 'embed'
|
|
2644
|
-
| 'fieldset'
|
|
2645
|
-
| 'figcaption'
|
|
2646
|
-
| 'figure'
|
|
2647
|
-
| 'footer'
|
|
2648
|
-
| 'form'
|
|
2649
|
-
| 'h1'
|
|
2650
|
-
| 'h2'
|
|
2651
|
-
| 'h3'
|
|
2652
|
-
| 'h4'
|
|
2653
|
-
| 'h5'
|
|
2654
|
-
| 'h6'
|
|
2655
|
-
| 'head'
|
|
2656
|
-
| 'header'
|
|
2657
|
-
| 'hgroup'
|
|
2658
|
-
| 'hr'
|
|
2659
|
-
| 'html'
|
|
2660
|
-
| 'i'
|
|
2661
|
-
| 'iframe'
|
|
2662
|
-
| 'img'
|
|
2663
|
-
| 'input'
|
|
2664
|
-
| 'ins'
|
|
2665
|
-
| 'kbd'
|
|
2666
|
-
| 'label'
|
|
2667
|
-
| 'legend'
|
|
2668
|
-
| 'li'
|
|
2669
|
-
| 'link'
|
|
2670
|
-
| 'main'
|
|
2671
|
-
| 'map'
|
|
2672
|
-
| 'mark'
|
|
2673
|
-
| 'math'
|
|
2674
|
-
| 'menu'
|
|
2675
|
-
| 'menuitem'
|
|
2676
|
-
| 'meta'
|
|
2677
|
-
| 'meter'
|
|
2678
|
-
| 'nav'
|
|
2679
|
-
| 'noscript'
|
|
2680
|
-
| 'object'
|
|
2681
|
-
| 'ol'
|
|
2682
|
-
| 'optgroup'
|
|
2683
|
-
| 'option'
|
|
2684
|
-
| 'output'
|
|
2685
|
-
| 'p'
|
|
2686
|
-
| 'param'
|
|
2687
|
-
| 'picture'
|
|
2688
|
-
| 'pre'
|
|
2689
|
-
| 'progress'
|
|
2690
|
-
| 'q'
|
|
2691
|
-
| 'rb'
|
|
2692
|
-
| 'rp'
|
|
2693
|
-
| 'rt'
|
|
2694
|
-
| 'rtc'
|
|
2695
|
-
| 'ruby'
|
|
2696
|
-
| 's'
|
|
2697
|
-
| 'samp'
|
|
2698
|
-
| 'script'
|
|
2699
|
-
| 'section'
|
|
2700
|
-
| 'select'
|
|
2701
|
-
| 'slot'
|
|
2702
|
-
| 'small'
|
|
2703
|
-
| 'source'
|
|
2704
|
-
| 'span'
|
|
2705
|
-
| 'strong'
|
|
2706
|
-
| 'style'
|
|
2707
|
-
| 'sub'
|
|
2708
|
-
| 'summary'
|
|
2709
|
-
| 'sup'
|
|
2710
|
-
| 'svg'
|
|
2711
|
-
| 'table'
|
|
2712
|
-
| 'tbody'
|
|
2713
|
-
| 'td'
|
|
2714
|
-
| 'template'
|
|
2715
|
-
| 'textarea'
|
|
2716
|
-
| 'tfoot'
|
|
2717
|
-
| 'th'
|
|
2718
|
-
| 'thead'
|
|
2719
|
-
| 'time'
|
|
2720
|
-
| 'title'
|
|
2721
|
-
| 'tr'
|
|
2722
|
-
| 'track'
|
|
2723
|
-
| 'u'
|
|
2724
|
-
| 'ul'
|
|
2725
|
-
| 'var'
|
|
2726
|
-
| 'video'
|
|
2727
|
-
| 'wbr'
|
|
2728
|
-
|
|
2729
|
-
type ElementType = IntrinsicElement | Component
|
|
2730
|
-
|
|
2731
|
-
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2732
|
-
? JSX.IntrinsicElements[T]
|
|
2733
|
-
: T extends Component<infer Props>
|
|
2734
|
-
? Props
|
|
2735
|
-
: never
|
|
2736
|
-
|
|
2737
|
-
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2738
|
-
>
|
|
2498
|
+
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2739
2499
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
}
|
|
2500
|
+
type IntrinsicElement = keyof NativeElements
|
|
2501
|
+
type ElementType = IntrinsicElement | Component
|
|
2743
2502
|
|
|
2744
|
-
|
|
2503
|
+
type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2504
|
+
? NativeElements[T]
|
|
2505
|
+
: T extends Component<infer Props>
|
|
2506
|
+
? Props
|
|
2507
|
+
: never
|
|
2508
|
+
|
|
2509
|
+
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2510
|
+
>
|
|
2745
2511
|
|
|
2746
|
-
|
|
2512
|
+
interface JsxFactory {
|
|
2513
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
type JsxElements = { [K in IntrinsicElement]: ${componentName}<K> }
|
|
2517
|
+
|
|
2518
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2747
2519
|
|
|
2748
|
-
|
|
2520
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2749
2521
|
`
|
|
2750
2522
|
};
|
|
2751
2523
|
}
|
|
@@ -2868,7 +2640,7 @@ var composition_d_ts_default = {
|
|
|
2868
2640
|
|
|
2869
2641
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2870
2642
|
var recipe_d_ts_default = {
|
|
2871
|
-
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\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]>\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 type RecipeRuntimeFn<T extends RecipeVariantRecord> = 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\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type 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 | RecipeVariantRecord\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?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype 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 type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & 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 type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {\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 extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type 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 | SlotRecipeVariantRecord<S>\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?: Array<SlotRecipeCompoundVariant<S, 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"
|
|
2643
|
+
content: "import type { SystemStyleObject, DistributiveOmit } from './system-types'\n\ntype Pretty<T> = { [K in keyof T]: T[K] } & {}\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]>\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 type RecipeRuntimeFn<T extends RecipeVariantRecord> = 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\nexport type RecipeCompoundSelection<T extends RecipeVariantRecord> = {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | Array<StringToBoolean<keyof T[K]>>\n}\n\nexport type RecipeCompoundVariant<T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SystemStyleObject\n}\n\nexport type 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 | RecipeVariantRecord\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?: Array<RecipeCompoundVariant<T>>\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ntype 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 type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & 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 type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = 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 extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport type 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 | SlotRecipeVariantRecord<S>\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?: Array<SlotRecipeCompoundVariant<S, 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"
|
|
2872
2644
|
};
|
|
2873
2645
|
|
|
2874
2646
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2927,9 +2699,12 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2927
2699
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2928
2700
|
}
|
|
2929
2701
|
`,
|
|
2702
|
+
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
|
|
2930
2703
|
index: outdent39`
|
|
2931
2704
|
import '${ctx.file.extDts("./global")}'
|
|
2932
2705
|
${ctx.file.exportType("ConditionalValue", "./conditions")}
|
|
2706
|
+
${ctx.file.exportType("PatternConfig, PatternProperties", "./pattern")}
|
|
2707
|
+
${ctx.file.exportType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
2933
2708
|
${ctx.file.exportType("GlobalStyleObject, JsxStyleProps, SystemStyleObject", "./system-types")}
|
|
2934
2709
|
|
|
2935
2710
|
`,
|
|
@@ -2974,9 +2749,9 @@ function generatePropTypes(ctx) {
|
|
|
2974
2749
|
${result.join("\n")}
|
|
2975
2750
|
|
|
2976
2751
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2977
|
-
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2752
|
+
? ConditionalValue<PropertyTypes[T]${strictText}${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
2978
2753
|
: T extends keyof CssProperties
|
|
2979
|
-
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2754
|
+
? ConditionalValue<CssProperties[T]${!ctx.config.strictTokens ? " | (string & {})" : ""}>
|
|
2980
2755
|
: ConditionalValue<string | number>
|
|
2981
2756
|
`;
|
|
2982
2757
|
}
|
|
@@ -3211,12 +2986,12 @@ function setupJsx(ctx) {
|
|
|
3211
2986
|
`,
|
|
3212
2987
|
dts: outdent43`
|
|
3213
2988
|
${ctx.file.exportTypeStar("./factory")}
|
|
3214
|
-
|
|
2989
|
+
|
|
3215
2990
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3216
|
-
|
|
2991
|
+
|
|
3217
2992
|
${outdent43.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3218
|
-
|
|
3219
|
-
${ctx.file.exportType(ctx.jsx.typeName, "../types/jsx")}
|
|
2993
|
+
|
|
2994
|
+
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3220
2995
|
`
|
|
3221
2996
|
};
|
|
3222
2997
|
return {
|
|
@@ -3363,7 +3138,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3363
3138
|
});
|
|
3364
3139
|
result2.jsx.forEach((jsx) => {
|
|
3365
3140
|
jsx.data.forEach((data) => {
|
|
3366
|
-
sheet.processStyleProps(data);
|
|
3141
|
+
sheet.processStyleProps(filterProps(ctx, data));
|
|
3367
3142
|
});
|
|
3368
3143
|
});
|
|
3369
3144
|
result2.recipe.forEach((recipeSet, recipeName) => {
|
|
@@ -3375,7 +3150,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3375
3150
|
match10(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3376
3151
|
recipe.data.forEach((data) => {
|
|
3377
3152
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3378
|
-
sheet.processStyleProps(styleProps);
|
|
3153
|
+
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
3379
3154
|
sheet.processRecipe(recipeName, recipeConfig, recipeProps);
|
|
3380
3155
|
});
|
|
3381
3156
|
}).otherwise(() => {
|
|
@@ -3395,7 +3170,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3395
3170
|
pattern.data.forEach((data) => {
|
|
3396
3171
|
const fnName = patterns.find(jsxName);
|
|
3397
3172
|
const styleProps = patterns.transform(fnName, data);
|
|
3398
|
-
sheet.processStyleProps(styleProps);
|
|
3173
|
+
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
3399
3174
|
});
|
|
3400
3175
|
}).otherwise(() => {
|
|
3401
3176
|
pattern.data.forEach((data) => {
|
|
@@ -3420,6 +3195,15 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3420
3195
|
}
|
|
3421
3196
|
)
|
|
3422
3197
|
);
|
|
3198
|
+
var filterProps = (ctx, props) => {
|
|
3199
|
+
const clone = {};
|
|
3200
|
+
for (const [key, value] of Object.entries(props)) {
|
|
3201
|
+
if (ctx.isValidProperty(key)) {
|
|
3202
|
+
clone[key] = value;
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
return clone;
|
|
3206
|
+
};
|
|
3423
3207
|
|
|
3424
3208
|
// src/engines/base.ts
|
|
3425
3209
|
import {
|
|
@@ -3461,7 +3245,8 @@ var getBaseEngine = (conf) => {
|
|
|
3461
3245
|
tokens,
|
|
3462
3246
|
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3463
3247
|
separator: config.separator,
|
|
3464
|
-
shorthands: config.shorthands
|
|
3248
|
+
shorthands: config.shorthands,
|
|
3249
|
+
strictTokens: config.strictTokens
|
|
3465
3250
|
});
|
|
3466
3251
|
const conditions = new Conditions({
|
|
3467
3252
|
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"pluralize": "8.0.0",
|
|
21
21
|
"postcss": "8.4.27",
|
|
22
22
|
"ts-pattern": "5.0.4",
|
|
23
|
-
"@pandacss/core": "0.
|
|
24
|
-
"@pandacss/is-valid-prop": "0.
|
|
25
|
-
"@pandacss/logger": "0.
|
|
26
|
-
"@pandacss/shared": "0.
|
|
27
|
-
"@pandacss/
|
|
28
|
-
"@pandacss/
|
|
23
|
+
"@pandacss/core": "0.15.0",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.15.0",
|
|
25
|
+
"@pandacss/logger": "0.15.0",
|
|
26
|
+
"@pandacss/shared": "0.15.0",
|
|
27
|
+
"@pandacss/token-dictionary": "0.15.0",
|
|
28
|
+
"@pandacss/types": "0.15.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.30",
|
|
32
32
|
"hookable": "5.5.3",
|
|
33
|
-
"@pandacss/fixture": "0.
|
|
33
|
+
"@pandacss/fixture": "0.15.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|