@pandacss/generator 0.9.0 → 0.10.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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +483 -315
- package/dist/index.mjs +480 -312
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -99,7 +99,7 @@ var getMessages = (ctx) => ({
|
|
|
99
99
|
|
|
100
100
|
// src/artifacts/index.ts
|
|
101
101
|
import { isObject } from "@pandacss/shared";
|
|
102
|
-
import
|
|
102
|
+
import outdent43 from "outdent";
|
|
103
103
|
|
|
104
104
|
// src/artifacts/css/global-css.ts
|
|
105
105
|
var generateGlobalCss = (ctx) => {
|
|
@@ -388,7 +388,10 @@ var generateStaticCss = (ctx) => {
|
|
|
388
388
|
return [];
|
|
389
389
|
return Object.keys(values);
|
|
390
390
|
},
|
|
391
|
-
getRecipeKeys: (recipe) =>
|
|
391
|
+
getRecipeKeys: (recipe) => {
|
|
392
|
+
const recipeConfig = recipes.details.find((detail) => detail.baseName === recipe);
|
|
393
|
+
return Object.assign({ __base: recipeConfig?.config.base }, recipeConfig?.variantKeyMap ?? {});
|
|
394
|
+
}
|
|
392
395
|
});
|
|
393
396
|
results.css.forEach((css2) => {
|
|
394
397
|
sheet.processAtomic(css2);
|
|
@@ -487,14 +490,15 @@ function generateConditions(ctx) {
|
|
|
487
490
|
js: outdent2`
|
|
488
491
|
${ctx.file.import("withoutSpace", "../helpers")}
|
|
489
492
|
|
|
490
|
-
const
|
|
493
|
+
const conditionsStr = "${keys.join(",")}"
|
|
494
|
+
const conditions = new Set(conditionsStr.split(','))
|
|
491
495
|
|
|
492
496
|
export function isCondition(value){
|
|
493
497
|
return conditions.has(value) || /^@|&|&$/.test(value)
|
|
494
498
|
}
|
|
495
499
|
|
|
496
500
|
const underscoreRegex = /^_/
|
|
497
|
-
const
|
|
501
|
+
const conditionsSelectorRegex = /&|@/
|
|
498
502
|
|
|
499
503
|
export function finalizeConditions(paths){
|
|
500
504
|
return paths.map((path) => {
|
|
@@ -502,7 +506,7 @@ function generateConditions(ctx) {
|
|
|
502
506
|
return path.replace(underscoreRegex, '')
|
|
503
507
|
}
|
|
504
508
|
|
|
505
|
-
if (
|
|
509
|
+
if (conditionsSelectorRegex.test(path)){
|
|
506
510
|
return \`[\${withoutSpace(path.trim())}]\`
|
|
507
511
|
}
|
|
508
512
|
|
|
@@ -582,7 +586,6 @@ function generateStringLiteralConditions(ctx) {
|
|
|
582
586
|
|
|
583
587
|
// src/artifacts/js/css-fn.ts
|
|
584
588
|
import { outdent as outdent4 } from "outdent";
|
|
585
|
-
var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
|
|
586
589
|
function generateCssFn(ctx) {
|
|
587
590
|
const {
|
|
588
591
|
utility,
|
|
@@ -590,6 +593,10 @@ function generateCssFn(ctx) {
|
|
|
590
593
|
conditions
|
|
591
594
|
} = ctx;
|
|
592
595
|
const { separator } = utility;
|
|
596
|
+
const shorthandsByProp = Array.from(utility.shorthands.entries()).reduce((acc, [shorthand, prop]) => {
|
|
597
|
+
acc[prop] = shorthand;
|
|
598
|
+
return acc;
|
|
599
|
+
}, {});
|
|
593
600
|
return {
|
|
594
601
|
dts: outdent4`
|
|
595
602
|
import type { SystemStyleObject } from '../types'
|
|
@@ -605,35 +612,45 @@ function generateCssFn(ctx) {
|
|
|
605
612
|
${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
606
613
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
607
614
|
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
+
const utilities = "${utility.entries().map(([prop, className]) => {
|
|
616
|
+
const shorthand = shorthandsByProp[prop];
|
|
617
|
+
return [prop, shorthand ? [className, shorthand === className ? 1 : shorthand].join("/") : className].join(":");
|
|
618
|
+
}).join(",")}"
|
|
619
|
+
|
|
620
|
+
const classMap = {}
|
|
621
|
+
${utility.hasShorthand ? outdent4`
|
|
622
|
+
const shorthands = {}
|
|
623
|
+
utilities.split(',').forEach((utility) => {
|
|
624
|
+
const [prop, meta] = utility.split(':')
|
|
625
|
+
const [className, shorthand] = meta.split('/')
|
|
626
|
+
classMap[prop] = className
|
|
627
|
+
if (shorthand) shorthands[shorthand === '1' ? className : shorthand] = prop
|
|
628
|
+
})
|
|
615
629
|
|
|
616
630
|
const resolveShorthand = (prop) => shorthands[prop] || prop
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
631
|
+
` : outdent4`
|
|
632
|
+
utilities.split(',').forEach((utility) => {
|
|
633
|
+
const [prop, className] = utility.split(':')
|
|
634
|
+
classMap[prop] = className
|
|
635
|
+
})
|
|
636
|
+
`}
|
|
624
637
|
|
|
625
638
|
const context = {
|
|
626
|
-
|
|
639
|
+
${hash ? "hash: true," : ""}
|
|
627
640
|
conditions: {
|
|
628
641
|
shift: sortConditions,
|
|
629
642
|
finalize: finalizeConditions,
|
|
630
|
-
breakpoints: { keys:
|
|
643
|
+
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
631
644
|
},
|
|
632
645
|
utility: {
|
|
633
|
-
|
|
634
|
-
transform,
|
|
635
|
-
|
|
636
|
-
|
|
646
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
647
|
+
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
648
|
+
const key = resolveShorthand(prop)
|
|
649
|
+
const propKey = classMap[key] || hypenateProperty(key)
|
|
650
|
+
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
651
|
+
}` : `(key, value) => ({ className: \`\${classMap[key] || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
652
|
+
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
653
|
+
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
637
654
|
}
|
|
638
655
|
}
|
|
639
656
|
|
|
@@ -808,20 +825,33 @@ import { outdent as outdent8 } from "outdent";
|
|
|
808
825
|
|
|
809
826
|
// src/artifacts/generated/helpers.mjs.json
|
|
810
827
|
var helpers_mjs_default = {
|
|
811
|
-
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/
|
|
828
|
+
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 assign = (obj, path, value) => {\n const last = path.pop();\n const target = path.reduce((acc, key) => {\n if (acc[key] == null)\n acc[key] = {};\n return acc[key];\n }, obj);\n if (last != null)\n target[last] = value;\n};\nvar getSlotRecipes = (recipe) => {\n const parts = recipe.slots.map((slot) => [\n slot,\n // setup base recipe\n {\n // create class-base on BEM\n className: [recipe.className ?? "", slot].join("__"),\n base: {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: []\n }\n ]).map(([slot, cva]) => {\n const base = recipe.base[slot];\n if (base)\n cva.base = base;\n walkObject(\n recipe.variants ?? {},\n (variant, path) => {\n if (!variant[slot])\n return;\n assign(cva, ["variants", ...path], variant[slot]);\n },\n {\n stop: (_value, path) => path.includes(slot)\n }\n );\n if (recipe.compoundVariants) {\n cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);\n }\n return [slot, cva];\n });\n return Object.fromEntries(parts);\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'
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// src/artifacts/generated/astish.mjs.json
|
|
832
|
+
var astish_mjs_default = {
|
|
833
|
+
content: '// src/astish.ts\nvar newRule = /(?:([\\u0080-\\uFFFF\\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\\s*)/g;\nvar ruleClean = /\\/\\*[^]*?\\*\\/|\\s\\s+|\\n/g;\nvar astish = (val, tree = [{}]) => {\n const block = newRule.exec((val ?? "").replace(ruleClean, ""));\n if (!block)\n return tree[0];\n if (block[4])\n tree.shift();\n else if (block[3])\n tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});\n else\n tree[0][block[1]] = block[2];\n return astish(val, tree);\n};\nexport {\n astish\n};\n'
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
// src/artifacts/generated/normalize-html.mjs.json
|
|
837
|
+
var normalize_html_mjs_default = {
|
|
838
|
+
content: '// src/normalize-html.ts\nvar htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];\nfunction convert(key) {\n return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;\n}\nfunction normalizeHTMLProps(props) {\n return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));\n}\nnormalizeHTMLProps.keys = htmlProps;\nexport {\n normalizeHTMLProps\n};\n'
|
|
812
839
|
};
|
|
813
840
|
|
|
814
841
|
// src/artifacts/js/helpers.ts
|
|
815
|
-
function generateHelpers() {
|
|
842
|
+
function generateHelpers(ctx) {
|
|
816
843
|
return {
|
|
817
844
|
js: outdent8`
|
|
818
845
|
${helpers_mjs_default.content}
|
|
846
|
+
${ctx.isTemplateLiteralSyntax ? astish_mjs_default.content : ""}
|
|
847
|
+
|
|
848
|
+
${ctx.jsx.framework ? `${normalize_html_mjs_default.content}` : ""}
|
|
819
849
|
|
|
820
|
-
export function __spreadValues(a, b){
|
|
850
|
+
export function __spreadValues(a, b) {
|
|
821
851
|
return { ...a, ...b }
|
|
822
852
|
}
|
|
823
853
|
|
|
824
|
-
export function __objRest(source, exclude){
|
|
854
|
+
export function __objRest(source, exclude) {
|
|
825
855
|
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
826
856
|
}
|
|
827
857
|
`
|
|
@@ -830,19 +860,29 @@ function generateHelpers() {
|
|
|
830
860
|
|
|
831
861
|
// src/artifacts/generated/is-valid-prop.mjs.json
|
|
832
862
|
var is_valid_prop_mjs_default = {
|
|
833
|
-
content: '// src/index.ts\nvar userGenerated = [];\nvar allCssProperties = [\n "MsAccelerator",\n "MsBlockProgression",\n "MsContentZoomChaining",\n "MsContentZooming",\n "MsContentZoomLimit",\n "MsContentZoomLimitMax",\n "MsContentZoomLimitMin",\n "MsContentZoomSnap",\n "MsContentZoomSnapPoints",\n "MsContentZoomSnapType",\n "MsFilter",\n "MsFlowFrom",\n "MsFlowInto",\n "MsGridColumns",\n "MsGridRows",\n "MsHighContrastAdjust",\n "MsHyphenateLimitChars",\n "MsHyphenateLimitLines",\n "MsHyphenateLimitZone",\n "MsImeAlign",\n "MsOverflowStyle",\n "MsScrollbar3dlightColor",\n "MsScrollbarArrowColor",\n "MsScrollbarBaseColor",\n "MsScrollbarDarkshadowColor",\n "MsScrollbarFaceColor",\n "MsScrollbarHighlightColor",\n "MsScrollbarShadowColor",\n "MsScrollbarTrackColor",\n "MsScrollChaining",\n "MsScrollLimit",\n "MsScrollLimitXMax",\n "MsScrollLimitXMin",\n "MsScrollLimitYMax",\n "MsScrollLimitYMin",\n "MsScrollRails",\n "MsScrollSnapPointsX",\n "MsScrollSnapPointsY",\n "MsScrollSnapType",\n "MsScrollSnapX",\n "MsScrollSnapY",\n "MsScrollTranslation",\n "MsTextAutospace",\n "MsTouchSelect",\n "MsUserSelect",\n "MsWrapFlow",\n "MsWrapMargin",\n "MsWrapThrough",\n "MozAppearance",\n "MozBinding",\n "MozBorderBottomColors",\n "MozBorderLeftColors",\n "MozBorderRightColors",\n "MozBorderTopColors",\n "MozContextProperties",\n "MozFloatEdge",\n "MozForceBrokenImageIcon",\n "MozImageRegion",\n "MozOrient",\n "MozOutlineRadius",\n "MozOutlineRadiusBottomleft",\n "MozOutlineRadiusBottomright",\n "MozOutlineRadiusTopleft",\n "MozOutlineRadiusTopright",\n "MozStackSizing",\n "MozTextBlink",\n "MozUserFocus",\n "MozUserInput",\n "MozUserModify",\n "MozWindowDragging",\n "MozWindowShadow",\n "WebkitAppearance",\n "WebkitBorderBefore",\n "WebkitBorderBeforeColor",\n "WebkitBorderBeforeStyle",\n "WebkitBorderBeforeWidth",\n "WebkitBoxReflect",\n "WebkitLineClamp",\n "WebkitMask",\n "WebkitMaskAttachment",\n "WebkitMaskClip",\n "WebkitMaskComposite",\n "WebkitMaskImage",\n "WebkitMaskOrigin",\n "WebkitMaskPosition",\n "WebkitMaskPositionX",\n "WebkitMaskPositionY",\n "WebkitMaskRepeat",\n "WebkitMaskRepeatX",\n "WebkitMaskRepeatY",\n "WebkitMaskSize",\n "WebkitOverflowScrolling",\n "WebkitTapHighlightColor",\n "WebkitTextFillColor",\n "WebkitTextStroke",\n "WebkitTextStrokeColor",\n "WebkitTextStrokeWidth",\n "WebkitTouchCallout",\n "WebkitUserModify",\n "accentColor",\n "alignContent",\n "alignItems",\n "alignSelf",\n "alignTracks",\n "all",\n "animation",\n "animationComposition",\n "animationDelay",\n "animationDirection",\n "animationDuration",\n "animationFillMode",\n "animationIterationCount",\n "animationName",\n "animationPlayState",\n "animationTimingFunction",\n "animationTimeline",\n "appearance",\n "aspectRatio",\n "azimuth",\n "backdropFilter",\n "backfaceVisibility",\n "background",\n "backgroundAttachment",\n "backgroundBlendMode",\n "backgroundClip",\n "backgroundColor",\n "backgroundImage",\n "backgroundOrigin",\n "backgroundPosition",\n "backgroundPositionX",\n "backgroundPositionY",\n "backgroundRepeat",\n "backgroundSize",\n "blockOverflow",\n "blockSize",\n "border",\n "borderBlock",\n "borderBlockColor",\n "borderBlockStyle",\n "borderBlockWidth",\n "borderBlockEnd",\n "borderBlockEndColor",\n "borderBlockEndStyle",\n "borderBlockEndWidth",\n "borderBlockStart",\n "borderBlockStartColor",\n "borderBlockStartStyle",\n "borderBlockStartWidth",\n "borderBottom",\n "borderBottomColor",\n "borderBottomLeftRadius",\n "borderBottomRightRadius",\n "borderBottomStyle",\n "borderBottomWidth",\n "borderCollapse",\n "borderColor",\n "borderEndEndRadius",\n "borderEndStartRadius",\n "borderImage",\n "borderImageOutset",\n "borderImageRepeat",\n "borderImageSlice",\n "borderImageSource",\n "borderImageWidth",\n "borderInline",\n "borderInlineEnd",\n "borderInlineColor",\n "borderInlineStyle",\n "borderInlineWidth",\n "borderInlineEndColor",\n "borderInlineEndStyle",\n "borderInlineEndWidth",\n "borderInlineStart",\n "borderInlineStartColor",\n "borderInlineStartStyle",\n "borderInlineStartWidth",\n "borderLeft",\n "borderLeftColor",\n "borderLeftStyle",\n "borderLeftWidth",\n "borderRadius",\n "borderRight",\n "borderRightColor",\n "borderRightStyle",\n "borderRightWidth",\n "borderSpacing",\n "borderStartEndRadius",\n "borderStartStartRadius",\n "borderStyle",\n "borderTop",\n "borderTopColor",\n "borderTopLeftRadius",\n "borderTopRightRadius",\n "borderTopStyle",\n "borderTopWidth",\n "borderWidth",\n "bottom",\n "boxAlign",\n "boxDecorationBreak",\n "boxDirection",\n "boxFlex",\n "boxFlexGroup",\n "boxLines",\n "boxOrdinalGroup",\n "boxOrient",\n "boxPack",\n "boxShadow",\n "boxSizing",\n "breakAfter",\n "breakBefore",\n "breakInside",\n "captionSide",\n "caret",\n "caretColor",\n "caretShape",\n "clear",\n "clip",\n "clipPath",\n "color",\n "colorScheme",\n "columnCount",\n "columnFill",\n "columnGap",\n "columnRule",\n "columnRuleColor",\n "columnRuleStyle",\n "columnRuleWidth",\n "columnSpan",\n "columnWidth",\n "columns",\n "contain",\n "containIntrinsicSize",\n "containIntrinsicBlockSize",\n "containIntrinsicHeight",\n "containIntrinsicInlineSize",\n "containIntrinsicWidth",\n "container",\n "containerName",\n "containerType",\n "content",\n "contentVisibility",\n "counterIncrement",\n "counterReset",\n "counterSet",\n "cursor",\n "direction",\n "display",\n "emptyCells",\n "filter",\n "flex",\n "flexBasis",\n "flexDirection",\n "flexFlow",\n "flexGrow",\n "flexShrink",\n "flexWrap",\n "float",\n "font",\n "fontFamily",\n "fontFeatureSettings",\n "fontKerning",\n "fontLanguageOverride",\n "fontOpticalSizing",\n "fontPalette",\n "fontVariationSettings",\n "fontSize",\n "fontSizeAdjust",\n "fontSmooth",\n "fontStretch",\n "fontStyle",\n "fontSynthesis",\n "fontVariant",\n "fontVariantAlternates",\n "fontVariantCaps",\n "fontVariantEastAsian",\n "fontVariantEmoji",\n "fontVariantLigatures",\n "fontVariantNumeric",\n "fontVariantPosition",\n "fontWeight",\n "forcedColorAdjust",\n "gap",\n "grid",\n "gridArea",\n "gridAutoColumns",\n "gridAutoFlow",\n "gridAutoRows",\n "gridColumn",\n "gridColumnEnd",\n "gridColumnGap",\n "gridColumnStart",\n "gridGap",\n "gridRow",\n "gridRowEnd",\n "gridRowGap",\n "gridRowStart",\n "gridTemplate",\n "gridTemplateAreas",\n "gridTemplateColumns",\n "gridTemplateRows",\n "hangingPunctuation",\n "height",\n "hyphenateCharacter",\n "hyphenateLimitChars",\n "hyphens",\n "imageOrientation",\n "imageRendering",\n "imageResolution",\n "imeMode",\n "initialLetter",\n "initialLetterAlign",\n "inlineSize",\n "inputSecurity",\n "inset",\n "insetBlock",\n "insetBlockEnd",\n "insetBlockStart",\n "insetInline",\n "insetInlineEnd",\n "insetInlineStart",\n "isolation",\n "justifyContent",\n "justifyItems",\n "justifySelf",\n "justifyTracks",\n "left",\n "letterSpacing",\n "lineBreak",\n "lineClamp",\n "lineHeight",\n "lineHeightStep",\n "listStyle",\n "listStyleImage",\n "listStylePosition",\n "listStyleType",\n "margin",\n "marginBlock",\n "marginBlockEnd",\n "marginBlockStart",\n "marginBottom",\n "marginInline",\n "marginInlineEnd",\n "marginInlineStart",\n "marginLeft",\n "marginRight",\n "marginTop",\n "marginTrim",\n "mask",\n "maskBorder",\n "maskBorderMode",\n "maskBorderOutset",\n "maskBorderRepeat",\n "maskBorderSlice",\n "maskBorderSource",\n "maskBorderWidth",\n "maskClip",\n "maskComposite",\n "maskImage",\n "maskMode",\n "maskOrigin",\n "maskPosition",\n "maskRepeat",\n "maskSize",\n "maskType",\n "masonryAutoFlow",\n "mathDepth",\n "mathShift",\n "mathStyle",\n "maxBlockSize",\n "maxHeight",\n "maxInlineSize",\n "maxLines",\n "maxWidth",\n "minBlockSize",\n "minHeight",\n "minInlineSize",\n "minWidth",\n "mixBlendMode",\n "objectFit",\n "objectPosition",\n "offset",\n "offsetAnchor",\n "offsetDistance",\n "offsetPath",\n "offsetPosition",\n "offsetRotate",\n "opacity",\n "order",\n "orphans",\n "outline",\n "outlineColor",\n "outlineOffset",\n "outlineStyle",\n "outlineWidth",\n "overflow",\n "overflowAnchor",\n "overflowBlock",\n "overflowClipBox",\n "overflowClipMargin",\n "overflowInline",\n "overflowWrap",\n "overflowX",\n "overflowY",\n "overscrollBehavior",\n "overscrollBehaviorBlock",\n "overscrollBehaviorInline",\n "overscrollBehaviorX",\n "overscrollBehaviorY",\n "padding",\n "paddingBlock",\n "paddingBlockEnd",\n "paddingBlockStart",\n "paddingBottom",\n "paddingInline",\n "paddingInlineEnd",\n "paddingInlineStart",\n "paddingLeft",\n "paddingRight",\n "paddingTop",\n "page",\n "pageBreakAfter",\n "pageBreakBefore",\n "pageBreakInside",\n "paintOrder",\n "perspective",\n "perspectiveOrigin",\n "placeContent",\n "placeItems",\n "placeSelf",\n "pointerEvents",\n "position",\n "printColorAdjust",\n "quotes",\n "resize",\n "right",\n "rotate",\n "rowGap",\n "rubyAlign",\n "rubyMerge",\n "rubyPosition",\n "scale",\n "scrollbarColor",\n "scrollbarGutter",\n "scrollbarWidth",\n "scrollBehavior",\n "scrollMargin",\n "scrollMarginBlock",\n "scrollMarginBlockStart",\n "scrollMarginBlockEnd",\n "scrollMarginBottom",\n "scrollMarginInline",\n "scrollMarginInlineStart",\n "scrollMarginInlineEnd",\n "scrollMarginLeft",\n "scrollMarginRight",\n "scrollMarginTop",\n "scrollPadding",\n "scrollPaddingBlock",\n "scrollPaddingBlockStart",\n "scrollPaddingBlockEnd",\n "scrollPaddingBottom",\n "scrollPaddingInline",\n "scrollPaddingInlineStart",\n "scrollPaddingInlineEnd",\n "scrollPaddingLeft",\n "scrollPaddingRight",\n "scrollPaddingTop",\n "scrollSnapAlign",\n "scrollSnapCoordinate",\n "scrollSnapDestination",\n "scrollSnapPointsX",\n "scrollSnapPointsY",\n "scrollSnapStop",\n "scrollSnapType",\n "scrollSnapTypeX",\n "scrollSnapTypeY",\n "scrollTimeline",\n "scrollTimelineAxis",\n "scrollTimelineName",\n "shapeImageThreshold",\n "shapeMargin",\n "shapeOutside",\n "tabSize",\n "tableLayout",\n "textAlign",\n "textAlignLast",\n "textCombineUpright",\n "textDecoration",\n "textDecorationColor",\n "textDecorationLine",\n "textDecorationSkip",\n "textDecorationSkipInk",\n "textDecorationStyle",\n "textDecorationThickness",\n "textEmphasis",\n "textEmphasisColor",\n "textEmphasisPosition",\n "textEmphasisStyle",\n "textIndent",\n "textJustify",\n "textOrientation",\n "textOverflow",\n "textRendering",\n "textShadow",\n "textSizeAdjust",\n "textTransform",\n "textUnderlineOffset",\n "textUnderlinePosition",\n "top",\n "touchAction",\n "transform",\n "transformBox",\n "transformOrigin",\n "transformStyle",\n "transition",\n "transitionDelay",\n "transitionDuration",\n "transitionProperty",\n "transitionTimingFunction",\n "translate",\n "unicodeBidi",\n "userSelect",\n "verticalAlign",\n "viewTransitionName",\n "visibility",\n "whiteSpace",\n "widows",\n "width",\n "willChange",\n "wordBreak",\n "wordSpacing",\n "wordWrap",\n "writingMode",\n "zIndex",\n "zoom",\n ...userGenerated\n];\nvar properties = new Map(allCssProperties.map((prop) => [prop, true]));\nfunction memo(fn) {\n const cache = /* @__PURE__ */ Object.create(null);\n return (arg) => {\n if (cache[arg] === void 0)\n cache[arg] = fn(arg);\n return cache[arg];\n };\n}\nvar selectorRegex = /&|@/;\nvar isCssProperty = memo((prop) => {\n return properties.has(prop) || prop.startsWith("--") || selectorRegex.test(prop);\n});\nexport {\n allCssProperties,\n isCssProperty\n};\n'
|
|
863
|
+
content: '// src/index.ts\nvar userGeneratedStr = "";\nvar userGenerated = userGeneratedStr.split(",");\nvar cssPropertiesStr = "WebkitAppearance,WebkitBorderBefore,WebkitBorderBeforeColor,WebkitBorderBeforeStyle,WebkitBorderBeforeWidth,WebkitBoxReflect,WebkitLineClamp,WebkitMask,WebkitMaskAttachment,WebkitMaskClip,WebkitMaskComposite,WebkitMaskImage,WebkitMaskOrigin,WebkitMaskPosition,WebkitMaskPositionX,WebkitMaskPositionY,WebkitMaskRepeat,WebkitMaskRepeatX,WebkitMaskRepeatY,WebkitMaskSize,WebkitOverflowScrolling,WebkitTapHighlightColor,WebkitTextFillColor,WebkitTextStroke,WebkitTextStrokeColor,WebkitTextStrokeWidth,WebkitTouchCallout,WebkitUserModify,accentColor,alignContent,alignItems,alignSelf,alignTracks,all,animation,animationComposition,animationDelay,animationDirection,animationDuration,animationFillMode,animationIterationCount,animationName,animationPlayState,animationTimingFunction,animationTimeline,appearance,aspectRatio,azimuth,backdropFilter,backfaceVisibility,background,backgroundAttachment,backgroundBlendMode,backgroundClip,backgroundColor,backgroundImage,backgroundOrigin,backgroundPosition,backgroundPositionX,backgroundPositionY,backgroundRepeat,backgroundSize,blockOverflow,blockSize,border,borderBlock,borderBlockColor,borderBlockStyle,borderBlockWidth,borderBlockEnd,borderBlockEndColor,borderBlockEndStyle,borderBlockEndWidth,borderBlockStart,borderBlockStartColor,borderBlockStartStyle,borderBlockStartWidth,borderBottom,borderBottomColor,borderBottomLeftRadius,borderBottomRightRadius,borderBottomStyle,borderBottomWidth,borderCollapse,borderColor,borderEndEndRadius,borderEndStartRadius,borderImage,borderImageOutset,borderImageRepeat,borderImageSlice,borderImageSource,borderImageWidth,borderInline,borderInlineEnd,borderInlineColor,borderInlineStyle,borderInlineWidth,borderInlineEndColor,borderInlineEndStyle,borderInlineEndWidth,borderInlineStart,borderInlineStartColor,borderInlineStartStyle,borderInlineStartWidth,borderLeft,borderLeftColor,borderLeftStyle,borderLeftWidth,borderRadius,borderRight,borderRightColor,borderRightStyle,borderRightWidth,borderSpacing,borderStartEndRadius,borderStartStartRadius,borderStyle,borderTop,borderTopColor,borderTopLeftRadius,borderTopRightRadius,borderTopStyle,borderTopWidth,borderWidth,bottom,boxAlign,boxDecorationBreak,boxDirection,boxFlex,boxFlexGroup,boxLines,boxOrdinalGroup,boxOrient,boxPack,boxShadow,boxSizing,breakAfter,breakBefore,breakInside,captionSide,caret,caretColor,caretShape,clear,clip,clipPath,color,colorScheme,columnCount,columnFill,columnGap,columnRule,columnRuleColor,columnRuleStyle,columnRuleWidth,columnSpan,columnWidth,columns,contain,containIntrinsicSize,containIntrinsicBlockSize,containIntrinsicHeight,containIntrinsicInlineSize,containIntrinsicWidth,container,containerName,containerType,content,contentVisibility,counterIncrement,counterReset,counterSet,cursor,direction,display,emptyCells,filter,flex,flexBasis,flexDirection,flexFlow,flexGrow,flexShrink,flexWrap,float,font,fontFamily,fontFeatureSettings,fontKerning,fontLanguageOverride,fontOpticalSizing,fontPalette,fontVariationSettings,fontSize,fontSizeAdjust,fontSmooth,fontStretch,fontStyle,fontSynthesis,fontVariant,fontVariantAlternates,fontVariantCaps,fontVariantEastAsian,fontVariantEmoji,fontVariantLigatures,fontVariantNumeric,fontVariantPosition,fontWeight,forcedColorAdjust,gap,grid,gridArea,gridAutoColumns,gridAutoFlow,gridAutoRows,gridColumn,gridColumnEnd,gridColumnGap,gridColumnStart,gridGap,gridRow,gridRowEnd,gridRowGap,gridRowStart,gridTemplate,gridTemplateAreas,gridTemplateColumns,gridTemplateRows,hangingPunctuation,height,hyphenateCharacter,hyphenateLimitChars,hyphens,imageOrientation,imageRendering,imageResolution,imeMode,initialLetter,initialLetterAlign,inlineSize,inputSecurity,inset,insetBlock,insetBlockEnd,insetBlockStart,insetInline,insetInlineEnd,insetInlineStart,isolation,justifyContent,justifyItems,justifySelf,justifyTracks,left,letterSpacing,lineBreak,lineClamp,lineHeight,lineHeightStep,listStyle,listStyleImage,listStylePosition,listStyleType,margin,marginBlock,marginBlockEnd,marginBlockStart,marginBottom,marginInline,marginInlineEnd,marginInlineStart,marginLeft,marginRight,marginTop,marginTrim,mask,maskBorder,maskBorderMode,maskBorderOutset,maskBorderRepeat,maskBorderSlice,maskBorderSource,maskBorderWidth,maskClip,maskComposite,maskImage,maskMode,maskOrigin,maskPosition,maskRepeat,maskSize,maskType,masonryAutoFlow,mathDepth,mathShift,mathStyle,maxBlockSize,maxHeight,maxInlineSize,maxLines,maxWidth,minBlockSize,minHeight,minInlineSize,minWidth,mixBlendMode,objectFit,objectPosition,offset,offsetAnchor,offsetDistance,offsetPath,offsetPosition,offsetRotate,opacity,order,orphans,outline,outlineColor,outlineOffset,outlineStyle,outlineWidth,overflow,overflowAnchor,overflowBlock,overflowClipBox,overflowClipMargin,overflowInline,overflowWrap,overflowX,overflowY,overscrollBehavior,overscrollBehaviorBlock,overscrollBehaviorInline,overscrollBehaviorX,overscrollBehaviorY,padding,paddingBlock,paddingBlockEnd,paddingBlockStart,paddingBottom,paddingInline,paddingInlineEnd,paddingInlineStart,paddingLeft,paddingRight,paddingTop,page,pageBreakAfter,pageBreakBefore,pageBreakInside,paintOrder,perspective,perspectiveOrigin,placeContent,placeItems,placeSelf,pointerEvents,position,printColorAdjust,quotes,resize,right,rotate,rowGap,rubyAlign,rubyMerge,rubyPosition,scale,scrollbarColor,scrollbarGutter,scrollbarWidth,scrollBehavior,scrollMargin,scrollMarginBlock,scrollMarginBlockStart,scrollMarginBlockEnd,scrollMarginBottom,scrollMarginInline,scrollMarginInlineStart,scrollMarginInlineEnd,scrollMarginLeft,scrollMarginRight,scrollMarginTop,scrollPadding,scrollPaddingBlock,scrollPaddingBlockStart,scrollPaddingBlockEnd,scrollPaddingBottom,scrollPaddingInline,scrollPaddingInlineStart,scrollPaddingInlineEnd,scrollPaddingLeft,scrollPaddingRight,scrollPaddingTop,scrollSnapAlign,scrollSnapCoordinate,scrollSnapDestination,scrollSnapPointsX,scrollSnapPointsY,scrollSnapStop,scrollSnapType,scrollSnapTypeX,scrollSnapTypeY,scrollTimeline,scrollTimelineAxis,scrollTimelineName,shapeImageThreshold,shapeMargin,shapeOutside,tabSize,tableLayout,textAlign,textAlignLast,textCombineUpright,textDecoration,textDecorationColor,textDecorationLine,textDecorationSkip,textDecorationSkipInk,textDecorationStyle,textDecorationThickness,textEmphasis,textEmphasisColor,textEmphasisPosition,textEmphasisStyle,textIndent,textJustify,textOrientation,textOverflow,textRendering,textShadow,textSizeAdjust,textTransform,textUnderlineOffset,textUnderlinePosition,top,touchAction,transform,transformBox,transformOrigin,transformStyle,transition,transitionDelay,transitionDuration,transitionProperty,transitionTimingFunction,translate,unicodeBidi,userSelect,verticalAlign,viewTransitionName,visibility,whiteSpace,widows,width,willChange,wordBreak,wordSpacing,wordWrap,writingMode,zIndex,zoom";\nvar allCssProperties = cssPropertiesStr.split(",").concat(userGenerated);\nvar properties = new Map(allCssProperties.map((prop) => [prop, true]));\nfunction memo(fn) {\n const cache = /* @__PURE__ */ Object.create(null);\n return (arg) => {\n if (cache[arg] === void 0)\n cache[arg] = fn(arg);\n return cache[arg];\n };\n}\nvar selectorRegex = /&|@/;\nvar isCssProperty = /* @__PURE__ */ memo((prop) => {\n return properties.has(prop) || prop.startsWith("--") || selectorRegex.test(prop);\n});\nexport {\n allCssProperties,\n isCssProperty\n};\n'
|
|
834
864
|
};
|
|
835
865
|
|
|
836
866
|
// src/artifacts/js/is-valid-prop.ts
|
|
837
867
|
import { outdent as outdent9 } from "outdent";
|
|
838
|
-
|
|
868
|
+
import { match } from "ts-pattern";
|
|
869
|
+
var cssPropRegex = /var cssPropertiesStr = ".*?";/;
|
|
870
|
+
var memoFnDeclarationRegex = /function memo(.+?)\nvar selectorRegex/s;
|
|
871
|
+
function generateIsValidProp(ctx) {
|
|
839
872
|
if (ctx.isTemplateLiteralSyntax)
|
|
840
873
|
return;
|
|
841
874
|
let content = is_valid_prop_mjs_default.content;
|
|
842
875
|
content = content.replace(
|
|
843
|
-
|
|
844
|
-
`var
|
|
876
|
+
'var userGeneratedStr = "";',
|
|
877
|
+
`var userGeneratedStr = "${match(ctx.jsx.styleProps).with("all", () => Array.from(new Set(ctx.properties)).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
845
878
|
);
|
|
879
|
+
content = content.replace(memoFnDeclarationRegex, "var selectorRegex");
|
|
880
|
+
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
881
|
+
content = content.replace("/* @__PURE__ */ memo(", "/* @__PURE__ */ (");
|
|
882
|
+
content = content.replace(cssPropRegex, 'var cssPropertiesStr = "";');
|
|
883
|
+
} else {
|
|
884
|
+
content = ctx.file.import("memo", "../helpers") + "\n" + content;
|
|
885
|
+
}
|
|
846
886
|
return {
|
|
847
887
|
js: content,
|
|
848
888
|
dts: outdent9`
|
|
@@ -855,16 +895,16 @@ function generateisValidProp(ctx) {
|
|
|
855
895
|
|
|
856
896
|
// src/artifacts/js/pattern.ts
|
|
857
897
|
import { unionType } from "@pandacss/shared";
|
|
858
|
-
import { stringify
|
|
898
|
+
import { stringify } from "javascript-stringify";
|
|
859
899
|
import { outdent as outdent10 } from "outdent";
|
|
860
|
-
import { match } from "ts-pattern";
|
|
900
|
+
import { match as match2 } from "ts-pattern";
|
|
861
901
|
function generatePattern(ctx) {
|
|
862
902
|
if (ctx.patterns.isEmpty())
|
|
863
903
|
return;
|
|
864
904
|
return ctx.patterns.details.map((pattern) => {
|
|
865
905
|
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
866
906
|
const { properties, transform, strict, description } = config;
|
|
867
|
-
const transformFn =
|
|
907
|
+
const transformFn = stringify({ transform }) ?? "";
|
|
868
908
|
const helperImports = ["mapObject"];
|
|
869
909
|
if (transformFn.includes("__spreadValues")) {
|
|
870
910
|
helperImports.push("__spreadValues");
|
|
@@ -883,7 +923,7 @@ function generatePattern(ctx) {
|
|
|
883
923
|
export type ${upperName}Properties = {
|
|
884
924
|
${Object.keys(properties ?? {}).map((key) => {
|
|
885
925
|
const value = properties[key];
|
|
886
|
-
return
|
|
926
|
+
return match2(value).with({ type: "property" }, (value2) => {
|
|
887
927
|
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
888
928
|
}).with({ type: "token" }, (value2) => {
|
|
889
929
|
if (value2.property) {
|
|
@@ -929,9 +969,11 @@ transform`)}
|
|
|
929
969
|
}
|
|
930
970
|
|
|
931
971
|
// src/artifacts/js/recipe.ts
|
|
972
|
+
import { isSlotRecipe } from "@pandacss/core";
|
|
932
973
|
import { unionType as unionType2 } from "@pandacss/shared";
|
|
933
974
|
import { outdent as outdent11 } from "outdent";
|
|
934
|
-
|
|
975
|
+
import { match as match3 } from "ts-pattern";
|
|
976
|
+
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
935
977
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
936
978
|
function generateRecipes(ctx) {
|
|
937
979
|
const {
|
|
@@ -964,9 +1006,9 @@ function generateRecipes(ctx) {
|
|
|
964
1006
|
}
|
|
965
1007
|
|
|
966
1008
|
const recipeCss = createCss({
|
|
967
|
-
|
|
1009
|
+
${hash ? "hash: true," : ""}
|
|
968
1010
|
utility: {
|
|
969
|
-
|
|
1011
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
970
1012
|
transform,
|
|
971
1013
|
}
|
|
972
1014
|
})
|
|
@@ -989,26 +1031,59 @@ function generateRecipes(ctx) {
|
|
|
989
1031
|
...ctx.recipes.details.map((recipe) => {
|
|
990
1032
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
991
1033
|
const { description, defaultVariants, compoundVariants } = config;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1034
|
+
const jsCode = match3(config).when(
|
|
1035
|
+
isSlotRecipe,
|
|
1036
|
+
(config2) => outdent11`
|
|
1037
|
+
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1038
|
+
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1039
|
+
|
|
1040
|
+
const ${baseName}DefaultVariants = ${stringify2(defaultVariants ?? {})}
|
|
1041
|
+
const ${baseName}CompoundVariants = ${stringify2(compoundVariants ?? [])}
|
|
1042
|
+
|
|
1043
|
+
const ${baseName}SlotNames = ${stringify2(config2.slots.map((slot) => [slot, `${config2.className}__${slot}`]))}
|
|
1044
|
+
const ${baseName}SlotFns = ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
|
|
1045
|
+
|
|
1046
|
+
const ${baseName}Fn = (props = {}) => {
|
|
1047
|
+
return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn(props)]))
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
const ${baseName}VariantKeys = ${stringify2(Object.keys(variantKeyMap))}
|
|
1051
|
+
|
|
1052
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1053
|
+
__recipe__: false,
|
|
1054
|
+
raw: (props) => props,
|
|
1055
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1056
|
+
variantMap: ${stringify2(variantKeyMap)},
|
|
1057
|
+
splitVariantProps(props) {
|
|
1058
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1059
|
+
},
|
|
1060
|
+
})
|
|
1061
|
+
`
|
|
1062
|
+
).otherwise(
|
|
1063
|
+
(config2) => outdent11`
|
|
995
1064
|
${ctx.file.import("splitProps", "../helpers")}
|
|
996
1065
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
997
1066
|
|
|
998
|
-
const ${baseName}Fn = createRecipe('${
|
|
1067
|
+
const ${baseName}Fn = createRecipe('${config2.className}', ${stringify2(defaultVariants ?? {})}, ${stringify2(
|
|
999
1068
|
compoundVariants ?? []
|
|
1000
1069
|
)})
|
|
1001
1070
|
|
|
1071
|
+
const ${baseName}VariantMap = ${stringify2(variantKeyMap)}
|
|
1072
|
+
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1002
1073
|
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1003
1074
|
__recipe__: true,
|
|
1004
1075
|
raw: (props) => props,
|
|
1005
|
-
variantKeys: ${
|
|
1006
|
-
variantMap: ${
|
|
1076
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1077
|
+
variantMap: ${baseName}VariantMap,
|
|
1007
1078
|
splitVariantProps(props) {
|
|
1008
|
-
return splitProps(props, ${
|
|
1079
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1009
1080
|
},
|
|
1010
1081
|
})
|
|
1011
|
-
|
|
1082
|
+
`
|
|
1083
|
+
);
|
|
1084
|
+
return {
|
|
1085
|
+
name: dashName,
|
|
1086
|
+
js: jsCode,
|
|
1012
1087
|
dts: outdent11`
|
|
1013
1088
|
import type { ConditionalValue } from '../types'
|
|
1014
1089
|
import type { Pretty } from '../types/helpers'
|
|
@@ -1032,7 +1107,7 @@ function generateRecipes(ctx) {
|
|
|
1032
1107
|
|
|
1033
1108
|
interface ${upperName}Recipe {
|
|
1034
1109
|
__type: ${upperName}VariantProps
|
|
1035
|
-
(props?: ${upperName}VariantProps): string
|
|
1110
|
+
(props?: ${upperName}VariantProps): ${isSlotRecipe(config) ? `Pretty<Record<${unionType2(config.slots)}, string>>` : "string"}
|
|
1036
1111
|
raw: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
|
|
1037
1112
|
variantMap: ${upperName}VariantMap
|
|
1038
1113
|
variantKeys: Array<keyof ${upperName}Variant>
|
|
@@ -1047,8 +1122,42 @@ function generateRecipes(ctx) {
|
|
|
1047
1122
|
];
|
|
1048
1123
|
}
|
|
1049
1124
|
|
|
1125
|
+
// src/artifacts/js/sva.ts
|
|
1126
|
+
import { outdent as outdent12 } from "outdent";
|
|
1127
|
+
function generateSvaFn(ctx) {
|
|
1128
|
+
return {
|
|
1129
|
+
js: outdent12`
|
|
1130
|
+
${ctx.file.import("getSlotRecipes", "../helpers")}
|
|
1131
|
+
${ctx.file.import("cva", "./cva")}
|
|
1132
|
+
|
|
1133
|
+
export function sva(config) {
|
|
1134
|
+
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1135
|
+
|
|
1136
|
+
function svaFn(props) {
|
|
1137
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1138
|
+
return Object.fromEntries(result)
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
const [, firstCva] = slots[0]
|
|
1142
|
+
|
|
1143
|
+
return Object.assign(svaFn, {
|
|
1144
|
+
__cva__: false,
|
|
1145
|
+
variantMap: firstCva.variantMap,
|
|
1146
|
+
variantKeys: firstCva.variantKeys,
|
|
1147
|
+
splitVariantProps: firstCva.splitVariantProps,
|
|
1148
|
+
})
|
|
1149
|
+
}
|
|
1150
|
+
`,
|
|
1151
|
+
dts: outdent12`
|
|
1152
|
+
import type { SlotRecipeCreatorFn } from '../types/recipe'
|
|
1153
|
+
|
|
1154
|
+
export declare const sva: SlotRecipeCreatorFn
|
|
1155
|
+
`
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1050
1159
|
// src/artifacts/js/token.ts
|
|
1051
|
-
import
|
|
1160
|
+
import outdent13 from "outdent";
|
|
1052
1161
|
function generateTokenJs(ctx) {
|
|
1053
1162
|
const { tokens } = ctx;
|
|
1054
1163
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1059,7 +1168,7 @@ function generateTokenJs(ctx) {
|
|
|
1059
1168
|
});
|
|
1060
1169
|
const obj = Object.fromEntries(map);
|
|
1061
1170
|
return {
|
|
1062
|
-
js:
|
|
1171
|
+
js: outdent13`
|
|
1063
1172
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1064
1173
|
|
|
1065
1174
|
export function token(path, fallback) {
|
|
@@ -1072,7 +1181,7 @@ function generateTokenJs(ctx) {
|
|
|
1072
1181
|
|
|
1073
1182
|
token.var = tokenVar
|
|
1074
1183
|
`,
|
|
1075
|
-
dts:
|
|
1184
|
+
dts: outdent13`
|
|
1076
1185
|
import type { Token } from './tokens'
|
|
1077
1186
|
|
|
1078
1187
|
export declare const token: {
|
|
@@ -1086,43 +1195,43 @@ function generateTokenJs(ctx) {
|
|
|
1086
1195
|
}
|
|
1087
1196
|
|
|
1088
1197
|
// src/artifacts/preact-jsx/jsx.ts
|
|
1089
|
-
import { outdent as
|
|
1198
|
+
import { outdent as outdent14 } from "outdent";
|
|
1090
1199
|
function generatePreactJsxFactory(ctx) {
|
|
1091
1200
|
const { factoryName, componentName } = ctx.jsx;
|
|
1092
1201
|
return {
|
|
1093
|
-
js:
|
|
1202
|
+
js: outdent14`
|
|
1094
1203
|
import { h } from 'preact'
|
|
1095
1204
|
import { forwardRef } from 'preact/compat'
|
|
1096
1205
|
import { useMemo } from 'preact/hooks'
|
|
1097
1206
|
${ctx.file.import("css, cx, assignCss", "../css/index")}
|
|
1098
1207
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1099
1208
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1100
|
-
|
|
1209
|
+
|
|
1101
1210
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1102
1211
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1103
|
-
|
|
1104
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1212
|
+
|
|
1213
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1105
1214
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1106
1215
|
|
|
1107
1216
|
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1108
1217
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1109
1218
|
}, [restProps])
|
|
1110
|
-
|
|
1219
|
+
|
|
1111
1220
|
function recipeClass() {
|
|
1112
1221
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1113
1222
|
const styles = assignCss(propStyles, cssStyles)
|
|
1114
1223
|
return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
|
|
1115
1224
|
}
|
|
1116
|
-
|
|
1225
|
+
|
|
1117
1226
|
function cvaClass() {
|
|
1118
1227
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1119
1228
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1120
1229
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1121
1230
|
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1122
1231
|
}
|
|
1123
|
-
|
|
1232
|
+
|
|
1124
1233
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1125
|
-
|
|
1234
|
+
|
|
1126
1235
|
return h(Element, {
|
|
1127
1236
|
...elementProps,
|
|
1128
1237
|
...normalizeHTMLProps(htmlProps),
|
|
@@ -1130,14 +1239,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1130
1239
|
className: classes()
|
|
1131
1240
|
})
|
|
1132
1241
|
})
|
|
1133
|
-
|
|
1242
|
+
|
|
1134
1243
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1135
1244
|
return ${componentName}
|
|
1136
1245
|
}
|
|
1137
|
-
|
|
1246
|
+
|
|
1138
1247
|
function createJsxFactory() {
|
|
1139
1248
|
const cache = new Map()
|
|
1140
|
-
|
|
1249
|
+
|
|
1141
1250
|
return new Proxy(styledFn, {
|
|
1142
1251
|
apply(_, __, args) {
|
|
1143
1252
|
return styledFn(...args)
|
|
@@ -1151,14 +1260,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1151
1260
|
})
|
|
1152
1261
|
}
|
|
1153
1262
|
|
|
1154
|
-
export const ${factoryName} = createJsxFactory()
|
|
1263
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1155
1264
|
`
|
|
1156
1265
|
};
|
|
1157
1266
|
}
|
|
1158
1267
|
|
|
1159
1268
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1160
|
-
import { outdent as
|
|
1161
|
-
import { match as
|
|
1269
|
+
import { outdent as outdent15 } from "outdent";
|
|
1270
|
+
import { match as match4 } from "ts-pattern";
|
|
1162
1271
|
function generatePreactJsxPattern(ctx) {
|
|
1163
1272
|
const { typeName, factoryName } = ctx.jsx;
|
|
1164
1273
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1166,35 +1275,35 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1166
1275
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1167
1276
|
return {
|
|
1168
1277
|
name: dashName,
|
|
1169
|
-
js:
|
|
1278
|
+
js: outdent15`
|
|
1170
1279
|
import { h } from 'preact'
|
|
1171
1280
|
import { forwardRef } from 'preact/compat'
|
|
1172
1281
|
${ctx.file.import(factoryName, "./factory")}
|
|
1173
1282
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1174
|
-
|
|
1175
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1176
|
-
${
|
|
1283
|
+
|
|
1284
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1285
|
+
${match4(props.length).with(
|
|
1177
1286
|
0,
|
|
1178
|
-
() =>
|
|
1287
|
+
() => outdent15`
|
|
1179
1288
|
const styleProps = ${styleFnName}()
|
|
1180
1289
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1181
1290
|
`
|
|
1182
1291
|
).otherwise(
|
|
1183
|
-
() =>
|
|
1292
|
+
() => outdent15`
|
|
1184
1293
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1185
1294
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1186
1295
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1187
1296
|
`
|
|
1188
1297
|
)}
|
|
1189
|
-
})
|
|
1298
|
+
})
|
|
1190
1299
|
`,
|
|
1191
|
-
dts:
|
|
1300
|
+
dts: outdent15`
|
|
1192
1301
|
import type { FunctionComponent } from 'preact'
|
|
1193
1302
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1194
1303
|
import type { ${typeName} } from '../types/jsx'
|
|
1195
|
-
|
|
1304
|
+
|
|
1196
1305
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1197
|
-
|
|
1306
|
+
|
|
1198
1307
|
${description ? `/** ${description} */` : ""}
|
|
1199
1308
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1200
1309
|
`
|
|
@@ -1203,15 +1312,15 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1203
1312
|
}
|
|
1204
1313
|
|
|
1205
1314
|
// src/artifacts/preact-jsx/types.ts
|
|
1206
|
-
import { outdent as
|
|
1315
|
+
import { outdent as outdent16 } from "outdent";
|
|
1207
1316
|
function generatePreactJsxTypes(ctx) {
|
|
1208
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1317
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1209
1318
|
return {
|
|
1210
|
-
jsxFactory:
|
|
1319
|
+
jsxFactory: outdent16`
|
|
1211
1320
|
import type { ${upperName} } from '../types/jsx'
|
|
1212
1321
|
export declare const ${factoryName}: ${upperName}
|
|
1213
1322
|
`,
|
|
1214
|
-
jsxType:
|
|
1323
|
+
jsxType: outdent16`
|
|
1215
1324
|
import type { ComponentProps, JSX } from 'preact'
|
|
1216
1325
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1217
1326
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1228,7 +1337,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1228
1337
|
type RecipeFn = { __type: any }
|
|
1229
1338
|
|
|
1230
1339
|
interface JsxFactory {
|
|
1231
|
-
|
|
1340
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1232
1341
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1233
1342
|
T,
|
|
1234
1343
|
RecipeSelection<P>
|
|
@@ -1238,7 +1347,7 @@ interface JsxFactory {
|
|
|
1238
1347
|
|
|
1239
1348
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1240
1349
|
|
|
1241
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1350
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1242
1351
|
|
|
1243
1352
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1244
1353
|
`
|
|
@@ -1246,37 +1355,37 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1246
1355
|
}
|
|
1247
1356
|
|
|
1248
1357
|
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1249
|
-
import { outdent as
|
|
1358
|
+
import { outdent as outdent17 } from "outdent";
|
|
1250
1359
|
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1251
1360
|
const { factoryName, componentName } = ctx.jsx;
|
|
1252
1361
|
return {
|
|
1253
|
-
js:
|
|
1362
|
+
js: outdent17`
|
|
1254
1363
|
import { h } from 'preact'
|
|
1255
1364
|
import { forwardRef } from 'preact/compat'
|
|
1256
1365
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1257
|
-
|
|
1366
|
+
|
|
1258
1367
|
function createStyledFn(Dynamic) {
|
|
1259
1368
|
return function styledFn(template) {
|
|
1260
1369
|
const baseClassName = css(template)
|
|
1261
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1370
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1262
1371
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1263
1372
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1264
|
-
|
|
1373
|
+
|
|
1265
1374
|
return h(Element, {
|
|
1266
1375
|
ref,
|
|
1267
1376
|
...elementProps,
|
|
1268
1377
|
className: classes(),
|
|
1269
1378
|
})
|
|
1270
1379
|
})
|
|
1271
|
-
|
|
1380
|
+
|
|
1272
1381
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1273
1382
|
return ${componentName}
|
|
1274
1383
|
}
|
|
1275
1384
|
}
|
|
1276
|
-
|
|
1385
|
+
|
|
1277
1386
|
function createJsxFactory() {
|
|
1278
1387
|
const cache = new Map()
|
|
1279
|
-
|
|
1388
|
+
|
|
1280
1389
|
return new Proxy(createStyledFn, {
|
|
1281
1390
|
apply(_, __, args) {
|
|
1282
1391
|
return createStyledFn(...args)
|
|
@@ -1290,21 +1399,21 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1290
1399
|
})
|
|
1291
1400
|
}
|
|
1292
1401
|
|
|
1293
|
-
export const ${factoryName} = createJsxFactory()
|
|
1402
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1294
1403
|
`
|
|
1295
1404
|
};
|
|
1296
1405
|
}
|
|
1297
1406
|
|
|
1298
1407
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1299
|
-
import { outdent as
|
|
1408
|
+
import { outdent as outdent18 } from "outdent";
|
|
1300
1409
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1301
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1410
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1302
1411
|
return {
|
|
1303
|
-
jsxFactory:
|
|
1412
|
+
jsxFactory: outdent18`
|
|
1304
1413
|
import type { ${upperName} } from '../types/jsx'
|
|
1305
1414
|
export declare const ${factoryName}: ${upperName}
|
|
1306
1415
|
`,
|
|
1307
|
-
jsxType:
|
|
1416
|
+
jsxType: outdent18`
|
|
1308
1417
|
import type { ComponentProps, JSX } from 'preact'
|
|
1309
1418
|
|
|
1310
1419
|
type ElementType = keyof JSX.IntrinsicElements
|
|
@@ -1322,7 +1431,7 @@ interface JsxFactory {
|
|
|
1322
1431
|
|
|
1323
1432
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1324
1433
|
|
|
1325
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1434
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1326
1435
|
|
|
1327
1436
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1328
1437
|
`
|
|
@@ -1330,54 +1439,54 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1330
1439
|
}
|
|
1331
1440
|
|
|
1332
1441
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1333
|
-
import { outdent as
|
|
1442
|
+
import { outdent as outdent19 } from "outdent";
|
|
1334
1443
|
function generateQwikJsxFactory(ctx) {
|
|
1335
1444
|
const { factoryName, componentName } = ctx.jsx;
|
|
1336
1445
|
return {
|
|
1337
|
-
js:
|
|
1446
|
+
js: outdent19`
|
|
1338
1447
|
import { h } from '@builder.io/qwik'
|
|
1339
1448
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1340
1449
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1341
1450
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1342
|
-
|
|
1451
|
+
|
|
1343
1452
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1344
1453
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1345
|
-
|
|
1454
|
+
|
|
1346
1455
|
const ${componentName} = function ${componentName}(props) {
|
|
1347
1456
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1348
|
-
|
|
1349
|
-
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1457
|
+
|
|
1458
|
+
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1350
1459
|
splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1351
|
-
|
|
1460
|
+
|
|
1352
1461
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1353
|
-
|
|
1462
|
+
|
|
1354
1463
|
function recipeClass() {
|
|
1355
1464
|
const styles = assignCss(propStyles, cssStyles)
|
|
1356
1465
|
return cx(cvaFn(variantProps), css(styles), elementProps.class)
|
|
1357
1466
|
}
|
|
1358
|
-
|
|
1467
|
+
|
|
1359
1468
|
function cvaClass() {
|
|
1360
1469
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1361
1470
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1362
1471
|
return cx(css(styles), elementProps.class)
|
|
1363
1472
|
}
|
|
1364
|
-
|
|
1473
|
+
|
|
1365
1474
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1366
|
-
|
|
1475
|
+
|
|
1367
1476
|
return h(Element, {
|
|
1368
1477
|
...elementProps,
|
|
1369
1478
|
...normalizeHTMLProps(htmlProps),
|
|
1370
1479
|
class: classes(),
|
|
1371
1480
|
})
|
|
1372
1481
|
}
|
|
1373
|
-
|
|
1482
|
+
|
|
1374
1483
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1375
1484
|
return ${componentName}
|
|
1376
1485
|
}
|
|
1377
|
-
|
|
1486
|
+
|
|
1378
1487
|
function createJsxFactory() {
|
|
1379
1488
|
const cache = new Map()
|
|
1380
|
-
|
|
1489
|
+
|
|
1381
1490
|
return new Proxy(styledFn, {
|
|
1382
1491
|
apply(_, __, args) {
|
|
1383
1492
|
return styledFn(...args)
|
|
@@ -1391,15 +1500,15 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1391
1500
|
})
|
|
1392
1501
|
}
|
|
1393
1502
|
|
|
1394
|
-
export const ${factoryName} = createJsxFactory()
|
|
1503
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1395
1504
|
|
|
1396
1505
|
`
|
|
1397
1506
|
};
|
|
1398
1507
|
}
|
|
1399
1508
|
|
|
1400
1509
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1401
|
-
import { outdent as
|
|
1402
|
-
import { match as
|
|
1510
|
+
import { outdent as outdent20 } from "outdent";
|
|
1511
|
+
import { match as match5 } from "ts-pattern";
|
|
1403
1512
|
function generateQwikJsxPattern(ctx) {
|
|
1404
1513
|
const { typeName, factoryName } = ctx.jsx;
|
|
1405
1514
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1407,20 +1516,20 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1407
1516
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1408
1517
|
return {
|
|
1409
1518
|
name: dashName,
|
|
1410
|
-
js:
|
|
1519
|
+
js: outdent20`
|
|
1411
1520
|
import { h } from '@builder.io/qwik'
|
|
1412
1521
|
${ctx.file.import(factoryName, "./factory")}
|
|
1413
1522
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1414
1523
|
|
|
1415
1524
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1416
|
-
${
|
|
1525
|
+
${match5(props.length).with(
|
|
1417
1526
|
0,
|
|
1418
|
-
() =>
|
|
1527
|
+
() => outdent20`
|
|
1419
1528
|
const styleProps = ${styleFnName}()
|
|
1420
1529
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1421
1530
|
`
|
|
1422
1531
|
).otherwise(
|
|
1423
|
-
() =>
|
|
1532
|
+
() => outdent20`
|
|
1424
1533
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1425
1534
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1426
1535
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1428,7 +1537,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1428
1537
|
)}
|
|
1429
1538
|
}
|
|
1430
1539
|
`,
|
|
1431
|
-
dts:
|
|
1540
|
+
dts: outdent20`
|
|
1432
1541
|
import type { FunctionComponent } from '@builder.io/qwik'
|
|
1433
1542
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1434
1543
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1447,15 +1556,15 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1447
1556
|
}
|
|
1448
1557
|
|
|
1449
1558
|
// src/artifacts/qwik-jsx/types.ts
|
|
1450
|
-
import { outdent as
|
|
1559
|
+
import { outdent as outdent21 } from "outdent";
|
|
1451
1560
|
function generateQwikJsxTypes(ctx) {
|
|
1452
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1561
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1453
1562
|
return {
|
|
1454
|
-
jsxFactory:
|
|
1563
|
+
jsxFactory: outdent21`
|
|
1455
1564
|
import { ${upperName} } from '../types/jsx'
|
|
1456
1565
|
export declare const ${factoryName}: ${upperName}
|
|
1457
1566
|
`,
|
|
1458
|
-
jsxType:
|
|
1567
|
+
jsxType: outdent21`
|
|
1459
1568
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1460
1569
|
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1461
1570
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1491,7 +1600,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = Funct
|
|
|
1491
1600
|
type RecipeFn = { __type: any }
|
|
1492
1601
|
|
|
1493
1602
|
interface JsxFactory {
|
|
1494
|
-
|
|
1603
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1495
1604
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1496
1605
|
T,
|
|
1497
1606
|
RecipeSelection<P>
|
|
@@ -1501,7 +1610,7 @@ interface JsxFactory {
|
|
|
1501
1610
|
|
|
1502
1611
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1503
1612
|
|
|
1504
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1613
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1505
1614
|
|
|
1506
1615
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1507
1616
|
`
|
|
@@ -1509,35 +1618,35 @@ export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxSt
|
|
|
1509
1618
|
}
|
|
1510
1619
|
|
|
1511
1620
|
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1512
|
-
import { outdent as
|
|
1621
|
+
import { outdent as outdent22 } from "outdent";
|
|
1513
1622
|
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1514
1623
|
const { factoryName, componentName } = ctx.jsx;
|
|
1515
1624
|
return {
|
|
1516
|
-
js:
|
|
1625
|
+
js: outdent22`
|
|
1517
1626
|
import { h } from '@builder.io/qwik'
|
|
1518
1627
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1519
|
-
|
|
1628
|
+
|
|
1520
1629
|
function createStyledFn(Dynamic) {
|
|
1521
1630
|
return function styledFn(template) {
|
|
1522
1631
|
const baseClassName = css(template)
|
|
1523
1632
|
const ${componentName} = function ${componentName}(props) {
|
|
1524
1633
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1525
1634
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1526
|
-
|
|
1635
|
+
|
|
1527
1636
|
return h(Element, {
|
|
1528
1637
|
...elementProps,
|
|
1529
1638
|
className: classes(),
|
|
1530
1639
|
})
|
|
1531
1640
|
}
|
|
1532
|
-
|
|
1641
|
+
|
|
1533
1642
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1534
1643
|
return ${componentName}
|
|
1535
1644
|
}
|
|
1536
1645
|
}
|
|
1537
|
-
|
|
1646
|
+
|
|
1538
1647
|
function createJsxFactory() {
|
|
1539
1648
|
const cache = new Map()
|
|
1540
|
-
|
|
1649
|
+
|
|
1541
1650
|
return new Proxy(createStyledFn, {
|
|
1542
1651
|
apply(_, __, args) {
|
|
1543
1652
|
return createStyledFn(...args)
|
|
@@ -1551,22 +1660,22 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1551
1660
|
})
|
|
1552
1661
|
}
|
|
1553
1662
|
|
|
1554
|
-
export const ${factoryName} = createJsxFactory()
|
|
1663
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1555
1664
|
|
|
1556
1665
|
`
|
|
1557
1666
|
};
|
|
1558
1667
|
}
|
|
1559
1668
|
|
|
1560
1669
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1561
|
-
import { outdent as
|
|
1670
|
+
import { outdent as outdent23 } from "outdent";
|
|
1562
1671
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1563
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1672
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1564
1673
|
return {
|
|
1565
|
-
jsxFactory:
|
|
1674
|
+
jsxFactory: outdent23`
|
|
1566
1675
|
import { ${upperName} } from '../types/jsx'
|
|
1567
1676
|
export declare const ${factoryName}: ${upperName}
|
|
1568
1677
|
`,
|
|
1569
|
-
jsxType:
|
|
1678
|
+
jsxType: outdent23`
|
|
1570
1679
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1571
1680
|
|
|
1572
1681
|
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
@@ -1589,7 +1698,7 @@ interface JsxFactory {
|
|
|
1589
1698
|
|
|
1590
1699
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1591
1700
|
|
|
1592
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1701
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1593
1702
|
|
|
1594
1703
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1595
1704
|
`
|
|
@@ -1597,41 +1706,76 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1597
1706
|
}
|
|
1598
1707
|
|
|
1599
1708
|
// src/artifacts/react-jsx/jsx.ts
|
|
1600
|
-
import { outdent as
|
|
1709
|
+
import { outdent as outdent24 } from "outdent";
|
|
1710
|
+
import { match as match6 } from "ts-pattern";
|
|
1601
1711
|
function generateReactJsxFactory(ctx) {
|
|
1602
1712
|
const { factoryName, componentName } = ctx.jsx;
|
|
1603
1713
|
return {
|
|
1604
|
-
js:
|
|
1714
|
+
js: outdent24`
|
|
1605
1715
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1606
1716
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1607
1717
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1608
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1609
|
-
|
|
1718
|
+
${ctx.jsx.styleProps === "all" ? ctx.file.import("isCssProperty", "./is-valid-prop") : ""}
|
|
1719
|
+
|
|
1610
1720
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1611
1721
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1612
|
-
|
|
1613
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1722
|
+
|
|
1723
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1614
1724
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1615
|
-
|
|
1616
|
-
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1617
|
-
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1618
|
-
}, [restProps])
|
|
1619
1725
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1726
|
+
${match6(ctx.jsx.styleProps).with("all", () => {
|
|
1727
|
+
return outdent24`
|
|
1728
|
+
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1729
|
+
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1730
|
+
}, [restProps])
|
|
1731
|
+
|
|
1732
|
+
function recipeClass() {
|
|
1733
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1734
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1735
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
function cvaClass() {
|
|
1739
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1740
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1741
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1742
|
+
return cx(css(styles), elementProps.className)
|
|
1743
|
+
}`;
|
|
1744
|
+
}).with("minimal", () => {
|
|
1745
|
+
return outdent24`
|
|
1746
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1747
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1748
|
+
}, [restProps])
|
|
1749
|
+
|
|
1750
|
+
function recipeClass() {
|
|
1751
|
+
return cx(cvaFn(variantProps), css(assignCss(elementProps.css)), elementProps.className)
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
function cvaClass() {
|
|
1755
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1756
|
+
const styles = assignCss(cvaStyles, elementProps.css)
|
|
1757
|
+
return cx(css(styles), elementProps.className)
|
|
1758
|
+
}`;
|
|
1759
|
+
}).with("none", () => {
|
|
1760
|
+
return outdent24`
|
|
1761
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1762
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1763
|
+
}, [restProps])
|
|
1764
|
+
|
|
1765
|
+
function recipeClass() {
|
|
1766
|
+
return cx(cvaFn(variantProps), elementProps.className)
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
function cvaClass() {
|
|
1770
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1771
|
+
const styles = assignCss(cvaStyles)
|
|
1772
|
+
return cx(css(styles), elementProps.className)
|
|
1773
|
+
}`;
|
|
1774
|
+
}).run()}
|
|
1775
|
+
|
|
1776
|
+
|
|
1633
1777
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1634
|
-
|
|
1778
|
+
|
|
1635
1779
|
return createElement(Element, {
|
|
1636
1780
|
ref,
|
|
1637
1781
|
...elementProps,
|
|
@@ -1639,14 +1783,14 @@ function generateReactJsxFactory(ctx) {
|
|
|
1639
1783
|
className: classes(),
|
|
1640
1784
|
})
|
|
1641
1785
|
})
|
|
1642
|
-
|
|
1786
|
+
|
|
1643
1787
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1644
1788
|
return ${componentName}
|
|
1645
1789
|
}
|
|
1646
|
-
|
|
1790
|
+
|
|
1647
1791
|
function createJsxFactory() {
|
|
1648
1792
|
const cache = new Map()
|
|
1649
|
-
|
|
1793
|
+
|
|
1650
1794
|
return new Proxy(styledFn, {
|
|
1651
1795
|
apply(_, __, args) {
|
|
1652
1796
|
return styledFn(...args)
|
|
@@ -1660,15 +1804,15 @@ function generateReactJsxFactory(ctx) {
|
|
|
1660
1804
|
})
|
|
1661
1805
|
}
|
|
1662
1806
|
|
|
1663
|
-
export const ${factoryName} = createJsxFactory()
|
|
1807
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1664
1808
|
|
|
1665
1809
|
`
|
|
1666
1810
|
};
|
|
1667
1811
|
}
|
|
1668
1812
|
|
|
1669
1813
|
// src/artifacts/react-jsx/pattern.ts
|
|
1670
|
-
import { outdent as
|
|
1671
|
-
import { match as
|
|
1814
|
+
import { outdent as outdent25 } from "outdent";
|
|
1815
|
+
import { match as match7 } from "ts-pattern";
|
|
1672
1816
|
function generateReactJsxPattern(ctx) {
|
|
1673
1817
|
const { typeName, factoryName } = ctx.jsx;
|
|
1674
1818
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1676,34 +1820,34 @@ function generateReactJsxPattern(ctx) {
|
|
|
1676
1820
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1677
1821
|
return {
|
|
1678
1822
|
name: dashName,
|
|
1679
|
-
js:
|
|
1823
|
+
js: outdent25`
|
|
1680
1824
|
import { createElement, forwardRef } from 'react'
|
|
1681
1825
|
${ctx.file.import(factoryName, "./factory")}
|
|
1682
1826
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1683
|
-
|
|
1684
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1685
|
-
${
|
|
1827
|
+
|
|
1828
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1829
|
+
${match7(props.length).with(
|
|
1686
1830
|
0,
|
|
1687
|
-
() =>
|
|
1831
|
+
() => outdent25`
|
|
1688
1832
|
const styleProps = ${styleFnName}()
|
|
1689
1833
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1690
1834
|
`
|
|
1691
1835
|
).otherwise(
|
|
1692
|
-
() =>
|
|
1836
|
+
() => outdent25`
|
|
1693
1837
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1694
1838
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1695
1839
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1696
1840
|
`
|
|
1697
1841
|
)}
|
|
1698
|
-
})
|
|
1842
|
+
})
|
|
1699
1843
|
`,
|
|
1700
|
-
dts:
|
|
1844
|
+
dts: outdent25`
|
|
1701
1845
|
import type { FunctionComponent } from 'react'
|
|
1702
1846
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1703
1847
|
import type { ${typeName} } from '../types/jsx'
|
|
1704
|
-
|
|
1848
|
+
|
|
1705
1849
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1706
|
-
|
|
1850
|
+
|
|
1707
1851
|
${description ? `/** ${description} */` : ""}
|
|
1708
1852
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1709
1853
|
`
|
|
@@ -1712,15 +1856,15 @@ function generateReactJsxPattern(ctx) {
|
|
|
1712
1856
|
}
|
|
1713
1857
|
|
|
1714
1858
|
// src/artifacts/react-jsx/types.ts
|
|
1715
|
-
import { outdent as
|
|
1859
|
+
import { outdent as outdent26 } from "outdent";
|
|
1716
1860
|
function generateReactJsxTypes(ctx) {
|
|
1717
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1861
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1718
1862
|
return {
|
|
1719
|
-
jsxFactory:
|
|
1863
|
+
jsxFactory: outdent26`
|
|
1720
1864
|
import { ${upperName} } from '../types/jsx'
|
|
1721
1865
|
export declare const ${factoryName}: ${upperName}
|
|
1722
1866
|
`,
|
|
1723
|
-
jsxType:
|
|
1867
|
+
jsxType: outdent26`
|
|
1724
1868
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1725
1869
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1726
1870
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1739,7 +1883,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1739
1883
|
type RecipeFn = { __type: any }
|
|
1740
1884
|
|
|
1741
1885
|
interface JsxFactory {
|
|
1742
|
-
|
|
1886
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1743
1887
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1744
1888
|
T,
|
|
1745
1889
|
RecipeSelection<P>
|
|
@@ -1749,7 +1893,7 @@ interface JsxFactory {
|
|
|
1749
1893
|
|
|
1750
1894
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1751
1895
|
|
|
1752
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1896
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1753
1897
|
|
|
1754
1898
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1755
1899
|
`
|
|
@@ -1757,36 +1901,36 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1757
1901
|
}
|
|
1758
1902
|
|
|
1759
1903
|
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
1760
|
-
import { outdent as
|
|
1904
|
+
import { outdent as outdent27 } from "outdent";
|
|
1761
1905
|
function generateReactJsxStringLiteralFactory(ctx) {
|
|
1762
1906
|
const { factoryName, componentName } = ctx.jsx;
|
|
1763
1907
|
return {
|
|
1764
|
-
js:
|
|
1908
|
+
js: outdent27`
|
|
1765
1909
|
import { createElement, forwardRef } from 'react'
|
|
1766
1910
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1767
|
-
|
|
1911
|
+
|
|
1768
1912
|
function createStyledFn(Dynamic) {
|
|
1769
1913
|
return function styledFn(template) {
|
|
1770
1914
|
const baseClassName = css(template)
|
|
1771
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1915
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1772
1916
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1773
1917
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1774
|
-
|
|
1918
|
+
|
|
1775
1919
|
return createElement(Element, {
|
|
1776
1920
|
ref,
|
|
1777
1921
|
...elementProps,
|
|
1778
1922
|
className: classes(),
|
|
1779
1923
|
})
|
|
1780
1924
|
})
|
|
1781
|
-
|
|
1925
|
+
|
|
1782
1926
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1783
1927
|
return ${componentName}
|
|
1784
1928
|
}
|
|
1785
1929
|
}
|
|
1786
|
-
|
|
1930
|
+
|
|
1787
1931
|
function createJsxFactory() {
|
|
1788
1932
|
const cache = new Map()
|
|
1789
|
-
|
|
1933
|
+
|
|
1790
1934
|
return new Proxy(createStyledFn, {
|
|
1791
1935
|
apply(_, __, args) {
|
|
1792
1936
|
return createStyledFn(...args)
|
|
@@ -1800,22 +1944,22 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
1800
1944
|
})
|
|
1801
1945
|
}
|
|
1802
1946
|
|
|
1803
|
-
export const ${factoryName} = createJsxFactory()
|
|
1947
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1804
1948
|
|
|
1805
1949
|
`
|
|
1806
1950
|
};
|
|
1807
1951
|
}
|
|
1808
1952
|
|
|
1809
1953
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
1810
|
-
import { outdent as
|
|
1954
|
+
import { outdent as outdent28 } from "outdent";
|
|
1811
1955
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
1812
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1956
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1813
1957
|
return {
|
|
1814
|
-
jsxFactory:
|
|
1958
|
+
jsxFactory: outdent28`
|
|
1815
1959
|
import { ${upperName} } from '../types/jsx'
|
|
1816
1960
|
export declare const ${factoryName}: ${upperName}
|
|
1817
1961
|
`,
|
|
1818
|
-
jsxType:
|
|
1962
|
+
jsxType: outdent28`
|
|
1819
1963
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1820
1964
|
|
|
1821
1965
|
type Dict = Record<string, unknown>
|
|
@@ -1835,7 +1979,7 @@ interface JsxFactory {
|
|
|
1835
1979
|
|
|
1836
1980
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1837
1981
|
|
|
1838
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1982
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1839
1983
|
|
|
1840
1984
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1841
1985
|
`
|
|
@@ -1843,24 +1987,24 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1843
1987
|
}
|
|
1844
1988
|
|
|
1845
1989
|
// src/artifacts/solid-jsx/jsx.ts
|
|
1846
|
-
import { outdent as
|
|
1990
|
+
import { outdent as outdent29 } from "outdent";
|
|
1847
1991
|
function generateSolidJsxFactory(ctx) {
|
|
1848
1992
|
const { componentName, factoryName } = ctx.jsx;
|
|
1849
1993
|
return {
|
|
1850
|
-
js:
|
|
1994
|
+
js: outdent29`
|
|
1851
1995
|
import { Dynamic } from 'solid-js/web'
|
|
1852
1996
|
import { mergeProps, splitProps } from 'solid-js'
|
|
1853
1997
|
import { createComponent } from 'solid-js/web'
|
|
1854
1998
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1855
1999
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
1856
2000
|
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
1857
|
-
|
|
2001
|
+
|
|
1858
2002
|
function styledFn(element, configOrCva = {}) {
|
|
1859
2003
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1860
|
-
|
|
2004
|
+
|
|
1861
2005
|
return function ${componentName}(props) {
|
|
1862
2006
|
const mergedProps = mergeProps({ as: element }, props)
|
|
1863
|
-
|
|
2007
|
+
|
|
1864
2008
|
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
1865
2009
|
mergedProps,
|
|
1866
2010
|
['as', 'class'],
|
|
@@ -1874,16 +2018,16 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1874
2018
|
const styles = assignCss(propStyles, cssStyles)
|
|
1875
2019
|
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1876
2020
|
}
|
|
1877
|
-
|
|
2021
|
+
|
|
1878
2022
|
function cvaClass() {
|
|
1879
2023
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1880
2024
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1881
2025
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1882
2026
|
return cx(css(styles), localProps.class)
|
|
1883
2027
|
}
|
|
1884
|
-
|
|
2028
|
+
|
|
1885
2029
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1886
|
-
|
|
2030
|
+
|
|
1887
2031
|
return createComponent(
|
|
1888
2032
|
Dynamic,
|
|
1889
2033
|
mergeProps(
|
|
@@ -1901,10 +2045,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1901
2045
|
)
|
|
1902
2046
|
}
|
|
1903
2047
|
}
|
|
1904
|
-
|
|
2048
|
+
|
|
1905
2049
|
function createJsxFactory() {
|
|
1906
2050
|
const cache = new Map()
|
|
1907
|
-
|
|
2051
|
+
|
|
1908
2052
|
return new Proxy(styledFn, {
|
|
1909
2053
|
apply(_, __, args) {
|
|
1910
2054
|
return styledFn(...args)
|
|
@@ -1917,15 +2061,15 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1917
2061
|
},
|
|
1918
2062
|
})
|
|
1919
2063
|
}
|
|
1920
|
-
|
|
1921
|
-
export const ${factoryName} = createJsxFactory()
|
|
2064
|
+
|
|
2065
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1922
2066
|
`
|
|
1923
2067
|
};
|
|
1924
2068
|
}
|
|
1925
2069
|
|
|
1926
2070
|
// src/artifacts/solid-jsx/pattern.ts
|
|
1927
|
-
import { outdent as
|
|
1928
|
-
import { match as
|
|
2071
|
+
import { outdent as outdent30 } from "outdent";
|
|
2072
|
+
import { match as match8 } from "ts-pattern";
|
|
1929
2073
|
function generateSolidJsxPattern(ctx) {
|
|
1930
2074
|
const { typeName, factoryName } = ctx.jsx;
|
|
1931
2075
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1933,21 +2077,21 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1933
2077
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1934
2078
|
return {
|
|
1935
2079
|
name: dashName,
|
|
1936
|
-
js:
|
|
2080
|
+
js: outdent30`
|
|
1937
2081
|
import { splitProps, mergeProps } from 'solid-js'
|
|
1938
2082
|
import { createComponent } from 'solid-js/web'
|
|
1939
2083
|
${ctx.file.import(factoryName, "./factory")}
|
|
1940
2084
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1941
2085
|
|
|
1942
2086
|
export function ${jsxName}(props) {
|
|
1943
|
-
${
|
|
2087
|
+
${match8(props.length).with(
|
|
1944
2088
|
0,
|
|
1945
|
-
() =>
|
|
2089
|
+
() => outdent30`
|
|
1946
2090
|
const styleProps = ${styleFnName}()
|
|
1947
2091
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
1948
2092
|
`
|
|
1949
2093
|
).otherwise(
|
|
1950
|
-
() =>
|
|
2094
|
+
() => outdent30`
|
|
1951
2095
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
1952
2096
|
const styleProps = ${styleFnName}(patternProps)
|
|
1953
2097
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -1955,7 +2099,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1955
2099
|
)}
|
|
1956
2100
|
}
|
|
1957
2101
|
`,
|
|
1958
|
-
dts:
|
|
2102
|
+
dts: outdent30`
|
|
1959
2103
|
import { Component } from 'solid-js'
|
|
1960
2104
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1961
2105
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1970,15 +2114,15 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1970
2114
|
}
|
|
1971
2115
|
|
|
1972
2116
|
// src/artifacts/solid-jsx/types.ts
|
|
1973
|
-
import { outdent as
|
|
2117
|
+
import { outdent as outdent31 } from "outdent";
|
|
1974
2118
|
function generateSolidJsxTypes(ctx) {
|
|
1975
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2119
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1976
2120
|
return {
|
|
1977
|
-
jsxFactory:
|
|
2121
|
+
jsxFactory: outdent31`
|
|
1978
2122
|
import type { ${upperName} } from '../types/jsx'
|
|
1979
2123
|
export declare const ${factoryName}: ${upperName}
|
|
1980
2124
|
`,
|
|
1981
|
-
jsxType:
|
|
2125
|
+
jsxType: outdent31`
|
|
1982
2126
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1983
2127
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1984
2128
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1995,7 +2139,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1995
2139
|
type RecipeFn = { __type: any }
|
|
1996
2140
|
|
|
1997
2141
|
interface JsxFactory {
|
|
1998
|
-
|
|
2142
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1999
2143
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2000
2144
|
T,
|
|
2001
2145
|
RecipeSelection<P>
|
|
@@ -2005,7 +2149,7 @@ interface JsxFactory {
|
|
|
2005
2149
|
|
|
2006
2150
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2007
2151
|
|
|
2008
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2152
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2009
2153
|
|
|
2010
2154
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2011
2155
|
`
|
|
@@ -2013,11 +2157,11 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
2013
2157
|
}
|
|
2014
2158
|
|
|
2015
2159
|
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
2016
|
-
import { outdent as
|
|
2160
|
+
import { outdent as outdent32 } from "outdent";
|
|
2017
2161
|
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
2018
2162
|
const { componentName, factoryName } = ctx.jsx;
|
|
2019
2163
|
return {
|
|
2020
|
-
js:
|
|
2164
|
+
js: outdent32`
|
|
2021
2165
|
import { mergeProps, splitProps } from 'solid-js'
|
|
2022
2166
|
import { Dynamic, createComponent } from 'solid-js/web'
|
|
2023
2167
|
${ctx.file.import("css, cx", "../css/index")}
|
|
@@ -2028,7 +2172,7 @@ function createStyled(element) {
|
|
|
2028
2172
|
return function ${componentName}(props) {
|
|
2029
2173
|
const mergedProps = mergeProps({ as: element }, props)
|
|
2030
2174
|
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2031
|
-
|
|
2175
|
+
|
|
2032
2176
|
return createComponent(
|
|
2033
2177
|
Dynamic,
|
|
2034
2178
|
mergeProps(
|
|
@@ -2063,21 +2207,21 @@ function createJsxFactory() {
|
|
|
2063
2207
|
})
|
|
2064
2208
|
}
|
|
2065
2209
|
|
|
2066
|
-
export const ${factoryName} = createJsxFactory()
|
|
2210
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2067
2211
|
`
|
|
2068
2212
|
};
|
|
2069
2213
|
}
|
|
2070
2214
|
|
|
2071
2215
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2072
|
-
import { outdent as
|
|
2216
|
+
import { outdent as outdent33 } from "outdent";
|
|
2073
2217
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2074
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2218
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2075
2219
|
return {
|
|
2076
|
-
jsxFactory:
|
|
2220
|
+
jsxFactory: outdent33`
|
|
2077
2221
|
import type { ${upperName} } from '../types/jsx'
|
|
2078
2222
|
export declare const ${factoryName}: ${upperName}
|
|
2079
2223
|
`,
|
|
2080
|
-
jsxType:
|
|
2224
|
+
jsxType: outdent33`
|
|
2081
2225
|
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2082
2226
|
|
|
2083
2227
|
type Dict = Record<string, unknown>
|
|
@@ -2095,7 +2239,7 @@ interface JsxFactory {
|
|
|
2095
2239
|
|
|
2096
2240
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2097
2241
|
|
|
2098
|
-
export type
|
|
2242
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2099
2243
|
|
|
2100
2244
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2101
2245
|
`
|
|
@@ -2103,16 +2247,16 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2103
2247
|
}
|
|
2104
2248
|
|
|
2105
2249
|
// src/artifacts/vue-jsx/jsx.ts
|
|
2106
|
-
import { outdent as
|
|
2250
|
+
import { outdent as outdent34 } from "outdent";
|
|
2107
2251
|
function generateVueJsxFactory(ctx) {
|
|
2108
2252
|
const { factoryName } = ctx.jsx;
|
|
2109
2253
|
return {
|
|
2110
|
-
js:
|
|
2254
|
+
js: outdent34`
|
|
2111
2255
|
import { defineComponent, h, computed } from 'vue'
|
|
2112
2256
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
2113
2257
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2114
2258
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2115
|
-
|
|
2259
|
+
|
|
2116
2260
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
2117
2261
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2118
2262
|
|
|
@@ -2140,10 +2284,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2140
2284
|
})
|
|
2141
2285
|
|
|
2142
2286
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2143
|
-
|
|
2287
|
+
|
|
2144
2288
|
return () => {
|
|
2145
2289
|
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
2146
|
-
|
|
2290
|
+
|
|
2147
2291
|
return h(
|
|
2148
2292
|
props.as,
|
|
2149
2293
|
{
|
|
@@ -2157,10 +2301,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2157
2301
|
},
|
|
2158
2302
|
})
|
|
2159
2303
|
}
|
|
2160
|
-
|
|
2304
|
+
|
|
2161
2305
|
function createJsxFactory() {
|
|
2162
2306
|
const cache = new Map()
|
|
2163
|
-
|
|
2307
|
+
|
|
2164
2308
|
return new Proxy(styledFn, {
|
|
2165
2309
|
apply(_, __, args) {
|
|
2166
2310
|
return styledFn(...args)
|
|
@@ -2174,21 +2318,21 @@ function generateVueJsxFactory(ctx) {
|
|
|
2174
2318
|
})
|
|
2175
2319
|
}
|
|
2176
2320
|
|
|
2177
|
-
export const ${factoryName} = createJsxFactory()
|
|
2321
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2178
2322
|
|
|
2179
2323
|
`
|
|
2180
2324
|
};
|
|
2181
2325
|
}
|
|
2182
2326
|
|
|
2183
2327
|
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2184
|
-
import { outdent as
|
|
2328
|
+
import { outdent as outdent35 } from "outdent";
|
|
2185
2329
|
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2186
2330
|
const { factoryName } = ctx.jsx;
|
|
2187
2331
|
return {
|
|
2188
|
-
js:
|
|
2332
|
+
js: outdent35`
|
|
2189
2333
|
import { defineComponent, h, computed } from 'vue'
|
|
2190
2334
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2191
|
-
|
|
2335
|
+
|
|
2192
2336
|
function createStyled(Dynamic) {
|
|
2193
2337
|
function styledFn(template) {
|
|
2194
2338
|
const baseClassName = css(template)
|
|
@@ -2212,10 +2356,10 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2212
2356
|
})
|
|
2213
2357
|
}
|
|
2214
2358
|
}
|
|
2215
|
-
|
|
2359
|
+
|
|
2216
2360
|
function createJsxFactory() {
|
|
2217
2361
|
const cache = new Map()
|
|
2218
|
-
|
|
2362
|
+
|
|
2219
2363
|
return new Proxy(createStyled, {
|
|
2220
2364
|
apply(_, __, args) {
|
|
2221
2365
|
return createStyled(...args)
|
|
@@ -2229,13 +2373,13 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2229
2373
|
})
|
|
2230
2374
|
}
|
|
2231
2375
|
|
|
2232
|
-
export const ${factoryName} = createJsxFactory()
|
|
2376
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2233
2377
|
`
|
|
2234
2378
|
};
|
|
2235
2379
|
}
|
|
2236
2380
|
|
|
2237
2381
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2238
|
-
import { outdent as
|
|
2382
|
+
import { outdent as outdent36 } from "outdent";
|
|
2239
2383
|
function generateVueJsxPattern(ctx) {
|
|
2240
2384
|
const { typeName, factoryName } = ctx.jsx;
|
|
2241
2385
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2244,7 +2388,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2244
2388
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2245
2389
|
return {
|
|
2246
2390
|
name: dashName,
|
|
2247
|
-
js:
|
|
2391
|
+
js: outdent36`
|
|
2248
2392
|
import { defineComponent, h, computed } from 'vue'
|
|
2249
2393
|
${ctx.file.import(factoryName, "./factory")}
|
|
2250
2394
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -2262,7 +2406,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2262
2406
|
}
|
|
2263
2407
|
})
|
|
2264
2408
|
`,
|
|
2265
|
-
dts:
|
|
2409
|
+
dts: outdent36`
|
|
2266
2410
|
import { FunctionalComponent } from 'vue'
|
|
2267
2411
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
2268
2412
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -2277,15 +2421,15 @@ function generateVueJsxPattern(ctx) {
|
|
|
2277
2421
|
}
|
|
2278
2422
|
|
|
2279
2423
|
// src/artifacts/vue-jsx/types.ts
|
|
2280
|
-
import { outdent as
|
|
2424
|
+
import { outdent as outdent37 } from "outdent";
|
|
2281
2425
|
function generateVueJsxTypes(ctx) {
|
|
2282
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2426
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2283
2427
|
return {
|
|
2284
|
-
jsxFactory:
|
|
2428
|
+
jsxFactory: outdent37`
|
|
2285
2429
|
import { ${upperName} } from '../types/jsx'
|
|
2286
2430
|
export declare const ${factoryName}: ${upperName}
|
|
2287
2431
|
`,
|
|
2288
|
-
jsxType:
|
|
2432
|
+
jsxType: outdent37`
|
|
2289
2433
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2290
2434
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
2291
2435
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -2424,33 +2568,33 @@ type IntrinsicElement =
|
|
|
2424
2568
|
type RecipeFn = { __type: any }
|
|
2425
2569
|
|
|
2426
2570
|
interface JsxFactory {
|
|
2427
|
-
|
|
2571
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2428
2572
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2429
2573
|
T,
|
|
2430
2574
|
RecipeSelection<P>
|
|
2431
2575
|
>
|
|
2432
2576
|
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2433
2577
|
}
|
|
2434
|
-
|
|
2578
|
+
|
|
2435
2579
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2436
|
-
|
|
2437
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2438
|
-
|
|
2580
|
+
|
|
2581
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2582
|
+
|
|
2439
2583
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2440
2584
|
`
|
|
2441
2585
|
};
|
|
2442
2586
|
}
|
|
2443
2587
|
|
|
2444
2588
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2445
|
-
import { outdent as
|
|
2589
|
+
import { outdent as outdent38 } from "outdent";
|
|
2446
2590
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2447
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2591
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2448
2592
|
return {
|
|
2449
|
-
jsxFactory:
|
|
2593
|
+
jsxFactory: outdent38`
|
|
2450
2594
|
import { ${upperName} } from '../types/jsx'
|
|
2451
2595
|
export declare const ${factoryName}: ${upperName}
|
|
2452
2596
|
`,
|
|
2453
|
-
jsxType:
|
|
2597
|
+
jsxType: outdent38`
|
|
2454
2598
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2455
2599
|
|
|
2456
2600
|
type IntrinsicElement =
|
|
@@ -2586,11 +2730,11 @@ type IntrinsicElement =
|
|
|
2586
2730
|
interface JsxFactory {
|
|
2587
2731
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2588
2732
|
}
|
|
2589
|
-
|
|
2733
|
+
|
|
2590
2734
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2591
|
-
|
|
2592
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2593
|
-
|
|
2735
|
+
|
|
2736
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2737
|
+
|
|
2594
2738
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2595
2739
|
`
|
|
2596
2740
|
};
|
|
@@ -2605,8 +2749,8 @@ var typesMap = {
|
|
|
2605
2749
|
qwik: generateQwikJsxTypes
|
|
2606
2750
|
};
|
|
2607
2751
|
var typesStringLiteralMap = {
|
|
2608
|
-
react:
|
|
2609
|
-
solid:
|
|
2752
|
+
react: generateReactJsxStringLiteralTypes,
|
|
2753
|
+
solid: generateSolidJsxStringLiteralTypes,
|
|
2610
2754
|
qwik: generateQwikJsxStringLiteralTypes,
|
|
2611
2755
|
preact: generatePreactJsxStringLiteralTypes,
|
|
2612
2756
|
vue: generateVueJsxStringLiteralTypes
|
|
@@ -2704,7 +2848,7 @@ var csstype_d_ts_default = {
|
|
|
2704
2848
|
|
|
2705
2849
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2706
2850
|
var system_types_d_ts_default = {
|
|
2707
|
-
content: "import type { ConditionalValue, Conditions, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport type CssProperties = PropertiesFallback<String | Number> & CssVarProperties\n\nexport type CssKeyframes = {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ntype MinimalNested<P> = {\n [K in keyof Conditions]?: Nested<P>\n}\n\ntype GenericProperties = {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport type GlobalStyleObject = {\n [selector: string]: SystemStyleObject\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<{\n [K in Property]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\n\nexport type JsxStyleProps =
|
|
2851
|
+
content: "import type { ConditionalValue, Conditions, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport type CssProperties = PropertiesFallback<String | Number> & CssVarProperties\n\nexport type CssKeyframes = {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ntype MinimalNested<P> = {\n [K in keyof Conditions]?: Nested<P>\n}\n\ntype GenericProperties = {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport type GlobalStyleObject = {\n [selector: string]: SystemStyleObject\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<{\n [K in Property]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ntype WithCss = { css?: SystemStyleObject }\ntype StyleProps = SystemProperties & MinimalNested<SystemStyleObject>\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport type Assign<T, U> = Omit<T, keyof U> & U\n\nexport type PatchedHTMLProps = {\n htmlSize?: string | number\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'size' | 'content'\n\ntype WithHTMLProps<T> = Omit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n"
|
|
2708
2852
|
};
|
|
2709
2853
|
|
|
2710
2854
|
// src/artifacts/generated/composition.d.ts.json
|
|
@@ -2714,7 +2858,7 @@ var composition_d_ts_default = {
|
|
|
2714
2858
|
|
|
2715
2859
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2716
2860
|
var recipe_d_ts_default = {
|
|
2717
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> =
|
|
2861
|
+
content: "import type { SystemStyleObject } 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 resolve: (props: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<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"
|
|
2718
2862
|
};
|
|
2719
2863
|
|
|
2720
2864
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2733,7 +2877,9 @@ var selectors_d_ts_default = {
|
|
|
2733
2877
|
};
|
|
2734
2878
|
|
|
2735
2879
|
// src/artifacts/types/generated.ts
|
|
2736
|
-
|
|
2880
|
+
import { match as match9 } from "ts-pattern";
|
|
2881
|
+
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2882
|
+
function getGeneratedTypes(ctx) {
|
|
2737
2883
|
return {
|
|
2738
2884
|
cssType: csstype_d_ts_default.content,
|
|
2739
2885
|
recipe: recipe_d_ts_default.content,
|
|
@@ -2741,15 +2887,15 @@ function getGeneratedTypes() {
|
|
|
2741
2887
|
parts: parts_d_ts_default.content,
|
|
2742
2888
|
composition: composition_d_ts_default.content,
|
|
2743
2889
|
selectors: selectors_d_ts_default.content,
|
|
2744
|
-
system: system_types_d_ts_default.content
|
|
2890
|
+
system: match9(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with("minimal", () => system_types_d_ts_default.content.replace(jsxStyleProps, "export type JsxStyleProps = WithCss")).with("none", () => system_types_d_ts_default.content.replace(jsxStyleProps, "export type JsxStyleProps = {}")).exhaustive()
|
|
2745
2891
|
};
|
|
2746
2892
|
}
|
|
2747
2893
|
|
|
2748
2894
|
// src/artifacts/types/main.ts
|
|
2749
|
-
import { outdent as
|
|
2895
|
+
import { outdent as outdent39 } from "outdent";
|
|
2750
2896
|
var generateTypesEntry = () => ({
|
|
2751
|
-
global:
|
|
2752
|
-
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2897
|
+
global: outdent39`
|
|
2898
|
+
import type { RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig } from './recipe'
|
|
2753
2899
|
import type { Parts } from './parts'
|
|
2754
2900
|
import type { PatternConfig, PatternProperties } from './pattern'
|
|
2755
2901
|
import type { GlobalStyleObject, SystemStyleObject } from './system-types'
|
|
@@ -2757,27 +2903,28 @@ var generateTypesEntry = () => ({
|
|
|
2757
2903
|
|
|
2758
2904
|
declare module '@pandacss/dev' {
|
|
2759
2905
|
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig
|
|
2906
|
+
export function defineSlotRecipe<S extends string, V extends SlotRecipeVariantRecord<S>>(config: SlotRecipeConfig<S, V>): SlotRecipeConfig
|
|
2760
2907
|
export function defineStyles(definition: SystemStyleObject): SystemStyleObject
|
|
2761
2908
|
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
2762
2909
|
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
2763
2910
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
2764
2911
|
export function definePattern<T extends PatternProperties>(config: PatternConfig<T>): PatternConfig
|
|
2765
|
-
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject
|
|
2912
|
+
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2766
2913
|
}
|
|
2767
2914
|
`,
|
|
2768
|
-
index:
|
|
2915
|
+
index: outdent39`
|
|
2769
2916
|
import './global'
|
|
2770
2917
|
export type { ConditionalValue } from './conditions'
|
|
2771
2918
|
export type { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
2772
2919
|
|
|
2773
2920
|
`,
|
|
2774
|
-
helpers:
|
|
2921
|
+
helpers: outdent39`
|
|
2775
2922
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2776
2923
|
`
|
|
2777
2924
|
});
|
|
2778
2925
|
|
|
2779
2926
|
// src/artifacts/types/prop-types.ts
|
|
2780
|
-
import { outdent as
|
|
2927
|
+
import { outdent as outdent40 } from "outdent";
|
|
2781
2928
|
function generatePropTypes(ctx) {
|
|
2782
2929
|
const {
|
|
2783
2930
|
config: { strictTokens },
|
|
@@ -2785,7 +2932,7 @@ function generatePropTypes(ctx) {
|
|
|
2785
2932
|
} = ctx;
|
|
2786
2933
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2787
2934
|
const result = [
|
|
2788
|
-
|
|
2935
|
+
outdent40`
|
|
2789
2936
|
import type { ConditionalValue } from './conditions';
|
|
2790
2937
|
import type { CssProperties } from './system-types'
|
|
2791
2938
|
import type { Tokens } from '../tokens'
|
|
@@ -2808,7 +2955,7 @@ function generatePropTypes(ctx) {
|
|
|
2808
2955
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2809
2956
|
});
|
|
2810
2957
|
result.push("}");
|
|
2811
|
-
return
|
|
2958
|
+
return outdent40`
|
|
2812
2959
|
${result.join("\n")}
|
|
2813
2960
|
|
|
2814
2961
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2821,10 +2968,10 @@ function generatePropTypes(ctx) {
|
|
|
2821
2968
|
|
|
2822
2969
|
// src/artifacts/types/style-props.ts
|
|
2823
2970
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
2824
|
-
import
|
|
2971
|
+
import outdent41 from "outdent";
|
|
2825
2972
|
function generateStyleProps(ctx) {
|
|
2826
|
-
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
2827
|
-
return
|
|
2973
|
+
const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
2974
|
+
return outdent41`
|
|
2828
2975
|
import type { ConditionalValue } from './conditions'
|
|
2829
2976
|
import type { PropertyValue } from './prop-type'
|
|
2830
2977
|
import type { Token } from '../tokens'
|
|
@@ -2841,7 +2988,7 @@ function generateStyleProps(ctx) {
|
|
|
2841
2988
|
|
|
2842
2989
|
// src/artifacts/types/token-types.ts
|
|
2843
2990
|
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
2844
|
-
import { outdent as
|
|
2991
|
+
import { outdent as outdent42 } from "outdent";
|
|
2845
2992
|
import pluralize from "pluralize";
|
|
2846
2993
|
var categories = [
|
|
2847
2994
|
"zIndex",
|
|
@@ -2886,12 +3033,12 @@ function generateTokenTypes(ctx) {
|
|
|
2886
3033
|
result.add("} & { [token: string]: never }");
|
|
2887
3034
|
set.add(Array.from(result).join("\n"));
|
|
2888
3035
|
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
2889
|
-
return
|
|
3036
|
+
return outdent42.string(Array.from(set).join("\n\n"));
|
|
2890
3037
|
}
|
|
2891
3038
|
|
|
2892
3039
|
// src/artifacts/index.ts
|
|
2893
3040
|
function setupHelpers(ctx) {
|
|
2894
|
-
const code = generateHelpers();
|
|
3041
|
+
const code = generateHelpers(ctx);
|
|
2895
3042
|
return {
|
|
2896
3043
|
files: [{ file: ctx.file.ext("helpers"), code: code.js }]
|
|
2897
3044
|
};
|
|
@@ -2919,7 +3066,7 @@ function setupDesignTokens(ctx) {
|
|
|
2919
3066
|
};
|
|
2920
3067
|
}
|
|
2921
3068
|
function setupTypes(ctx) {
|
|
2922
|
-
const gen = getGeneratedTypes();
|
|
3069
|
+
const gen = getGeneratedTypes(ctx);
|
|
2923
3070
|
const conditions = generateConditions(ctx);
|
|
2924
3071
|
const jsx = generateJsxTypes(ctx);
|
|
2925
3072
|
const entry = generateTypesEntry();
|
|
@@ -2967,6 +3114,18 @@ function setupCva(ctx) {
|
|
|
2967
3114
|
]
|
|
2968
3115
|
};
|
|
2969
3116
|
}
|
|
3117
|
+
function setupSva(ctx) {
|
|
3118
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
3119
|
+
return;
|
|
3120
|
+
const code = generateSvaFn(ctx);
|
|
3121
|
+
return {
|
|
3122
|
+
dir: ctx.paths.css,
|
|
3123
|
+
files: [
|
|
3124
|
+
{ file: ctx.file.ext("sva"), code: code.js },
|
|
3125
|
+
{ file: "sva.d.ts", code: code.dts }
|
|
3126
|
+
]
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
2970
3129
|
function setupCx(ctx) {
|
|
2971
3130
|
const code = generateCx();
|
|
2972
3131
|
return {
|
|
@@ -2983,8 +3142,8 @@ function setupRecipes(ctx) {
|
|
|
2983
3142
|
return;
|
|
2984
3143
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2985
3144
|
const index = {
|
|
2986
|
-
js:
|
|
2987
|
-
dts:
|
|
3145
|
+
js: outdent43.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3146
|
+
dts: outdent43.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2988
3147
|
};
|
|
2989
3148
|
return {
|
|
2990
3149
|
dir: ctx.paths.recipe,
|
|
@@ -3003,8 +3162,8 @@ function setupPatterns(ctx) {
|
|
|
3003
3162
|
if (!files)
|
|
3004
3163
|
return;
|
|
3005
3164
|
const index = {
|
|
3006
|
-
js:
|
|
3007
|
-
dts:
|
|
3165
|
+
js: outdent43.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3166
|
+
dts: outdent43.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
3008
3167
|
};
|
|
3009
3168
|
return {
|
|
3010
3169
|
dir: ctx.paths.pattern,
|
|
@@ -3019,20 +3178,20 @@ function setupPatterns(ctx) {
|
|
|
3019
3178
|
function setupJsx(ctx) {
|
|
3020
3179
|
if (!ctx.jsx.framework)
|
|
3021
3180
|
return;
|
|
3022
|
-
const isValidProp =
|
|
3181
|
+
const isValidProp = generateIsValidProp(ctx);
|
|
3023
3182
|
const types = generateJsxTypes(ctx);
|
|
3024
3183
|
const factory = generateJsxFactory(ctx);
|
|
3025
3184
|
const patterns = generateJsxPatterns(ctx);
|
|
3026
3185
|
const index = {
|
|
3027
|
-
js:
|
|
3186
|
+
js: outdent43`
|
|
3028
3187
|
${ctx.file.export("./factory")}
|
|
3029
3188
|
${isValidProp?.js ? ctx.file.export("./is-valid-prop") : ""}
|
|
3030
|
-
${
|
|
3189
|
+
${outdent43.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
3031
3190
|
`,
|
|
3032
|
-
dts:
|
|
3191
|
+
dts: outdent43`
|
|
3033
3192
|
export * from './factory'
|
|
3034
3193
|
${isValidProp?.dts ? `export * from './is-valid-prop'` : ""}
|
|
3035
|
-
${
|
|
3194
|
+
${outdent43.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
3036
3195
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
3037
3196
|
`
|
|
3038
3197
|
};
|
|
@@ -3052,15 +3211,17 @@ function setupJsx(ctx) {
|
|
|
3052
3211
|
}
|
|
3053
3212
|
function setupCssIndex(ctx) {
|
|
3054
3213
|
const index = {
|
|
3055
|
-
js:
|
|
3214
|
+
js: outdent43`
|
|
3056
3215
|
${ctx.file.export("./css")}
|
|
3057
3216
|
${ctx.file.export("./cx")}
|
|
3058
3217
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./cva")}
|
|
3218
|
+
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./sva")}
|
|
3059
3219
|
`,
|
|
3060
|
-
dts:
|
|
3220
|
+
dts: outdent43`
|
|
3061
3221
|
export * from './css'
|
|
3062
3222
|
export * from './cx'
|
|
3063
3223
|
${ctx.isTemplateLiteralSyntax ? "" : `export * from './cva'`}
|
|
3224
|
+
${ctx.isTemplateLiteralSyntax ? "" : `export * from './sva'`}
|
|
3064
3225
|
`
|
|
3065
3226
|
};
|
|
3066
3227
|
return {
|
|
@@ -3104,6 +3265,7 @@ var generateArtifacts = (ctx) => () => {
|
|
|
3104
3265
|
setupKeyframes(ctx),
|
|
3105
3266
|
setupTypes(ctx),
|
|
3106
3267
|
setupCva(ctx),
|
|
3268
|
+
setupSva(ctx),
|
|
3107
3269
|
setupCx(ctx),
|
|
3108
3270
|
setupCss(ctx),
|
|
3109
3271
|
setupRecipes(ctx),
|
|
@@ -3154,7 +3316,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3154
3316
|
// src/artifacts/css/parser-css.ts
|
|
3155
3317
|
import { logger } from "@pandacss/logger";
|
|
3156
3318
|
import { pipe, tap, tryCatch } from "lil-fp/func";
|
|
3157
|
-
import { P, match as
|
|
3319
|
+
import { P, match as match10 } from "ts-pattern";
|
|
3158
3320
|
var generateParserCss = (ctx) => (result) => pipe(
|
|
3159
3321
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3160
3322
|
tap(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3168,6 +3330,11 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3168
3330
|
sheet.processAtomicRecipe(data);
|
|
3169
3331
|
});
|
|
3170
3332
|
});
|
|
3333
|
+
result2.sva.forEach((sva) => {
|
|
3334
|
+
sva.data.forEach((data) => {
|
|
3335
|
+
sheet.processAtomicSlotRecipe(data);
|
|
3336
|
+
});
|
|
3337
|
+
});
|
|
3171
3338
|
result2.jsx.forEach((jsx) => {
|
|
3172
3339
|
jsx.data.forEach((data) => {
|
|
3173
3340
|
sheet.processStyleProps(data);
|
|
@@ -3179,7 +3346,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3179
3346
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3180
3347
|
if (!recipeConfig)
|
|
3181
3348
|
continue;
|
|
3182
|
-
|
|
3349
|
+
match10(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3183
3350
|
recipe.data.forEach((data) => {
|
|
3184
3351
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3185
3352
|
sheet.processStyleProps(styleProps);
|
|
@@ -3198,7 +3365,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3198
3365
|
result2.pattern.forEach((patternSet, name) => {
|
|
3199
3366
|
try {
|
|
3200
3367
|
for (const pattern of patternSet) {
|
|
3201
|
-
|
|
3368
|
+
match10(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
|
|
3202
3369
|
pattern.data.forEach((data) => {
|
|
3203
3370
|
const fnName = patterns.getFnName(jsxName);
|
|
3204
3371
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -3292,11 +3459,13 @@ var getBaseEngine = (conf) => {
|
|
|
3292
3459
|
const sheetContext = createSheetContext();
|
|
3293
3460
|
return new Stylesheet(sheetContext, {
|
|
3294
3461
|
content: options?.content,
|
|
3295
|
-
recipes: theme?.recipes
|
|
3462
|
+
recipes: theme?.recipes,
|
|
3463
|
+
slotRecipes: theme?.slotRecipes
|
|
3296
3464
|
});
|
|
3297
3465
|
};
|
|
3298
3466
|
const recipeContext = createSheetContext();
|
|
3299
|
-
const
|
|
3467
|
+
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
3468
|
+
const recipes = new Recipes(recipeConfigs, recipeContext);
|
|
3300
3469
|
recipes.save();
|
|
3301
3470
|
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
3302
3471
|
const propertyMap = new Map(properties.map((prop) => [prop, true]));
|
|
@@ -3327,13 +3496,14 @@ var getBaseEngine = (conf) => {
|
|
|
3327
3496
|
// src/engines/jsx.ts
|
|
3328
3497
|
import { capitalize as capitalize2 } from "@pandacss/shared";
|
|
3329
3498
|
var getJsxEngine = (config) => {
|
|
3330
|
-
const { jsxFactory, jsxFramework } = config;
|
|
3499
|
+
const { jsxFactory, jsxFramework, jsxStyleProps: jsxStyleProps2 } = config;
|
|
3331
3500
|
return {
|
|
3332
3501
|
factoryName: jsxFactory,
|
|
3333
3502
|
upperName: capitalize2(jsxFactory),
|
|
3334
3503
|
typeName: `HTML${capitalize2(jsxFactory)}Props`,
|
|
3335
3504
|
componentName: `${capitalize2(jsxFactory)}Component`,
|
|
3336
|
-
framework: jsxFramework
|
|
3505
|
+
framework: jsxFramework,
|
|
3506
|
+
styleProps: jsxStyleProps2 ?? "all"
|
|
3337
3507
|
};
|
|
3338
3508
|
};
|
|
3339
3509
|
|
|
@@ -3355,12 +3525,8 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
|
3355
3525
|
};
|
|
3356
3526
|
|
|
3357
3527
|
// src/engines/pattern.ts
|
|
3358
|
-
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, memo as memo2, uncapitalize } from "@pandacss/shared";
|
|
3528
|
+
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, memo as memo2, uncapitalize, createRegex } from "@pandacss/shared";
|
|
3359
3529
|
var helpers2 = { map: mapObject2 };
|
|
3360
|
-
var createRegex = (item) => {
|
|
3361
|
-
const regex = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
|
|
3362
|
-
return new RegExp(`^${regex}$`);
|
|
3363
|
-
};
|
|
3364
3530
|
var getPatternEngine = (config) => {
|
|
3365
3531
|
const patterns = config.patterns ?? {};
|
|
3366
3532
|
const getNames = (name) => {
|
|
@@ -3428,6 +3594,7 @@ var defaults = (conf) => ({
|
|
|
3428
3594
|
config: {
|
|
3429
3595
|
cssVarRoot: ":where(:root, :host)",
|
|
3430
3596
|
jsxFactory: "styled",
|
|
3597
|
+
jsxStyleProps: "all",
|
|
3431
3598
|
outExtension: "mjs",
|
|
3432
3599
|
shorthands: true,
|
|
3433
3600
|
syntax: "object-literal",
|
|
@@ -3457,6 +3624,7 @@ var createGenerator = (conf) => {
|
|
|
3457
3624
|
importMap: getImportMap(config.outdir.replace(relativeBaseUrl, "")),
|
|
3458
3625
|
jsx: {
|
|
3459
3626
|
factory: jsx.factoryName,
|
|
3627
|
+
styleProps: jsx.styleProps,
|
|
3460
3628
|
isStyleProp: isValidProperty,
|
|
3461
3629
|
nodes: [...patterns.details, ...recipes.details]
|
|
3462
3630
|
},
|