@pandacss/generator 0.9.0 → 0.11.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 +500 -320
- package/dist/index.mjs +497 -317
- 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,14 +586,13 @@ 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,
|
|
589
592
|
config: { hash, prefix },
|
|
590
593
|
conditions
|
|
591
594
|
} = ctx;
|
|
592
|
-
const { separator } = utility;
|
|
595
|
+
const { separator, getPropShorthands } = utility;
|
|
593
596
|
return {
|
|
594
597
|
dts: outdent4`
|
|
595
598
|
import type { SystemStyleObject } from '../types'
|
|
@@ -605,35 +608,59 @@ function generateCssFn(ctx) {
|
|
|
605
608
|
${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
606
609
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
607
610
|
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
611
|
+
const utilities = "${utility.entries().map(([prop, className]) => {
|
|
612
|
+
const shorthandList = getPropShorthands(prop);
|
|
613
|
+
const result = [
|
|
614
|
+
prop,
|
|
615
|
+
[
|
|
616
|
+
className,
|
|
617
|
+
shorthandList.length ? (
|
|
618
|
+
// mark shorthand equal to className as 1 to save a few bytes
|
|
619
|
+
shorthandList.map((shorthand) => shorthand === className ? 1 : shorthand).join("/")
|
|
620
|
+
) : null
|
|
621
|
+
].filter(Boolean).join("/")
|
|
622
|
+
].join(":");
|
|
623
|
+
return result;
|
|
624
|
+
}).join(",")}"
|
|
625
|
+
|
|
626
|
+
const classNames = new Map()
|
|
627
|
+
${utility.hasShorthand ? outdent4`
|
|
628
|
+
const shorthands = new Map()
|
|
629
|
+
utilities.split(',').forEach((utility) => {
|
|
630
|
+
const [prop, meta] = utility.split(':')
|
|
631
|
+
const [className, ...shorthandList] = meta.split('/')
|
|
632
|
+
classNames.set(prop, className)
|
|
633
|
+
if (shorthandList.length) {
|
|
634
|
+
shorthandList.forEach((shorthand) => {
|
|
635
|
+
shorthands.set(shorthand === '1' ? className : shorthand, prop)
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
})
|
|
617
639
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const className =
|
|
622
|
-
|
|
623
|
-
}
|
|
640
|
+
const resolveShorthand = (prop) => shorthands.get(prop) || prop
|
|
641
|
+
` : outdent4`
|
|
642
|
+
utilities.split(',').forEach((utility) => {
|
|
643
|
+
const [prop, className] = utility.split(':')
|
|
644
|
+
classNames.set(prop, className)
|
|
645
|
+
})
|
|
646
|
+
`}
|
|
624
647
|
|
|
625
648
|
const context = {
|
|
626
|
-
|
|
649
|
+
${hash ? "hash: true," : ""}
|
|
627
650
|
conditions: {
|
|
628
651
|
shift: sortConditions,
|
|
629
652
|
finalize: finalizeConditions,
|
|
630
|
-
breakpoints: { keys:
|
|
653
|
+
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
631
654
|
},
|
|
632
655
|
utility: {
|
|
633
|
-
|
|
634
|
-
transform,
|
|
635
|
-
|
|
636
|
-
|
|
656
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
657
|
+
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
658
|
+
const key = resolveShorthand(prop)
|
|
659
|
+
const propKey = classNames.get(key) || hypenateProperty(key)
|
|
660
|
+
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
661
|
+
}` : `(key, value) => ({ className: \`\${classNames.get(key) || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
662
|
+
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
663
|
+
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
637
664
|
}
|
|
638
665
|
}
|
|
639
666
|
|
|
@@ -808,20 +835,33 @@ import { outdent as outdent8 } from "outdent";
|
|
|
808
835
|
|
|
809
836
|
// src/artifacts/generated/helpers.mjs.json
|
|
810
837
|
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/
|
|
838
|
+
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate-property.ts\nvar wordRegex = /([A-Z])/g;\nvar msRegex = /^ms-/;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();\n});\n\n// src/slot.ts\nvar 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'
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// src/artifacts/generated/astish.mjs.json
|
|
842
|
+
var astish_mjs_default = {
|
|
843
|
+
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'
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
// src/artifacts/generated/normalize-html.mjs.json
|
|
847
|
+
var normalize_html_mjs_default = {
|
|
848
|
+
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
849
|
};
|
|
813
850
|
|
|
814
851
|
// src/artifacts/js/helpers.ts
|
|
815
|
-
function generateHelpers() {
|
|
852
|
+
function generateHelpers(ctx) {
|
|
816
853
|
return {
|
|
817
854
|
js: outdent8`
|
|
818
855
|
${helpers_mjs_default.content}
|
|
856
|
+
${ctx.isTemplateLiteralSyntax ? astish_mjs_default.content : ""}
|
|
857
|
+
|
|
858
|
+
${ctx.jsx.framework ? `${normalize_html_mjs_default.content}` : ""}
|
|
819
859
|
|
|
820
|
-
export function __spreadValues(a, b){
|
|
860
|
+
export function __spreadValues(a, b) {
|
|
821
861
|
return { ...a, ...b }
|
|
822
862
|
}
|
|
823
863
|
|
|
824
|
-
export function __objRest(source, exclude){
|
|
864
|
+
export function __objRest(source, exclude) {
|
|
825
865
|
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
826
866
|
}
|
|
827
867
|
`
|
|
@@ -830,19 +870,29 @@ function generateHelpers() {
|
|
|
830
870
|
|
|
831
871
|
// src/artifacts/generated/is-valid-prop.mjs.json
|
|
832
872
|
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'
|
|
873
|
+
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
874
|
};
|
|
835
875
|
|
|
836
876
|
// src/artifacts/js/is-valid-prop.ts
|
|
837
877
|
import { outdent as outdent9 } from "outdent";
|
|
838
|
-
|
|
878
|
+
import { match } from "ts-pattern";
|
|
879
|
+
var cssPropRegex = /var cssPropertiesStr = ".*?";/;
|
|
880
|
+
var memoFnDeclarationRegex = /function memo(.+?)\nvar selectorRegex/s;
|
|
881
|
+
function generateIsValidProp(ctx) {
|
|
839
882
|
if (ctx.isTemplateLiteralSyntax)
|
|
840
883
|
return;
|
|
841
884
|
let content = is_valid_prop_mjs_default.content;
|
|
842
885
|
content = content.replace(
|
|
843
|
-
|
|
844
|
-
`var
|
|
886
|
+
'var userGeneratedStr = "";',
|
|
887
|
+
`var userGeneratedStr = "${match(ctx.jsx.styleProps).with("all", () => Array.from(new Set(ctx.properties)).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
845
888
|
);
|
|
889
|
+
content = content.replace(memoFnDeclarationRegex, "var selectorRegex");
|
|
890
|
+
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
891
|
+
content = content.replace("/* @__PURE__ */ memo(", "/* @__PURE__ */ (");
|
|
892
|
+
content = content.replace(cssPropRegex, 'var cssPropertiesStr = "";');
|
|
893
|
+
} else {
|
|
894
|
+
content = ctx.file.import("memo", "../helpers") + "\n" + content;
|
|
895
|
+
}
|
|
846
896
|
return {
|
|
847
897
|
js: content,
|
|
848
898
|
dts: outdent9`
|
|
@@ -855,16 +905,16 @@ function generateisValidProp(ctx) {
|
|
|
855
905
|
|
|
856
906
|
// src/artifacts/js/pattern.ts
|
|
857
907
|
import { unionType } from "@pandacss/shared";
|
|
858
|
-
import { stringify
|
|
908
|
+
import { stringify } from "javascript-stringify";
|
|
859
909
|
import { outdent as outdent10 } from "outdent";
|
|
860
|
-
import { match } from "ts-pattern";
|
|
910
|
+
import { match as match2 } from "ts-pattern";
|
|
861
911
|
function generatePattern(ctx) {
|
|
862
912
|
if (ctx.patterns.isEmpty())
|
|
863
913
|
return;
|
|
864
914
|
return ctx.patterns.details.map((pattern) => {
|
|
865
915
|
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
866
916
|
const { properties, transform, strict, description } = config;
|
|
867
|
-
const transformFn =
|
|
917
|
+
const transformFn = stringify({ transform }) ?? "";
|
|
868
918
|
const helperImports = ["mapObject"];
|
|
869
919
|
if (transformFn.includes("__spreadValues")) {
|
|
870
920
|
helperImports.push("__spreadValues");
|
|
@@ -883,7 +933,7 @@ function generatePattern(ctx) {
|
|
|
883
933
|
export type ${upperName}Properties = {
|
|
884
934
|
${Object.keys(properties ?? {}).map((key) => {
|
|
885
935
|
const value = properties[key];
|
|
886
|
-
return
|
|
936
|
+
return match2(value).with({ type: "property" }, (value2) => {
|
|
887
937
|
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
888
938
|
}).with({ type: "token" }, (value2) => {
|
|
889
939
|
if (value2.property) {
|
|
@@ -929,9 +979,11 @@ transform`)}
|
|
|
929
979
|
}
|
|
930
980
|
|
|
931
981
|
// src/artifacts/js/recipe.ts
|
|
982
|
+
import { isSlotRecipe } from "@pandacss/core";
|
|
932
983
|
import { unionType as unionType2 } from "@pandacss/shared";
|
|
933
984
|
import { outdent as outdent11 } from "outdent";
|
|
934
|
-
|
|
985
|
+
import { match as match3 } from "ts-pattern";
|
|
986
|
+
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
935
987
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
936
988
|
function generateRecipes(ctx) {
|
|
937
989
|
const {
|
|
@@ -964,9 +1016,9 @@ function generateRecipes(ctx) {
|
|
|
964
1016
|
}
|
|
965
1017
|
|
|
966
1018
|
const recipeCss = createCss({
|
|
967
|
-
|
|
1019
|
+
${hash ? "hash: true," : ""}
|
|
968
1020
|
utility: {
|
|
969
|
-
|
|
1021
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
970
1022
|
transform,
|
|
971
1023
|
}
|
|
972
1024
|
})
|
|
@@ -989,26 +1041,59 @@ function generateRecipes(ctx) {
|
|
|
989
1041
|
...ctx.recipes.details.map((recipe) => {
|
|
990
1042
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
991
1043
|
const { description, defaultVariants, compoundVariants } = config;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1044
|
+
const jsCode = match3(config).when(
|
|
1045
|
+
isSlotRecipe,
|
|
1046
|
+
(config2) => outdent11`
|
|
1047
|
+
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1048
|
+
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1049
|
+
|
|
1050
|
+
const ${baseName}DefaultVariants = ${stringify2(defaultVariants ?? {})}
|
|
1051
|
+
const ${baseName}CompoundVariants = ${stringify2(compoundVariants ?? [])}
|
|
1052
|
+
|
|
1053
|
+
const ${baseName}SlotNames = ${stringify2(config2.slots.map((slot) => [slot, `${config2.className}__${slot}`]))}
|
|
1054
|
+
const ${baseName}SlotFns = ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
|
|
1055
|
+
|
|
1056
|
+
const ${baseName}Fn = (props = {}) => {
|
|
1057
|
+
return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn(props)]))
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
const ${baseName}VariantKeys = ${stringify2(Object.keys(variantKeyMap))}
|
|
1061
|
+
|
|
1062
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1063
|
+
__recipe__: false,
|
|
1064
|
+
raw: (props) => props,
|
|
1065
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1066
|
+
variantMap: ${stringify2(variantKeyMap)},
|
|
1067
|
+
splitVariantProps(props) {
|
|
1068
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1069
|
+
},
|
|
1070
|
+
})
|
|
1071
|
+
`
|
|
1072
|
+
).otherwise(
|
|
1073
|
+
(config2) => outdent11`
|
|
995
1074
|
${ctx.file.import("splitProps", "../helpers")}
|
|
996
1075
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
997
1076
|
|
|
998
|
-
const ${baseName}Fn = createRecipe('${
|
|
1077
|
+
const ${baseName}Fn = createRecipe('${config2.className}', ${stringify2(defaultVariants ?? {})}, ${stringify2(
|
|
999
1078
|
compoundVariants ?? []
|
|
1000
1079
|
)})
|
|
1001
1080
|
|
|
1081
|
+
const ${baseName}VariantMap = ${stringify2(variantKeyMap)}
|
|
1082
|
+
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1002
1083
|
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1003
1084
|
__recipe__: true,
|
|
1004
1085
|
raw: (props) => props,
|
|
1005
|
-
variantKeys: ${
|
|
1006
|
-
variantMap: ${
|
|
1086
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1087
|
+
variantMap: ${baseName}VariantMap,
|
|
1007
1088
|
splitVariantProps(props) {
|
|
1008
|
-
return splitProps(props, ${
|
|
1089
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1009
1090
|
},
|
|
1010
1091
|
})
|
|
1011
|
-
|
|
1092
|
+
`
|
|
1093
|
+
);
|
|
1094
|
+
return {
|
|
1095
|
+
name: dashName,
|
|
1096
|
+
js: jsCode,
|
|
1012
1097
|
dts: outdent11`
|
|
1013
1098
|
import type { ConditionalValue } from '../types'
|
|
1014
1099
|
import type { Pretty } from '../types/helpers'
|
|
@@ -1032,7 +1117,7 @@ function generateRecipes(ctx) {
|
|
|
1032
1117
|
|
|
1033
1118
|
interface ${upperName}Recipe {
|
|
1034
1119
|
__type: ${upperName}VariantProps
|
|
1035
|
-
(props?: ${upperName}VariantProps): string
|
|
1120
|
+
(props?: ${upperName}VariantProps): ${isSlotRecipe(config) ? `Pretty<Record<${unionType2(config.slots)}, string>>` : "string"}
|
|
1036
1121
|
raw: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
|
|
1037
1122
|
variantMap: ${upperName}VariantMap
|
|
1038
1123
|
variantKeys: Array<keyof ${upperName}Variant>
|
|
@@ -1047,8 +1132,42 @@ function generateRecipes(ctx) {
|
|
|
1047
1132
|
];
|
|
1048
1133
|
}
|
|
1049
1134
|
|
|
1135
|
+
// src/artifacts/js/sva.ts
|
|
1136
|
+
import { outdent as outdent12 } from "outdent";
|
|
1137
|
+
function generateSvaFn(ctx) {
|
|
1138
|
+
return {
|
|
1139
|
+
js: outdent12`
|
|
1140
|
+
${ctx.file.import("getSlotRecipes", "../helpers")}
|
|
1141
|
+
${ctx.file.import("cva", "./cva")}
|
|
1142
|
+
|
|
1143
|
+
export function sva(config) {
|
|
1144
|
+
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1145
|
+
|
|
1146
|
+
function svaFn(props) {
|
|
1147
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1148
|
+
return Object.fromEntries(result)
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const [, firstCva] = slots[0]
|
|
1152
|
+
|
|
1153
|
+
return Object.assign(svaFn, {
|
|
1154
|
+
__cva__: false,
|
|
1155
|
+
variantMap: firstCva.variantMap,
|
|
1156
|
+
variantKeys: firstCva.variantKeys,
|
|
1157
|
+
splitVariantProps: firstCva.splitVariantProps,
|
|
1158
|
+
})
|
|
1159
|
+
}
|
|
1160
|
+
`,
|
|
1161
|
+
dts: outdent12`
|
|
1162
|
+
import type { SlotRecipeCreatorFn } from '../types/recipe'
|
|
1163
|
+
|
|
1164
|
+
export declare const sva: SlotRecipeCreatorFn
|
|
1165
|
+
`
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1050
1169
|
// src/artifacts/js/token.ts
|
|
1051
|
-
import
|
|
1170
|
+
import outdent13 from "outdent";
|
|
1052
1171
|
function generateTokenJs(ctx) {
|
|
1053
1172
|
const { tokens } = ctx;
|
|
1054
1173
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1059,7 +1178,7 @@ function generateTokenJs(ctx) {
|
|
|
1059
1178
|
});
|
|
1060
1179
|
const obj = Object.fromEntries(map);
|
|
1061
1180
|
return {
|
|
1062
|
-
js:
|
|
1181
|
+
js: outdent13`
|
|
1063
1182
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1064
1183
|
|
|
1065
1184
|
export function token(path, fallback) {
|
|
@@ -1072,7 +1191,7 @@ function generateTokenJs(ctx) {
|
|
|
1072
1191
|
|
|
1073
1192
|
token.var = tokenVar
|
|
1074
1193
|
`,
|
|
1075
|
-
dts:
|
|
1194
|
+
dts: outdent13`
|
|
1076
1195
|
import type { Token } from './tokens'
|
|
1077
1196
|
|
|
1078
1197
|
export declare const token: {
|
|
@@ -1086,43 +1205,43 @@ function generateTokenJs(ctx) {
|
|
|
1086
1205
|
}
|
|
1087
1206
|
|
|
1088
1207
|
// src/artifacts/preact-jsx/jsx.ts
|
|
1089
|
-
import { outdent as
|
|
1208
|
+
import { outdent as outdent14 } from "outdent";
|
|
1090
1209
|
function generatePreactJsxFactory(ctx) {
|
|
1091
1210
|
const { factoryName, componentName } = ctx.jsx;
|
|
1092
1211
|
return {
|
|
1093
|
-
js:
|
|
1212
|
+
js: outdent14`
|
|
1094
1213
|
import { h } from 'preact'
|
|
1095
1214
|
import { forwardRef } from 'preact/compat'
|
|
1096
1215
|
import { useMemo } from 'preact/hooks'
|
|
1097
1216
|
${ctx.file.import("css, cx, assignCss", "../css/index")}
|
|
1098
1217
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1099
1218
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1100
|
-
|
|
1219
|
+
|
|
1101
1220
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1102
1221
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1103
|
-
|
|
1104
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1222
|
+
|
|
1223
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1105
1224
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1106
1225
|
|
|
1107
1226
|
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1108
1227
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1109
1228
|
}, [restProps])
|
|
1110
|
-
|
|
1229
|
+
|
|
1111
1230
|
function recipeClass() {
|
|
1112
1231
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1113
1232
|
const styles = assignCss(propStyles, cssStyles)
|
|
1114
1233
|
return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
|
|
1115
1234
|
}
|
|
1116
|
-
|
|
1235
|
+
|
|
1117
1236
|
function cvaClass() {
|
|
1118
1237
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1119
1238
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1120
1239
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1121
1240
|
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1122
1241
|
}
|
|
1123
|
-
|
|
1242
|
+
|
|
1124
1243
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1125
|
-
|
|
1244
|
+
|
|
1126
1245
|
return h(Element, {
|
|
1127
1246
|
...elementProps,
|
|
1128
1247
|
...normalizeHTMLProps(htmlProps),
|
|
@@ -1130,14 +1249,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1130
1249
|
className: classes()
|
|
1131
1250
|
})
|
|
1132
1251
|
})
|
|
1133
|
-
|
|
1252
|
+
|
|
1134
1253
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1135
1254
|
return ${componentName}
|
|
1136
1255
|
}
|
|
1137
|
-
|
|
1256
|
+
|
|
1138
1257
|
function createJsxFactory() {
|
|
1139
1258
|
const cache = new Map()
|
|
1140
|
-
|
|
1259
|
+
|
|
1141
1260
|
return new Proxy(styledFn, {
|
|
1142
1261
|
apply(_, __, args) {
|
|
1143
1262
|
return styledFn(...args)
|
|
@@ -1151,14 +1270,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1151
1270
|
})
|
|
1152
1271
|
}
|
|
1153
1272
|
|
|
1154
|
-
export const ${factoryName} = createJsxFactory()
|
|
1273
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1155
1274
|
`
|
|
1156
1275
|
};
|
|
1157
1276
|
}
|
|
1158
1277
|
|
|
1159
1278
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1160
|
-
import { outdent as
|
|
1161
|
-
import { match as
|
|
1279
|
+
import { outdent as outdent15 } from "outdent";
|
|
1280
|
+
import { match as match4 } from "ts-pattern";
|
|
1162
1281
|
function generatePreactJsxPattern(ctx) {
|
|
1163
1282
|
const { typeName, factoryName } = ctx.jsx;
|
|
1164
1283
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1166,35 +1285,35 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1166
1285
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1167
1286
|
return {
|
|
1168
1287
|
name: dashName,
|
|
1169
|
-
js:
|
|
1288
|
+
js: outdent15`
|
|
1170
1289
|
import { h } from 'preact'
|
|
1171
1290
|
import { forwardRef } from 'preact/compat'
|
|
1172
1291
|
${ctx.file.import(factoryName, "./factory")}
|
|
1173
1292
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1174
|
-
|
|
1175
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1176
|
-
${
|
|
1293
|
+
|
|
1294
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1295
|
+
${match4(props.length).with(
|
|
1177
1296
|
0,
|
|
1178
|
-
() =>
|
|
1297
|
+
() => outdent15`
|
|
1179
1298
|
const styleProps = ${styleFnName}()
|
|
1180
1299
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1181
1300
|
`
|
|
1182
1301
|
).otherwise(
|
|
1183
|
-
() =>
|
|
1302
|
+
() => outdent15`
|
|
1184
1303
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1185
1304
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1186
1305
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1187
1306
|
`
|
|
1188
1307
|
)}
|
|
1189
|
-
})
|
|
1308
|
+
})
|
|
1190
1309
|
`,
|
|
1191
|
-
dts:
|
|
1310
|
+
dts: outdent15`
|
|
1192
1311
|
import type { FunctionComponent } from 'preact'
|
|
1193
1312
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1194
1313
|
import type { ${typeName} } from '../types/jsx'
|
|
1195
|
-
|
|
1314
|
+
|
|
1196
1315
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1197
|
-
|
|
1316
|
+
|
|
1198
1317
|
${description ? `/** ${description} */` : ""}
|
|
1199
1318
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1200
1319
|
`
|
|
@@ -1203,15 +1322,15 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1203
1322
|
}
|
|
1204
1323
|
|
|
1205
1324
|
// src/artifacts/preact-jsx/types.ts
|
|
1206
|
-
import { outdent as
|
|
1325
|
+
import { outdent as outdent16 } from "outdent";
|
|
1207
1326
|
function generatePreactJsxTypes(ctx) {
|
|
1208
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1327
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1209
1328
|
return {
|
|
1210
|
-
jsxFactory:
|
|
1329
|
+
jsxFactory: outdent16`
|
|
1211
1330
|
import type { ${upperName} } from '../types/jsx'
|
|
1212
1331
|
export declare const ${factoryName}: ${upperName}
|
|
1213
1332
|
`,
|
|
1214
|
-
jsxType:
|
|
1333
|
+
jsxType: outdent16`
|
|
1215
1334
|
import type { ComponentProps, JSX } from 'preact'
|
|
1216
1335
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1217
1336
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1228,7 +1347,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1228
1347
|
type RecipeFn = { __type: any }
|
|
1229
1348
|
|
|
1230
1349
|
interface JsxFactory {
|
|
1231
|
-
|
|
1350
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1232
1351
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1233
1352
|
T,
|
|
1234
1353
|
RecipeSelection<P>
|
|
@@ -1238,7 +1357,7 @@ interface JsxFactory {
|
|
|
1238
1357
|
|
|
1239
1358
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1240
1359
|
|
|
1241
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1360
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1242
1361
|
|
|
1243
1362
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1244
1363
|
`
|
|
@@ -1246,37 +1365,37 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1246
1365
|
}
|
|
1247
1366
|
|
|
1248
1367
|
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1249
|
-
import { outdent as
|
|
1368
|
+
import { outdent as outdent17 } from "outdent";
|
|
1250
1369
|
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1251
1370
|
const { factoryName, componentName } = ctx.jsx;
|
|
1252
1371
|
return {
|
|
1253
|
-
js:
|
|
1372
|
+
js: outdent17`
|
|
1254
1373
|
import { h } from 'preact'
|
|
1255
1374
|
import { forwardRef } from 'preact/compat'
|
|
1256
1375
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1257
|
-
|
|
1376
|
+
|
|
1258
1377
|
function createStyledFn(Dynamic) {
|
|
1259
1378
|
return function styledFn(template) {
|
|
1260
1379
|
const baseClassName = css(template)
|
|
1261
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1380
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1262
1381
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1263
1382
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1264
|
-
|
|
1383
|
+
|
|
1265
1384
|
return h(Element, {
|
|
1266
1385
|
ref,
|
|
1267
1386
|
...elementProps,
|
|
1268
1387
|
className: classes(),
|
|
1269
1388
|
})
|
|
1270
1389
|
})
|
|
1271
|
-
|
|
1390
|
+
|
|
1272
1391
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1273
1392
|
return ${componentName}
|
|
1274
1393
|
}
|
|
1275
1394
|
}
|
|
1276
|
-
|
|
1395
|
+
|
|
1277
1396
|
function createJsxFactory() {
|
|
1278
1397
|
const cache = new Map()
|
|
1279
|
-
|
|
1398
|
+
|
|
1280
1399
|
return new Proxy(createStyledFn, {
|
|
1281
1400
|
apply(_, __, args) {
|
|
1282
1401
|
return createStyledFn(...args)
|
|
@@ -1290,21 +1409,21 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1290
1409
|
})
|
|
1291
1410
|
}
|
|
1292
1411
|
|
|
1293
|
-
export const ${factoryName} = createJsxFactory()
|
|
1412
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1294
1413
|
`
|
|
1295
1414
|
};
|
|
1296
1415
|
}
|
|
1297
1416
|
|
|
1298
1417
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1299
|
-
import { outdent as
|
|
1418
|
+
import { outdent as outdent18 } from "outdent";
|
|
1300
1419
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1301
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1420
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1302
1421
|
return {
|
|
1303
|
-
jsxFactory:
|
|
1422
|
+
jsxFactory: outdent18`
|
|
1304
1423
|
import type { ${upperName} } from '../types/jsx'
|
|
1305
1424
|
export declare const ${factoryName}: ${upperName}
|
|
1306
1425
|
`,
|
|
1307
|
-
jsxType:
|
|
1426
|
+
jsxType: outdent18`
|
|
1308
1427
|
import type { ComponentProps, JSX } from 'preact'
|
|
1309
1428
|
|
|
1310
1429
|
type ElementType = keyof JSX.IntrinsicElements
|
|
@@ -1322,7 +1441,7 @@ interface JsxFactory {
|
|
|
1322
1441
|
|
|
1323
1442
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1324
1443
|
|
|
1325
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1444
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1326
1445
|
|
|
1327
1446
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1328
1447
|
`
|
|
@@ -1330,54 +1449,54 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1330
1449
|
}
|
|
1331
1450
|
|
|
1332
1451
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1333
|
-
import { outdent as
|
|
1452
|
+
import { outdent as outdent19 } from "outdent";
|
|
1334
1453
|
function generateQwikJsxFactory(ctx) {
|
|
1335
1454
|
const { factoryName, componentName } = ctx.jsx;
|
|
1336
1455
|
return {
|
|
1337
|
-
js:
|
|
1456
|
+
js: outdent19`
|
|
1338
1457
|
import { h } from '@builder.io/qwik'
|
|
1339
1458
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1340
1459
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1341
1460
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1342
|
-
|
|
1461
|
+
|
|
1343
1462
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1344
1463
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1345
|
-
|
|
1464
|
+
|
|
1346
1465
|
const ${componentName} = function ${componentName}(props) {
|
|
1347
1466
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1348
|
-
|
|
1349
|
-
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1467
|
+
|
|
1468
|
+
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1350
1469
|
splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1351
|
-
|
|
1470
|
+
|
|
1352
1471
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1353
|
-
|
|
1472
|
+
|
|
1354
1473
|
function recipeClass() {
|
|
1355
1474
|
const styles = assignCss(propStyles, cssStyles)
|
|
1356
1475
|
return cx(cvaFn(variantProps), css(styles), elementProps.class)
|
|
1357
1476
|
}
|
|
1358
|
-
|
|
1477
|
+
|
|
1359
1478
|
function cvaClass() {
|
|
1360
1479
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1361
1480
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1362
1481
|
return cx(css(styles), elementProps.class)
|
|
1363
1482
|
}
|
|
1364
|
-
|
|
1483
|
+
|
|
1365
1484
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1366
|
-
|
|
1485
|
+
|
|
1367
1486
|
return h(Element, {
|
|
1368
1487
|
...elementProps,
|
|
1369
1488
|
...normalizeHTMLProps(htmlProps),
|
|
1370
1489
|
class: classes(),
|
|
1371
1490
|
})
|
|
1372
1491
|
}
|
|
1373
|
-
|
|
1492
|
+
|
|
1374
1493
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1375
1494
|
return ${componentName}
|
|
1376
1495
|
}
|
|
1377
|
-
|
|
1496
|
+
|
|
1378
1497
|
function createJsxFactory() {
|
|
1379
1498
|
const cache = new Map()
|
|
1380
|
-
|
|
1499
|
+
|
|
1381
1500
|
return new Proxy(styledFn, {
|
|
1382
1501
|
apply(_, __, args) {
|
|
1383
1502
|
return styledFn(...args)
|
|
@@ -1391,15 +1510,15 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1391
1510
|
})
|
|
1392
1511
|
}
|
|
1393
1512
|
|
|
1394
|
-
export const ${factoryName} = createJsxFactory()
|
|
1513
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1395
1514
|
|
|
1396
1515
|
`
|
|
1397
1516
|
};
|
|
1398
1517
|
}
|
|
1399
1518
|
|
|
1400
1519
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1401
|
-
import { outdent as
|
|
1402
|
-
import { match as
|
|
1520
|
+
import { outdent as outdent20 } from "outdent";
|
|
1521
|
+
import { match as match5 } from "ts-pattern";
|
|
1403
1522
|
function generateQwikJsxPattern(ctx) {
|
|
1404
1523
|
const { typeName, factoryName } = ctx.jsx;
|
|
1405
1524
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1407,20 +1526,20 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1407
1526
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1408
1527
|
return {
|
|
1409
1528
|
name: dashName,
|
|
1410
|
-
js:
|
|
1529
|
+
js: outdent20`
|
|
1411
1530
|
import { h } from '@builder.io/qwik'
|
|
1412
1531
|
${ctx.file.import(factoryName, "./factory")}
|
|
1413
1532
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1414
1533
|
|
|
1415
1534
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1416
|
-
${
|
|
1535
|
+
${match5(props.length).with(
|
|
1417
1536
|
0,
|
|
1418
|
-
() =>
|
|
1537
|
+
() => outdent20`
|
|
1419
1538
|
const styleProps = ${styleFnName}()
|
|
1420
1539
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1421
1540
|
`
|
|
1422
1541
|
).otherwise(
|
|
1423
|
-
() =>
|
|
1542
|
+
() => outdent20`
|
|
1424
1543
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1425
1544
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1426
1545
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1428,7 +1547,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1428
1547
|
)}
|
|
1429
1548
|
}
|
|
1430
1549
|
`,
|
|
1431
|
-
dts:
|
|
1550
|
+
dts: outdent20`
|
|
1432
1551
|
import type { FunctionComponent } from '@builder.io/qwik'
|
|
1433
1552
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1434
1553
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1447,15 +1566,15 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1447
1566
|
}
|
|
1448
1567
|
|
|
1449
1568
|
// src/artifacts/qwik-jsx/types.ts
|
|
1450
|
-
import { outdent as
|
|
1569
|
+
import { outdent as outdent21 } from "outdent";
|
|
1451
1570
|
function generateQwikJsxTypes(ctx) {
|
|
1452
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1571
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1453
1572
|
return {
|
|
1454
|
-
jsxFactory:
|
|
1573
|
+
jsxFactory: outdent21`
|
|
1455
1574
|
import { ${upperName} } from '../types/jsx'
|
|
1456
1575
|
export declare const ${factoryName}: ${upperName}
|
|
1457
1576
|
`,
|
|
1458
|
-
jsxType:
|
|
1577
|
+
jsxType: outdent21`
|
|
1459
1578
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1460
1579
|
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1461
1580
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1491,7 +1610,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = Funct
|
|
|
1491
1610
|
type RecipeFn = { __type: any }
|
|
1492
1611
|
|
|
1493
1612
|
interface JsxFactory {
|
|
1494
|
-
|
|
1613
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1495
1614
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1496
1615
|
T,
|
|
1497
1616
|
RecipeSelection<P>
|
|
@@ -1501,7 +1620,7 @@ interface JsxFactory {
|
|
|
1501
1620
|
|
|
1502
1621
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1503
1622
|
|
|
1504
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1623
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1505
1624
|
|
|
1506
1625
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1507
1626
|
`
|
|
@@ -1509,35 +1628,35 @@ export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxSt
|
|
|
1509
1628
|
}
|
|
1510
1629
|
|
|
1511
1630
|
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1512
|
-
import { outdent as
|
|
1631
|
+
import { outdent as outdent22 } from "outdent";
|
|
1513
1632
|
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1514
1633
|
const { factoryName, componentName } = ctx.jsx;
|
|
1515
1634
|
return {
|
|
1516
|
-
js:
|
|
1635
|
+
js: outdent22`
|
|
1517
1636
|
import { h } from '@builder.io/qwik'
|
|
1518
1637
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1519
|
-
|
|
1638
|
+
|
|
1520
1639
|
function createStyledFn(Dynamic) {
|
|
1521
1640
|
return function styledFn(template) {
|
|
1522
1641
|
const baseClassName = css(template)
|
|
1523
1642
|
const ${componentName} = function ${componentName}(props) {
|
|
1524
1643
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1525
1644
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1526
|
-
|
|
1645
|
+
|
|
1527
1646
|
return h(Element, {
|
|
1528
1647
|
...elementProps,
|
|
1529
1648
|
className: classes(),
|
|
1530
1649
|
})
|
|
1531
1650
|
}
|
|
1532
|
-
|
|
1651
|
+
|
|
1533
1652
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1534
1653
|
return ${componentName}
|
|
1535
1654
|
}
|
|
1536
1655
|
}
|
|
1537
|
-
|
|
1656
|
+
|
|
1538
1657
|
function createJsxFactory() {
|
|
1539
1658
|
const cache = new Map()
|
|
1540
|
-
|
|
1659
|
+
|
|
1541
1660
|
return new Proxy(createStyledFn, {
|
|
1542
1661
|
apply(_, __, args) {
|
|
1543
1662
|
return createStyledFn(...args)
|
|
@@ -1551,22 +1670,22 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1551
1670
|
})
|
|
1552
1671
|
}
|
|
1553
1672
|
|
|
1554
|
-
export const ${factoryName} = createJsxFactory()
|
|
1673
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1555
1674
|
|
|
1556
1675
|
`
|
|
1557
1676
|
};
|
|
1558
1677
|
}
|
|
1559
1678
|
|
|
1560
1679
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1561
|
-
import { outdent as
|
|
1680
|
+
import { outdent as outdent23 } from "outdent";
|
|
1562
1681
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1563
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1682
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1564
1683
|
return {
|
|
1565
|
-
jsxFactory:
|
|
1684
|
+
jsxFactory: outdent23`
|
|
1566
1685
|
import { ${upperName} } from '../types/jsx'
|
|
1567
1686
|
export declare const ${factoryName}: ${upperName}
|
|
1568
1687
|
`,
|
|
1569
|
-
jsxType:
|
|
1688
|
+
jsxType: outdent23`
|
|
1570
1689
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1571
1690
|
|
|
1572
1691
|
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
@@ -1589,7 +1708,7 @@ interface JsxFactory {
|
|
|
1589
1708
|
|
|
1590
1709
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1591
1710
|
|
|
1592
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1711
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1593
1712
|
|
|
1594
1713
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1595
1714
|
`
|
|
@@ -1597,41 +1716,76 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1597
1716
|
}
|
|
1598
1717
|
|
|
1599
1718
|
// src/artifacts/react-jsx/jsx.ts
|
|
1600
|
-
import { outdent as
|
|
1719
|
+
import { outdent as outdent24 } from "outdent";
|
|
1720
|
+
import { match as match6 } from "ts-pattern";
|
|
1601
1721
|
function generateReactJsxFactory(ctx) {
|
|
1602
1722
|
const { factoryName, componentName } = ctx.jsx;
|
|
1603
1723
|
return {
|
|
1604
|
-
js:
|
|
1724
|
+
js: outdent24`
|
|
1605
1725
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1606
1726
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1607
1727
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1608
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1609
|
-
|
|
1728
|
+
${ctx.jsx.styleProps === "all" ? ctx.file.import("isCssProperty", "./is-valid-prop") : ""}
|
|
1729
|
+
|
|
1610
1730
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1611
1731
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1612
|
-
|
|
1613
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1732
|
+
|
|
1733
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1614
1734
|
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
1735
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1736
|
+
${match6(ctx.jsx.styleProps).with("all", () => {
|
|
1737
|
+
return outdent24`
|
|
1738
|
+
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1739
|
+
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1740
|
+
}, [restProps])
|
|
1741
|
+
|
|
1742
|
+
function recipeClass() {
|
|
1743
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1744
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1745
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
function cvaClass() {
|
|
1749
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1750
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1751
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1752
|
+
return cx(css(styles), elementProps.className)
|
|
1753
|
+
}`;
|
|
1754
|
+
}).with("minimal", () => {
|
|
1755
|
+
return outdent24`
|
|
1756
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1757
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1758
|
+
}, [restProps])
|
|
1759
|
+
|
|
1760
|
+
function recipeClass() {
|
|
1761
|
+
return cx(cvaFn(variantProps), css(assignCss(elementProps.css)), elementProps.className)
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
function cvaClass() {
|
|
1765
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1766
|
+
const styles = assignCss(cvaStyles, elementProps.css)
|
|
1767
|
+
return cx(css(styles), elementProps.className)
|
|
1768
|
+
}`;
|
|
1769
|
+
}).with("none", () => {
|
|
1770
|
+
return outdent24`
|
|
1771
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1772
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1773
|
+
}, [restProps])
|
|
1774
|
+
|
|
1775
|
+
function recipeClass() {
|
|
1776
|
+
return cx(cvaFn(variantProps), elementProps.className)
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
function cvaClass() {
|
|
1780
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1781
|
+
const styles = assignCss(cvaStyles)
|
|
1782
|
+
return cx(css(styles), elementProps.className)
|
|
1783
|
+
}`;
|
|
1784
|
+
}).run()}
|
|
1785
|
+
|
|
1786
|
+
|
|
1633
1787
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1634
|
-
|
|
1788
|
+
|
|
1635
1789
|
return createElement(Element, {
|
|
1636
1790
|
ref,
|
|
1637
1791
|
...elementProps,
|
|
@@ -1639,14 +1793,14 @@ function generateReactJsxFactory(ctx) {
|
|
|
1639
1793
|
className: classes(),
|
|
1640
1794
|
})
|
|
1641
1795
|
})
|
|
1642
|
-
|
|
1796
|
+
|
|
1643
1797
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1644
1798
|
return ${componentName}
|
|
1645
1799
|
}
|
|
1646
|
-
|
|
1800
|
+
|
|
1647
1801
|
function createJsxFactory() {
|
|
1648
1802
|
const cache = new Map()
|
|
1649
|
-
|
|
1803
|
+
|
|
1650
1804
|
return new Proxy(styledFn, {
|
|
1651
1805
|
apply(_, __, args) {
|
|
1652
1806
|
return styledFn(...args)
|
|
@@ -1660,15 +1814,15 @@ function generateReactJsxFactory(ctx) {
|
|
|
1660
1814
|
})
|
|
1661
1815
|
}
|
|
1662
1816
|
|
|
1663
|
-
export const ${factoryName} = createJsxFactory()
|
|
1817
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1664
1818
|
|
|
1665
1819
|
`
|
|
1666
1820
|
};
|
|
1667
1821
|
}
|
|
1668
1822
|
|
|
1669
1823
|
// src/artifacts/react-jsx/pattern.ts
|
|
1670
|
-
import { outdent as
|
|
1671
|
-
import { match as
|
|
1824
|
+
import { outdent as outdent25 } from "outdent";
|
|
1825
|
+
import { match as match7 } from "ts-pattern";
|
|
1672
1826
|
function generateReactJsxPattern(ctx) {
|
|
1673
1827
|
const { typeName, factoryName } = ctx.jsx;
|
|
1674
1828
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1676,34 +1830,34 @@ function generateReactJsxPattern(ctx) {
|
|
|
1676
1830
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1677
1831
|
return {
|
|
1678
1832
|
name: dashName,
|
|
1679
|
-
js:
|
|
1833
|
+
js: outdent25`
|
|
1680
1834
|
import { createElement, forwardRef } from 'react'
|
|
1681
1835
|
${ctx.file.import(factoryName, "./factory")}
|
|
1682
1836
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1683
|
-
|
|
1684
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1685
|
-
${
|
|
1837
|
+
|
|
1838
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1839
|
+
${match7(props.length).with(
|
|
1686
1840
|
0,
|
|
1687
|
-
() =>
|
|
1841
|
+
() => outdent25`
|
|
1688
1842
|
const styleProps = ${styleFnName}()
|
|
1689
1843
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1690
1844
|
`
|
|
1691
1845
|
).otherwise(
|
|
1692
|
-
() =>
|
|
1846
|
+
() => outdent25`
|
|
1693
1847
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1694
1848
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1695
1849
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1696
1850
|
`
|
|
1697
1851
|
)}
|
|
1698
|
-
})
|
|
1852
|
+
})
|
|
1699
1853
|
`,
|
|
1700
|
-
dts:
|
|
1854
|
+
dts: outdent25`
|
|
1701
1855
|
import type { FunctionComponent } from 'react'
|
|
1702
1856
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1703
1857
|
import type { ${typeName} } from '../types/jsx'
|
|
1704
|
-
|
|
1858
|
+
|
|
1705
1859
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1706
|
-
|
|
1860
|
+
|
|
1707
1861
|
${description ? `/** ${description} */` : ""}
|
|
1708
1862
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1709
1863
|
`
|
|
@@ -1712,15 +1866,15 @@ function generateReactJsxPattern(ctx) {
|
|
|
1712
1866
|
}
|
|
1713
1867
|
|
|
1714
1868
|
// src/artifacts/react-jsx/types.ts
|
|
1715
|
-
import { outdent as
|
|
1869
|
+
import { outdent as outdent26 } from "outdent";
|
|
1716
1870
|
function generateReactJsxTypes(ctx) {
|
|
1717
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1871
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1718
1872
|
return {
|
|
1719
|
-
jsxFactory:
|
|
1873
|
+
jsxFactory: outdent26`
|
|
1720
1874
|
import { ${upperName} } from '../types/jsx'
|
|
1721
1875
|
export declare const ${factoryName}: ${upperName}
|
|
1722
1876
|
`,
|
|
1723
|
-
jsxType:
|
|
1877
|
+
jsxType: outdent26`
|
|
1724
1878
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1725
1879
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1726
1880
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1739,7 +1893,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1739
1893
|
type RecipeFn = { __type: any }
|
|
1740
1894
|
|
|
1741
1895
|
interface JsxFactory {
|
|
1742
|
-
|
|
1896
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1743
1897
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1744
1898
|
T,
|
|
1745
1899
|
RecipeSelection<P>
|
|
@@ -1749,7 +1903,7 @@ interface JsxFactory {
|
|
|
1749
1903
|
|
|
1750
1904
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1751
1905
|
|
|
1752
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1906
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1753
1907
|
|
|
1754
1908
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1755
1909
|
`
|
|
@@ -1757,36 +1911,36 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1757
1911
|
}
|
|
1758
1912
|
|
|
1759
1913
|
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
1760
|
-
import { outdent as
|
|
1914
|
+
import { outdent as outdent27 } from "outdent";
|
|
1761
1915
|
function generateReactJsxStringLiteralFactory(ctx) {
|
|
1762
1916
|
const { factoryName, componentName } = ctx.jsx;
|
|
1763
1917
|
return {
|
|
1764
|
-
js:
|
|
1918
|
+
js: outdent27`
|
|
1765
1919
|
import { createElement, forwardRef } from 'react'
|
|
1766
1920
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1767
|
-
|
|
1921
|
+
|
|
1768
1922
|
function createStyledFn(Dynamic) {
|
|
1769
1923
|
return function styledFn(template) {
|
|
1770
1924
|
const baseClassName = css(template)
|
|
1771
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1925
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1772
1926
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1773
1927
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1774
|
-
|
|
1928
|
+
|
|
1775
1929
|
return createElement(Element, {
|
|
1776
1930
|
ref,
|
|
1777
1931
|
...elementProps,
|
|
1778
1932
|
className: classes(),
|
|
1779
1933
|
})
|
|
1780
1934
|
})
|
|
1781
|
-
|
|
1935
|
+
|
|
1782
1936
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1783
1937
|
return ${componentName}
|
|
1784
1938
|
}
|
|
1785
1939
|
}
|
|
1786
|
-
|
|
1940
|
+
|
|
1787
1941
|
function createJsxFactory() {
|
|
1788
1942
|
const cache = new Map()
|
|
1789
|
-
|
|
1943
|
+
|
|
1790
1944
|
return new Proxy(createStyledFn, {
|
|
1791
1945
|
apply(_, __, args) {
|
|
1792
1946
|
return createStyledFn(...args)
|
|
@@ -1800,22 +1954,22 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
1800
1954
|
})
|
|
1801
1955
|
}
|
|
1802
1956
|
|
|
1803
|
-
export const ${factoryName} = createJsxFactory()
|
|
1957
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1804
1958
|
|
|
1805
1959
|
`
|
|
1806
1960
|
};
|
|
1807
1961
|
}
|
|
1808
1962
|
|
|
1809
1963
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
1810
|
-
import { outdent as
|
|
1964
|
+
import { outdent as outdent28 } from "outdent";
|
|
1811
1965
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
1812
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1966
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1813
1967
|
return {
|
|
1814
|
-
jsxFactory:
|
|
1968
|
+
jsxFactory: outdent28`
|
|
1815
1969
|
import { ${upperName} } from '../types/jsx'
|
|
1816
1970
|
export declare const ${factoryName}: ${upperName}
|
|
1817
1971
|
`,
|
|
1818
|
-
jsxType:
|
|
1972
|
+
jsxType: outdent28`
|
|
1819
1973
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1820
1974
|
|
|
1821
1975
|
type Dict = Record<string, unknown>
|
|
@@ -1835,7 +1989,7 @@ interface JsxFactory {
|
|
|
1835
1989
|
|
|
1836
1990
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1837
1991
|
|
|
1838
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1992
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1839
1993
|
|
|
1840
1994
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1841
1995
|
`
|
|
@@ -1843,24 +1997,24 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1843
1997
|
}
|
|
1844
1998
|
|
|
1845
1999
|
// src/artifacts/solid-jsx/jsx.ts
|
|
1846
|
-
import { outdent as
|
|
2000
|
+
import { outdent as outdent29 } from "outdent";
|
|
1847
2001
|
function generateSolidJsxFactory(ctx) {
|
|
1848
2002
|
const { componentName, factoryName } = ctx.jsx;
|
|
1849
2003
|
return {
|
|
1850
|
-
js:
|
|
2004
|
+
js: outdent29`
|
|
1851
2005
|
import { Dynamic } from 'solid-js/web'
|
|
1852
2006
|
import { mergeProps, splitProps } from 'solid-js'
|
|
1853
2007
|
import { createComponent } from 'solid-js/web'
|
|
1854
2008
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1855
2009
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
1856
2010
|
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
1857
|
-
|
|
2011
|
+
|
|
1858
2012
|
function styledFn(element, configOrCva = {}) {
|
|
1859
2013
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1860
|
-
|
|
2014
|
+
|
|
1861
2015
|
return function ${componentName}(props) {
|
|
1862
2016
|
const mergedProps = mergeProps({ as: element }, props)
|
|
1863
|
-
|
|
2017
|
+
|
|
1864
2018
|
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
1865
2019
|
mergedProps,
|
|
1866
2020
|
['as', 'class'],
|
|
@@ -1874,16 +2028,16 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1874
2028
|
const styles = assignCss(propStyles, cssStyles)
|
|
1875
2029
|
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1876
2030
|
}
|
|
1877
|
-
|
|
2031
|
+
|
|
1878
2032
|
function cvaClass() {
|
|
1879
2033
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1880
2034
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1881
2035
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1882
2036
|
return cx(css(styles), localProps.class)
|
|
1883
2037
|
}
|
|
1884
|
-
|
|
2038
|
+
|
|
1885
2039
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1886
|
-
|
|
2040
|
+
|
|
1887
2041
|
return createComponent(
|
|
1888
2042
|
Dynamic,
|
|
1889
2043
|
mergeProps(
|
|
@@ -1901,10 +2055,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1901
2055
|
)
|
|
1902
2056
|
}
|
|
1903
2057
|
}
|
|
1904
|
-
|
|
2058
|
+
|
|
1905
2059
|
function createJsxFactory() {
|
|
1906
2060
|
const cache = new Map()
|
|
1907
|
-
|
|
2061
|
+
|
|
1908
2062
|
return new Proxy(styledFn, {
|
|
1909
2063
|
apply(_, __, args) {
|
|
1910
2064
|
return styledFn(...args)
|
|
@@ -1917,15 +2071,15 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1917
2071
|
},
|
|
1918
2072
|
})
|
|
1919
2073
|
}
|
|
1920
|
-
|
|
1921
|
-
export const ${factoryName} = createJsxFactory()
|
|
2074
|
+
|
|
2075
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1922
2076
|
`
|
|
1923
2077
|
};
|
|
1924
2078
|
}
|
|
1925
2079
|
|
|
1926
2080
|
// src/artifacts/solid-jsx/pattern.ts
|
|
1927
|
-
import { outdent as
|
|
1928
|
-
import { match as
|
|
2081
|
+
import { outdent as outdent30 } from "outdent";
|
|
2082
|
+
import { match as match8 } from "ts-pattern";
|
|
1929
2083
|
function generateSolidJsxPattern(ctx) {
|
|
1930
2084
|
const { typeName, factoryName } = ctx.jsx;
|
|
1931
2085
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1933,21 +2087,21 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1933
2087
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1934
2088
|
return {
|
|
1935
2089
|
name: dashName,
|
|
1936
|
-
js:
|
|
2090
|
+
js: outdent30`
|
|
1937
2091
|
import { splitProps, mergeProps } from 'solid-js'
|
|
1938
2092
|
import { createComponent } from 'solid-js/web'
|
|
1939
2093
|
${ctx.file.import(factoryName, "./factory")}
|
|
1940
2094
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1941
2095
|
|
|
1942
2096
|
export function ${jsxName}(props) {
|
|
1943
|
-
${
|
|
2097
|
+
${match8(props.length).with(
|
|
1944
2098
|
0,
|
|
1945
|
-
() =>
|
|
2099
|
+
() => outdent30`
|
|
1946
2100
|
const styleProps = ${styleFnName}()
|
|
1947
2101
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
1948
2102
|
`
|
|
1949
2103
|
).otherwise(
|
|
1950
|
-
() =>
|
|
2104
|
+
() => outdent30`
|
|
1951
2105
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
1952
2106
|
const styleProps = ${styleFnName}(patternProps)
|
|
1953
2107
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -1955,7 +2109,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1955
2109
|
)}
|
|
1956
2110
|
}
|
|
1957
2111
|
`,
|
|
1958
|
-
dts:
|
|
2112
|
+
dts: outdent30`
|
|
1959
2113
|
import { Component } from 'solid-js'
|
|
1960
2114
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1961
2115
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1970,15 +2124,15 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1970
2124
|
}
|
|
1971
2125
|
|
|
1972
2126
|
// src/artifacts/solid-jsx/types.ts
|
|
1973
|
-
import { outdent as
|
|
2127
|
+
import { outdent as outdent31 } from "outdent";
|
|
1974
2128
|
function generateSolidJsxTypes(ctx) {
|
|
1975
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2129
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1976
2130
|
return {
|
|
1977
|
-
jsxFactory:
|
|
2131
|
+
jsxFactory: outdent31`
|
|
1978
2132
|
import type { ${upperName} } from '../types/jsx'
|
|
1979
2133
|
export declare const ${factoryName}: ${upperName}
|
|
1980
2134
|
`,
|
|
1981
|
-
jsxType:
|
|
2135
|
+
jsxType: outdent31`
|
|
1982
2136
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1983
2137
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1984
2138
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1995,7 +2149,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1995
2149
|
type RecipeFn = { __type: any }
|
|
1996
2150
|
|
|
1997
2151
|
interface JsxFactory {
|
|
1998
|
-
|
|
2152
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1999
2153
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2000
2154
|
T,
|
|
2001
2155
|
RecipeSelection<P>
|
|
@@ -2005,7 +2159,7 @@ interface JsxFactory {
|
|
|
2005
2159
|
|
|
2006
2160
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2007
2161
|
|
|
2008
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2162
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2009
2163
|
|
|
2010
2164
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2011
2165
|
`
|
|
@@ -2013,11 +2167,11 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
2013
2167
|
}
|
|
2014
2168
|
|
|
2015
2169
|
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
2016
|
-
import { outdent as
|
|
2170
|
+
import { outdent as outdent32 } from "outdent";
|
|
2017
2171
|
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
2018
2172
|
const { componentName, factoryName } = ctx.jsx;
|
|
2019
2173
|
return {
|
|
2020
|
-
js:
|
|
2174
|
+
js: outdent32`
|
|
2021
2175
|
import { mergeProps, splitProps } from 'solid-js'
|
|
2022
2176
|
import { Dynamic, createComponent } from 'solid-js/web'
|
|
2023
2177
|
${ctx.file.import("css, cx", "../css/index")}
|
|
@@ -2028,7 +2182,7 @@ function createStyled(element) {
|
|
|
2028
2182
|
return function ${componentName}(props) {
|
|
2029
2183
|
const mergedProps = mergeProps({ as: element }, props)
|
|
2030
2184
|
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2031
|
-
|
|
2185
|
+
|
|
2032
2186
|
return createComponent(
|
|
2033
2187
|
Dynamic,
|
|
2034
2188
|
mergeProps(
|
|
@@ -2063,21 +2217,21 @@ function createJsxFactory() {
|
|
|
2063
2217
|
})
|
|
2064
2218
|
}
|
|
2065
2219
|
|
|
2066
|
-
export const ${factoryName} = createJsxFactory()
|
|
2220
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2067
2221
|
`
|
|
2068
2222
|
};
|
|
2069
2223
|
}
|
|
2070
2224
|
|
|
2071
2225
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2072
|
-
import { outdent as
|
|
2226
|
+
import { outdent as outdent33 } from "outdent";
|
|
2073
2227
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2074
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2228
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2075
2229
|
return {
|
|
2076
|
-
jsxFactory:
|
|
2230
|
+
jsxFactory: outdent33`
|
|
2077
2231
|
import type { ${upperName} } from '../types/jsx'
|
|
2078
2232
|
export declare const ${factoryName}: ${upperName}
|
|
2079
2233
|
`,
|
|
2080
|
-
jsxType:
|
|
2234
|
+
jsxType: outdent33`
|
|
2081
2235
|
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2082
2236
|
|
|
2083
2237
|
type Dict = Record<string, unknown>
|
|
@@ -2095,7 +2249,7 @@ interface JsxFactory {
|
|
|
2095
2249
|
|
|
2096
2250
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2097
2251
|
|
|
2098
|
-
export type
|
|
2252
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2099
2253
|
|
|
2100
2254
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2101
2255
|
`
|
|
@@ -2103,16 +2257,16 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2103
2257
|
}
|
|
2104
2258
|
|
|
2105
2259
|
// src/artifacts/vue-jsx/jsx.ts
|
|
2106
|
-
import { outdent as
|
|
2260
|
+
import { outdent as outdent34 } from "outdent";
|
|
2107
2261
|
function generateVueJsxFactory(ctx) {
|
|
2108
2262
|
const { factoryName } = ctx.jsx;
|
|
2109
2263
|
return {
|
|
2110
|
-
js:
|
|
2264
|
+
js: outdent34`
|
|
2111
2265
|
import { defineComponent, h, computed } from 'vue'
|
|
2112
2266
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
2113
2267
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2114
2268
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2115
|
-
|
|
2269
|
+
|
|
2116
2270
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
2117
2271
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2118
2272
|
|
|
@@ -2140,10 +2294,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2140
2294
|
})
|
|
2141
2295
|
|
|
2142
2296
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2143
|
-
|
|
2297
|
+
|
|
2144
2298
|
return () => {
|
|
2145
2299
|
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
2146
|
-
|
|
2300
|
+
|
|
2147
2301
|
return h(
|
|
2148
2302
|
props.as,
|
|
2149
2303
|
{
|
|
@@ -2157,10 +2311,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2157
2311
|
},
|
|
2158
2312
|
})
|
|
2159
2313
|
}
|
|
2160
|
-
|
|
2314
|
+
|
|
2161
2315
|
function createJsxFactory() {
|
|
2162
2316
|
const cache = new Map()
|
|
2163
|
-
|
|
2317
|
+
|
|
2164
2318
|
return new Proxy(styledFn, {
|
|
2165
2319
|
apply(_, __, args) {
|
|
2166
2320
|
return styledFn(...args)
|
|
@@ -2174,21 +2328,21 @@ function generateVueJsxFactory(ctx) {
|
|
|
2174
2328
|
})
|
|
2175
2329
|
}
|
|
2176
2330
|
|
|
2177
|
-
export const ${factoryName} = createJsxFactory()
|
|
2331
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2178
2332
|
|
|
2179
2333
|
`
|
|
2180
2334
|
};
|
|
2181
2335
|
}
|
|
2182
2336
|
|
|
2183
2337
|
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2184
|
-
import { outdent as
|
|
2338
|
+
import { outdent as outdent35 } from "outdent";
|
|
2185
2339
|
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2186
2340
|
const { factoryName } = ctx.jsx;
|
|
2187
2341
|
return {
|
|
2188
|
-
js:
|
|
2342
|
+
js: outdent35`
|
|
2189
2343
|
import { defineComponent, h, computed } from 'vue'
|
|
2190
2344
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2191
|
-
|
|
2345
|
+
|
|
2192
2346
|
function createStyled(Dynamic) {
|
|
2193
2347
|
function styledFn(template) {
|
|
2194
2348
|
const baseClassName = css(template)
|
|
@@ -2212,10 +2366,10 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2212
2366
|
})
|
|
2213
2367
|
}
|
|
2214
2368
|
}
|
|
2215
|
-
|
|
2369
|
+
|
|
2216
2370
|
function createJsxFactory() {
|
|
2217
2371
|
const cache = new Map()
|
|
2218
|
-
|
|
2372
|
+
|
|
2219
2373
|
return new Proxy(createStyled, {
|
|
2220
2374
|
apply(_, __, args) {
|
|
2221
2375
|
return createStyled(...args)
|
|
@@ -2229,13 +2383,13 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2229
2383
|
})
|
|
2230
2384
|
}
|
|
2231
2385
|
|
|
2232
|
-
export const ${factoryName} = createJsxFactory()
|
|
2386
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2233
2387
|
`
|
|
2234
2388
|
};
|
|
2235
2389
|
}
|
|
2236
2390
|
|
|
2237
2391
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2238
|
-
import { outdent as
|
|
2392
|
+
import { outdent as outdent36 } from "outdent";
|
|
2239
2393
|
function generateVueJsxPattern(ctx) {
|
|
2240
2394
|
const { typeName, factoryName } = ctx.jsx;
|
|
2241
2395
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2244,7 +2398,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2244
2398
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2245
2399
|
return {
|
|
2246
2400
|
name: dashName,
|
|
2247
|
-
js:
|
|
2401
|
+
js: outdent36`
|
|
2248
2402
|
import { defineComponent, h, computed } from 'vue'
|
|
2249
2403
|
${ctx.file.import(factoryName, "./factory")}
|
|
2250
2404
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -2262,7 +2416,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2262
2416
|
}
|
|
2263
2417
|
})
|
|
2264
2418
|
`,
|
|
2265
|
-
dts:
|
|
2419
|
+
dts: outdent36`
|
|
2266
2420
|
import { FunctionalComponent } from 'vue'
|
|
2267
2421
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
2268
2422
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -2277,15 +2431,15 @@ function generateVueJsxPattern(ctx) {
|
|
|
2277
2431
|
}
|
|
2278
2432
|
|
|
2279
2433
|
// src/artifacts/vue-jsx/types.ts
|
|
2280
|
-
import { outdent as
|
|
2434
|
+
import { outdent as outdent37 } from "outdent";
|
|
2281
2435
|
function generateVueJsxTypes(ctx) {
|
|
2282
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2436
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2283
2437
|
return {
|
|
2284
|
-
jsxFactory:
|
|
2438
|
+
jsxFactory: outdent37`
|
|
2285
2439
|
import { ${upperName} } from '../types/jsx'
|
|
2286
2440
|
export declare const ${factoryName}: ${upperName}
|
|
2287
2441
|
`,
|
|
2288
|
-
jsxType:
|
|
2442
|
+
jsxType: outdent37`
|
|
2289
2443
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2290
2444
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
2291
2445
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -2424,33 +2578,33 @@ type IntrinsicElement =
|
|
|
2424
2578
|
type RecipeFn = { __type: any }
|
|
2425
2579
|
|
|
2426
2580
|
interface JsxFactory {
|
|
2427
|
-
|
|
2581
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2428
2582
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2429
2583
|
T,
|
|
2430
2584
|
RecipeSelection<P>
|
|
2431
2585
|
>
|
|
2432
2586
|
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2433
2587
|
}
|
|
2434
|
-
|
|
2588
|
+
|
|
2435
2589
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2436
|
-
|
|
2437
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2438
|
-
|
|
2590
|
+
|
|
2591
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2592
|
+
|
|
2439
2593
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2440
2594
|
`
|
|
2441
2595
|
};
|
|
2442
2596
|
}
|
|
2443
2597
|
|
|
2444
2598
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2445
|
-
import { outdent as
|
|
2599
|
+
import { outdent as outdent38 } from "outdent";
|
|
2446
2600
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2447
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2601
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2448
2602
|
return {
|
|
2449
|
-
jsxFactory:
|
|
2603
|
+
jsxFactory: outdent38`
|
|
2450
2604
|
import { ${upperName} } from '../types/jsx'
|
|
2451
2605
|
export declare const ${factoryName}: ${upperName}
|
|
2452
2606
|
`,
|
|
2453
|
-
jsxType:
|
|
2607
|
+
jsxType: outdent38`
|
|
2454
2608
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2455
2609
|
|
|
2456
2610
|
type IntrinsicElement =
|
|
@@ -2586,11 +2740,11 @@ type IntrinsicElement =
|
|
|
2586
2740
|
interface JsxFactory {
|
|
2587
2741
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2588
2742
|
}
|
|
2589
|
-
|
|
2743
|
+
|
|
2590
2744
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2591
|
-
|
|
2592
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2593
|
-
|
|
2745
|
+
|
|
2746
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2747
|
+
|
|
2594
2748
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2595
2749
|
`
|
|
2596
2750
|
};
|
|
@@ -2605,8 +2759,8 @@ var typesMap = {
|
|
|
2605
2759
|
qwik: generateQwikJsxTypes
|
|
2606
2760
|
};
|
|
2607
2761
|
var typesStringLiteralMap = {
|
|
2608
|
-
react:
|
|
2609
|
-
solid:
|
|
2762
|
+
react: generateReactJsxStringLiteralTypes,
|
|
2763
|
+
solid: generateSolidJsxStringLiteralTypes,
|
|
2610
2764
|
qwik: generateQwikJsxStringLiteralTypes,
|
|
2611
2765
|
preact: generatePreactJsxStringLiteralTypes,
|
|
2612
2766
|
vue: generateVueJsxStringLiteralTypes
|
|
@@ -2704,7 +2858,7 @@ var csstype_d_ts_default = {
|
|
|
2704
2858
|
|
|
2705
2859
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2706
2860
|
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 =
|
|
2861
|
+
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
2862
|
};
|
|
2709
2863
|
|
|
2710
2864
|
// src/artifacts/generated/composition.d.ts.json
|
|
@@ -2714,7 +2868,7 @@ var composition_d_ts_default = {
|
|
|
2714
2868
|
|
|
2715
2869
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2716
2870
|
var recipe_d_ts_default = {
|
|
2717
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> =
|
|
2871
|
+
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
2872
|
};
|
|
2719
2873
|
|
|
2720
2874
|
// src/artifacts/generated/pattern.d.ts.json
|
|
@@ -2733,7 +2887,9 @@ var selectors_d_ts_default = {
|
|
|
2733
2887
|
};
|
|
2734
2888
|
|
|
2735
2889
|
// src/artifacts/types/generated.ts
|
|
2736
|
-
|
|
2890
|
+
import { match as match9 } from "ts-pattern";
|
|
2891
|
+
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2892
|
+
function getGeneratedTypes(ctx) {
|
|
2737
2893
|
return {
|
|
2738
2894
|
cssType: csstype_d_ts_default.content,
|
|
2739
2895
|
recipe: recipe_d_ts_default.content,
|
|
@@ -2741,15 +2897,15 @@ function getGeneratedTypes() {
|
|
|
2741
2897
|
parts: parts_d_ts_default.content,
|
|
2742
2898
|
composition: composition_d_ts_default.content,
|
|
2743
2899
|
selectors: selectors_d_ts_default.content,
|
|
2744
|
-
system: system_types_d_ts_default.content
|
|
2900
|
+
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
2901
|
};
|
|
2746
2902
|
}
|
|
2747
2903
|
|
|
2748
2904
|
// src/artifacts/types/main.ts
|
|
2749
|
-
import { outdent as
|
|
2905
|
+
import { outdent as outdent39 } from "outdent";
|
|
2750
2906
|
var generateTypesEntry = () => ({
|
|
2751
|
-
global:
|
|
2752
|
-
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2907
|
+
global: outdent39`
|
|
2908
|
+
import type { RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig } from './recipe'
|
|
2753
2909
|
import type { Parts } from './parts'
|
|
2754
2910
|
import type { PatternConfig, PatternProperties } from './pattern'
|
|
2755
2911
|
import type { GlobalStyleObject, SystemStyleObject } from './system-types'
|
|
@@ -2757,27 +2913,28 @@ var generateTypesEntry = () => ({
|
|
|
2757
2913
|
|
|
2758
2914
|
declare module '@pandacss/dev' {
|
|
2759
2915
|
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig
|
|
2916
|
+
export function defineSlotRecipe<S extends string, V extends SlotRecipeVariantRecord<S>>(config: SlotRecipeConfig<S, V>): SlotRecipeConfig
|
|
2760
2917
|
export function defineStyles(definition: SystemStyleObject): SystemStyleObject
|
|
2761
2918
|
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
2762
2919
|
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
2763
2920
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
2764
2921
|
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
|
|
2922
|
+
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2766
2923
|
}
|
|
2767
2924
|
`,
|
|
2768
|
-
index:
|
|
2925
|
+
index: outdent39`
|
|
2769
2926
|
import './global'
|
|
2770
2927
|
export type { ConditionalValue } from './conditions'
|
|
2771
2928
|
export type { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
2772
2929
|
|
|
2773
2930
|
`,
|
|
2774
|
-
helpers:
|
|
2931
|
+
helpers: outdent39`
|
|
2775
2932
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2776
2933
|
`
|
|
2777
2934
|
});
|
|
2778
2935
|
|
|
2779
2936
|
// src/artifacts/types/prop-types.ts
|
|
2780
|
-
import { outdent as
|
|
2937
|
+
import { outdent as outdent40 } from "outdent";
|
|
2781
2938
|
function generatePropTypes(ctx) {
|
|
2782
2939
|
const {
|
|
2783
2940
|
config: { strictTokens },
|
|
@@ -2785,7 +2942,7 @@ function generatePropTypes(ctx) {
|
|
|
2785
2942
|
} = ctx;
|
|
2786
2943
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2787
2944
|
const result = [
|
|
2788
|
-
|
|
2945
|
+
outdent40`
|
|
2789
2946
|
import type { ConditionalValue } from './conditions';
|
|
2790
2947
|
import type { CssProperties } from './system-types'
|
|
2791
2948
|
import type { Tokens } from '../tokens'
|
|
@@ -2808,23 +2965,23 @@ function generatePropTypes(ctx) {
|
|
|
2808
2965
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2809
2966
|
});
|
|
2810
2967
|
result.push("}");
|
|
2811
|
-
return
|
|
2968
|
+
return outdent40`
|
|
2812
2969
|
${result.join("\n")}
|
|
2813
2970
|
|
|
2814
2971
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2815
|
-
? ConditionalValue<PropertyTypes[T]${strictText}>
|
|
2972
|
+
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2816
2973
|
: T extends keyof CssProperties
|
|
2817
|
-
? ConditionalValue<CssProperties[T]>
|
|
2974
|
+
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2818
2975
|
: ConditionalValue<string | number>
|
|
2819
2976
|
`;
|
|
2820
2977
|
}
|
|
2821
2978
|
|
|
2822
2979
|
// src/artifacts/types/style-props.ts
|
|
2823
2980
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
2824
|
-
import
|
|
2981
|
+
import outdent41 from "outdent";
|
|
2825
2982
|
function generateStyleProps(ctx) {
|
|
2826
|
-
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
2827
|
-
return
|
|
2983
|
+
const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
2984
|
+
return outdent41`
|
|
2828
2985
|
import type { ConditionalValue } from './conditions'
|
|
2829
2986
|
import type { PropertyValue } from './prop-type'
|
|
2830
2987
|
import type { Token } from '../tokens'
|
|
@@ -2841,7 +2998,7 @@ function generateStyleProps(ctx) {
|
|
|
2841
2998
|
|
|
2842
2999
|
// src/artifacts/types/token-types.ts
|
|
2843
3000
|
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
2844
|
-
import { outdent as
|
|
3001
|
+
import { outdent as outdent42 } from "outdent";
|
|
2845
3002
|
import pluralize from "pluralize";
|
|
2846
3003
|
var categories = [
|
|
2847
3004
|
"zIndex",
|
|
@@ -2886,12 +3043,12 @@ function generateTokenTypes(ctx) {
|
|
|
2886
3043
|
result.add("} & { [token: string]: never }");
|
|
2887
3044
|
set.add(Array.from(result).join("\n"));
|
|
2888
3045
|
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
2889
|
-
return
|
|
3046
|
+
return outdent42.string(Array.from(set).join("\n\n"));
|
|
2890
3047
|
}
|
|
2891
3048
|
|
|
2892
3049
|
// src/artifacts/index.ts
|
|
2893
3050
|
function setupHelpers(ctx) {
|
|
2894
|
-
const code = generateHelpers();
|
|
3051
|
+
const code = generateHelpers(ctx);
|
|
2895
3052
|
return {
|
|
2896
3053
|
files: [{ file: ctx.file.ext("helpers"), code: code.js }]
|
|
2897
3054
|
};
|
|
@@ -2919,7 +3076,7 @@ function setupDesignTokens(ctx) {
|
|
|
2919
3076
|
};
|
|
2920
3077
|
}
|
|
2921
3078
|
function setupTypes(ctx) {
|
|
2922
|
-
const gen = getGeneratedTypes();
|
|
3079
|
+
const gen = getGeneratedTypes(ctx);
|
|
2923
3080
|
const conditions = generateConditions(ctx);
|
|
2924
3081
|
const jsx = generateJsxTypes(ctx);
|
|
2925
3082
|
const entry = generateTypesEntry();
|
|
@@ -2967,6 +3124,18 @@ function setupCva(ctx) {
|
|
|
2967
3124
|
]
|
|
2968
3125
|
};
|
|
2969
3126
|
}
|
|
3127
|
+
function setupSva(ctx) {
|
|
3128
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
3129
|
+
return;
|
|
3130
|
+
const code = generateSvaFn(ctx);
|
|
3131
|
+
return {
|
|
3132
|
+
dir: ctx.paths.css,
|
|
3133
|
+
files: [
|
|
3134
|
+
{ file: ctx.file.ext("sva"), code: code.js },
|
|
3135
|
+
{ file: "sva.d.ts", code: code.dts }
|
|
3136
|
+
]
|
|
3137
|
+
};
|
|
3138
|
+
}
|
|
2970
3139
|
function setupCx(ctx) {
|
|
2971
3140
|
const code = generateCx();
|
|
2972
3141
|
return {
|
|
@@ -2983,8 +3152,8 @@ function setupRecipes(ctx) {
|
|
|
2983
3152
|
return;
|
|
2984
3153
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2985
3154
|
const index = {
|
|
2986
|
-
js:
|
|
2987
|
-
dts:
|
|
3155
|
+
js: outdent43.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3156
|
+
dts: outdent43.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2988
3157
|
};
|
|
2989
3158
|
return {
|
|
2990
3159
|
dir: ctx.paths.recipe,
|
|
@@ -3003,8 +3172,8 @@ function setupPatterns(ctx) {
|
|
|
3003
3172
|
if (!files)
|
|
3004
3173
|
return;
|
|
3005
3174
|
const index = {
|
|
3006
|
-
js:
|
|
3007
|
-
dts:
|
|
3175
|
+
js: outdent43.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3176
|
+
dts: outdent43.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
3008
3177
|
};
|
|
3009
3178
|
return {
|
|
3010
3179
|
dir: ctx.paths.pattern,
|
|
@@ -3019,20 +3188,20 @@ function setupPatterns(ctx) {
|
|
|
3019
3188
|
function setupJsx(ctx) {
|
|
3020
3189
|
if (!ctx.jsx.framework)
|
|
3021
3190
|
return;
|
|
3022
|
-
const isValidProp =
|
|
3191
|
+
const isValidProp = generateIsValidProp(ctx);
|
|
3023
3192
|
const types = generateJsxTypes(ctx);
|
|
3024
3193
|
const factory = generateJsxFactory(ctx);
|
|
3025
3194
|
const patterns = generateJsxPatterns(ctx);
|
|
3026
3195
|
const index = {
|
|
3027
|
-
js:
|
|
3196
|
+
js: outdent43`
|
|
3028
3197
|
${ctx.file.export("./factory")}
|
|
3029
3198
|
${isValidProp?.js ? ctx.file.export("./is-valid-prop") : ""}
|
|
3030
|
-
${
|
|
3199
|
+
${outdent43.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
3031
3200
|
`,
|
|
3032
|
-
dts:
|
|
3201
|
+
dts: outdent43`
|
|
3033
3202
|
export * from './factory'
|
|
3034
3203
|
${isValidProp?.dts ? `export * from './is-valid-prop'` : ""}
|
|
3035
|
-
${
|
|
3204
|
+
${outdent43.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
3036
3205
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
3037
3206
|
`
|
|
3038
3207
|
};
|
|
@@ -3052,15 +3221,17 @@ function setupJsx(ctx) {
|
|
|
3052
3221
|
}
|
|
3053
3222
|
function setupCssIndex(ctx) {
|
|
3054
3223
|
const index = {
|
|
3055
|
-
js:
|
|
3224
|
+
js: outdent43`
|
|
3056
3225
|
${ctx.file.export("./css")}
|
|
3057
3226
|
${ctx.file.export("./cx")}
|
|
3058
3227
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./cva")}
|
|
3228
|
+
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./sva")}
|
|
3059
3229
|
`,
|
|
3060
|
-
dts:
|
|
3230
|
+
dts: outdent43`
|
|
3061
3231
|
export * from './css'
|
|
3062
3232
|
export * from './cx'
|
|
3063
3233
|
${ctx.isTemplateLiteralSyntax ? "" : `export * from './cva'`}
|
|
3234
|
+
${ctx.isTemplateLiteralSyntax ? "" : `export * from './sva'`}
|
|
3064
3235
|
`
|
|
3065
3236
|
};
|
|
3066
3237
|
return {
|
|
@@ -3104,6 +3275,7 @@ var generateArtifacts = (ctx) => () => {
|
|
|
3104
3275
|
setupKeyframes(ctx),
|
|
3105
3276
|
setupTypes(ctx),
|
|
3106
3277
|
setupCva(ctx),
|
|
3278
|
+
setupSva(ctx),
|
|
3107
3279
|
setupCx(ctx),
|
|
3108
3280
|
setupCss(ctx),
|
|
3109
3281
|
setupRecipes(ctx),
|
|
@@ -3148,13 +3320,15 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3148
3320
|
].filter(Boolean).join("\n\n") : unresolved
|
|
3149
3321
|
});
|
|
3150
3322
|
sheet.append(...files);
|
|
3151
|
-
|
|
3323
|
+
const output = sheet.toCss({ optimize: true, minify });
|
|
3324
|
+
ctx.hooks.callHook("generator:css", "styles.css", output);
|
|
3325
|
+
return output;
|
|
3152
3326
|
};
|
|
3153
3327
|
|
|
3154
3328
|
// src/artifacts/css/parser-css.ts
|
|
3155
3329
|
import { logger } from "@pandacss/logger";
|
|
3156
3330
|
import { pipe, tap, tryCatch } from "lil-fp/func";
|
|
3157
|
-
import { P, match as
|
|
3331
|
+
import { P, match as match10 } from "ts-pattern";
|
|
3158
3332
|
var generateParserCss = (ctx) => (result) => pipe(
|
|
3159
3333
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3160
3334
|
tap(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3168,6 +3342,11 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3168
3342
|
sheet.processAtomicRecipe(data);
|
|
3169
3343
|
});
|
|
3170
3344
|
});
|
|
3345
|
+
result2.sva.forEach((sva) => {
|
|
3346
|
+
sva.data.forEach((data) => {
|
|
3347
|
+
sheet.processAtomicSlotRecipe(data);
|
|
3348
|
+
});
|
|
3349
|
+
});
|
|
3171
3350
|
result2.jsx.forEach((jsx) => {
|
|
3172
3351
|
jsx.data.forEach((data) => {
|
|
3173
3352
|
sheet.processStyleProps(data);
|
|
@@ -3179,7 +3358,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3179
3358
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3180
3359
|
if (!recipeConfig)
|
|
3181
3360
|
continue;
|
|
3182
|
-
|
|
3361
|
+
match10(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3183
3362
|
recipe.data.forEach((data) => {
|
|
3184
3363
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3185
3364
|
sheet.processStyleProps(styleProps);
|
|
@@ -3198,7 +3377,7 @@ var generateParserCss = (ctx) => (result) => pipe(
|
|
|
3198
3377
|
result2.pattern.forEach((patternSet, name) => {
|
|
3199
3378
|
try {
|
|
3200
3379
|
for (const pattern of patternSet) {
|
|
3201
|
-
|
|
3380
|
+
match10(pattern).with({ type: "jsx-pattern", name: P.string }, ({ name: jsxName }) => {
|
|
3202
3381
|
pattern.data.forEach((data) => {
|
|
3203
3382
|
const fnName = patterns.getFnName(jsxName);
|
|
3204
3383
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -3292,11 +3471,13 @@ var getBaseEngine = (conf) => {
|
|
|
3292
3471
|
const sheetContext = createSheetContext();
|
|
3293
3472
|
return new Stylesheet(sheetContext, {
|
|
3294
3473
|
content: options?.content,
|
|
3295
|
-
recipes: theme?.recipes
|
|
3474
|
+
recipes: theme?.recipes,
|
|
3475
|
+
slotRecipes: theme?.slotRecipes
|
|
3296
3476
|
});
|
|
3297
3477
|
};
|
|
3298
3478
|
const recipeContext = createSheetContext();
|
|
3299
|
-
const
|
|
3479
|
+
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
3480
|
+
const recipes = new Recipes(recipeConfigs, recipeContext);
|
|
3300
3481
|
recipes.save();
|
|
3301
3482
|
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
3302
3483
|
const propertyMap = new Map(properties.map((prop) => [prop, true]));
|
|
@@ -3327,13 +3508,14 @@ var getBaseEngine = (conf) => {
|
|
|
3327
3508
|
// src/engines/jsx.ts
|
|
3328
3509
|
import { capitalize as capitalize2 } from "@pandacss/shared";
|
|
3329
3510
|
var getJsxEngine = (config) => {
|
|
3330
|
-
const { jsxFactory, jsxFramework } = config;
|
|
3511
|
+
const { jsxFactory, jsxFramework, jsxStyleProps: jsxStyleProps2 } = config;
|
|
3331
3512
|
return {
|
|
3332
3513
|
factoryName: jsxFactory,
|
|
3333
3514
|
upperName: capitalize2(jsxFactory),
|
|
3334
3515
|
typeName: `HTML${capitalize2(jsxFactory)}Props`,
|
|
3335
3516
|
componentName: `${capitalize2(jsxFactory)}Component`,
|
|
3336
|
-
framework: jsxFramework
|
|
3517
|
+
framework: jsxFramework,
|
|
3518
|
+
styleProps: jsxStyleProps2 ?? "all"
|
|
3337
3519
|
};
|
|
3338
3520
|
};
|
|
3339
3521
|
|
|
@@ -3355,12 +3537,8 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
|
3355
3537
|
};
|
|
3356
3538
|
|
|
3357
3539
|
// src/engines/pattern.ts
|
|
3358
|
-
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, memo as memo2, uncapitalize } from "@pandacss/shared";
|
|
3540
|
+
import { capitalize as capitalize3, dashCase, mapObject as mapObject2, memo as memo2, uncapitalize, createRegex } from "@pandacss/shared";
|
|
3359
3541
|
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
3542
|
var getPatternEngine = (config) => {
|
|
3365
3543
|
const patterns = config.patterns ?? {};
|
|
3366
3544
|
const getNames = (name) => {
|
|
@@ -3428,6 +3606,7 @@ var defaults = (conf) => ({
|
|
|
3428
3606
|
config: {
|
|
3429
3607
|
cssVarRoot: ":where(:root, :host)",
|
|
3430
3608
|
jsxFactory: "styled",
|
|
3609
|
+
jsxStyleProps: "all",
|
|
3431
3610
|
outExtension: "mjs",
|
|
3432
3611
|
shorthands: true,
|
|
3433
3612
|
syntax: "object-literal",
|
|
@@ -3457,6 +3636,7 @@ var createGenerator = (conf) => {
|
|
|
3457
3636
|
importMap: getImportMap(config.outdir.replace(relativeBaseUrl, "")),
|
|
3458
3637
|
jsx: {
|
|
3459
3638
|
factory: jsx.factoryName,
|
|
3639
|
+
styleProps: jsx.styleProps,
|
|
3460
3640
|
isStyleProp: isValidProperty,
|
|
3461
3641
|
nodes: [...patterns.details, ...recipes.details]
|
|
3462
3642
|
},
|