@pandacss/generator 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +72 -23
- package/dist/index.d.ts +72 -23
- package/dist/index.js +540 -372
- package/dist/index.mjs +538 -370
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -130,7 +130,7 @@ var getMessages = (ctx) => ({
|
|
|
130
130
|
|
|
131
131
|
// src/artifacts/index.ts
|
|
132
132
|
var import_shared4 = require("@pandacss/shared");
|
|
133
|
-
var
|
|
133
|
+
var import_outdent43 = __toESM(require("outdent"));
|
|
134
134
|
|
|
135
135
|
// src/artifacts/css/global-css.ts
|
|
136
136
|
var generateGlobalCss = (ctx) => {
|
|
@@ -419,7 +419,10 @@ var generateStaticCss = (ctx) => {
|
|
|
419
419
|
return [];
|
|
420
420
|
return Object.keys(values);
|
|
421
421
|
},
|
|
422
|
-
getRecipeKeys: (recipe) =>
|
|
422
|
+
getRecipeKeys: (recipe) => {
|
|
423
|
+
const recipeConfig = recipes.details.find((detail) => detail.baseName === recipe);
|
|
424
|
+
return Object.assign({ __base: recipeConfig?.config.base }, recipeConfig?.variantKeyMap ?? {});
|
|
425
|
+
}
|
|
423
426
|
});
|
|
424
427
|
results.css.forEach((css2) => {
|
|
425
428
|
sheet.processAtomic(css2);
|
|
@@ -429,7 +432,7 @@ var generateStaticCss = (ctx) => {
|
|
|
429
432
|
const recipeConfig = recipes.getConfig(name);
|
|
430
433
|
if (!recipeConfig)
|
|
431
434
|
return;
|
|
432
|
-
sheet.processRecipe(recipeConfig, value);
|
|
435
|
+
sheet.processRecipe(name, recipeConfig, value);
|
|
433
436
|
});
|
|
434
437
|
});
|
|
435
438
|
const output = sheet.toCss({ optimize });
|
|
@@ -518,14 +521,15 @@ function generateConditions(ctx) {
|
|
|
518
521
|
js: import_outdent2.default`
|
|
519
522
|
${ctx.file.import("withoutSpace", "../helpers")}
|
|
520
523
|
|
|
521
|
-
const
|
|
524
|
+
const conditionsStr = "${keys.join(",")}"
|
|
525
|
+
const conditions = new Set(conditionsStr.split(','))
|
|
522
526
|
|
|
523
527
|
export function isCondition(value){
|
|
524
528
|
return conditions.has(value) || /^@|&|&$/.test(value)
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
const underscoreRegex = /^_/
|
|
528
|
-
const
|
|
532
|
+
const conditionsSelectorRegex = /&|@/
|
|
529
533
|
|
|
530
534
|
export function finalizeConditions(paths){
|
|
531
535
|
return paths.map((path) => {
|
|
@@ -533,7 +537,7 @@ function generateConditions(ctx) {
|
|
|
533
537
|
return path.replace(underscoreRegex, '')
|
|
534
538
|
}
|
|
535
539
|
|
|
536
|
-
if (
|
|
540
|
+
if (conditionsSelectorRegex.test(path)){
|
|
537
541
|
return \`[\${withoutSpace(path.trim())}]\`
|
|
538
542
|
}
|
|
539
543
|
|
|
@@ -613,7 +617,6 @@ function generateStringLiteralConditions(ctx) {
|
|
|
613
617
|
|
|
614
618
|
// src/artifacts/js/css-fn.ts
|
|
615
619
|
var import_outdent4 = require("outdent");
|
|
616
|
-
var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
|
|
617
620
|
function generateCssFn(ctx) {
|
|
618
621
|
const {
|
|
619
622
|
utility,
|
|
@@ -621,6 +624,10 @@ function generateCssFn(ctx) {
|
|
|
621
624
|
conditions
|
|
622
625
|
} = ctx;
|
|
623
626
|
const { separator } = utility;
|
|
627
|
+
const shorthandsByProp = Array.from(utility.shorthands.entries()).reduce((acc, [shorthand, prop]) => {
|
|
628
|
+
acc[prop] = shorthand;
|
|
629
|
+
return acc;
|
|
630
|
+
}, {});
|
|
624
631
|
return {
|
|
625
632
|
dts: import_outdent4.outdent`
|
|
626
633
|
import type { SystemStyleObject } from '../types'
|
|
@@ -636,35 +643,45 @@ function generateCssFn(ctx) {
|
|
|
636
643
|
${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
637
644
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
638
645
|
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
+
const utilities = "${utility.entries().map(([prop, className]) => {
|
|
647
|
+
const shorthand = shorthandsByProp[prop];
|
|
648
|
+
return [prop, shorthand ? [className, shorthand === className ? 1 : shorthand].join("/") : className].join(":");
|
|
649
|
+
}).join(",")}"
|
|
650
|
+
|
|
651
|
+
const classMap = {}
|
|
652
|
+
${utility.hasShorthand ? import_outdent4.outdent`
|
|
653
|
+
const shorthands = {}
|
|
654
|
+
utilities.split(',').forEach((utility) => {
|
|
655
|
+
const [prop, meta] = utility.split(':')
|
|
656
|
+
const [className, shorthand] = meta.split('/')
|
|
657
|
+
classMap[prop] = className
|
|
658
|
+
if (shorthand) shorthands[shorthand === '1' ? className : shorthand] = prop
|
|
659
|
+
})
|
|
646
660
|
|
|
647
661
|
const resolveShorthand = (prop) => shorthands[prop] || prop
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
662
|
+
` : import_outdent4.outdent`
|
|
663
|
+
utilities.split(',').forEach((utility) => {
|
|
664
|
+
const [prop, className] = utility.split(':')
|
|
665
|
+
classMap[prop] = className
|
|
666
|
+
})
|
|
667
|
+
`}
|
|
655
668
|
|
|
656
669
|
const context = {
|
|
657
|
-
|
|
670
|
+
${hash ? "hash: true," : ""}
|
|
658
671
|
conditions: {
|
|
659
672
|
shift: sortConditions,
|
|
660
673
|
finalize: finalizeConditions,
|
|
661
|
-
breakpoints: { keys:
|
|
674
|
+
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
662
675
|
},
|
|
663
676
|
utility: {
|
|
664
|
-
|
|
665
|
-
transform,
|
|
666
|
-
|
|
667
|
-
|
|
677
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
678
|
+
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
679
|
+
const key = resolveShorthand(prop)
|
|
680
|
+
const propKey = classMap[key] || hypenateProperty(key)
|
|
681
|
+
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
682
|
+
}` : `(key, value) => ({ className: \`\${classMap[key] || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
683
|
+
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
684
|
+
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
668
685
|
}
|
|
669
686
|
}
|
|
670
687
|
|
|
@@ -839,20 +856,33 @@ var import_outdent8 = require("outdent");
|
|
|
839
856
|
|
|
840
857
|
// src/artifacts/generated/helpers.mjs.json
|
|
841
858
|
var helpers_mjs_default = {
|
|
842
|
-
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/
|
|
859
|
+
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'
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
// src/artifacts/generated/astish.mjs.json
|
|
863
|
+
var astish_mjs_default = {
|
|
864
|
+
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'
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// src/artifacts/generated/normalize-html.mjs.json
|
|
868
|
+
var normalize_html_mjs_default = {
|
|
869
|
+
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'
|
|
843
870
|
};
|
|
844
871
|
|
|
845
872
|
// src/artifacts/js/helpers.ts
|
|
846
|
-
function generateHelpers() {
|
|
873
|
+
function generateHelpers(ctx) {
|
|
847
874
|
return {
|
|
848
875
|
js: import_outdent8.outdent`
|
|
849
876
|
${helpers_mjs_default.content}
|
|
877
|
+
${ctx.isTemplateLiteralSyntax ? astish_mjs_default.content : ""}
|
|
850
878
|
|
|
851
|
-
|
|
879
|
+
${ctx.jsx.framework ? `${normalize_html_mjs_default.content}` : ""}
|
|
880
|
+
|
|
881
|
+
export function __spreadValues(a, b) {
|
|
852
882
|
return { ...a, ...b }
|
|
853
883
|
}
|
|
854
884
|
|
|
855
|
-
export function __objRest(source, exclude){
|
|
885
|
+
export function __objRest(source, exclude) {
|
|
856
886
|
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
857
887
|
}
|
|
858
888
|
`
|
|
@@ -861,19 +891,29 @@ function generateHelpers() {
|
|
|
861
891
|
|
|
862
892
|
// src/artifacts/generated/is-valid-prop.mjs.json
|
|
863
893
|
var is_valid_prop_mjs_default = {
|
|
864
|
-
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'
|
|
894
|
+
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'
|
|
865
895
|
};
|
|
866
896
|
|
|
867
897
|
// src/artifacts/js/is-valid-prop.ts
|
|
868
898
|
var import_outdent9 = require("outdent");
|
|
869
|
-
|
|
899
|
+
var import_ts_pattern = require("ts-pattern");
|
|
900
|
+
var cssPropRegex = /var cssPropertiesStr = ".*?";/;
|
|
901
|
+
var memoFnDeclarationRegex = /function memo(.+?)\nvar selectorRegex/s;
|
|
902
|
+
function generateIsValidProp(ctx) {
|
|
870
903
|
if (ctx.isTemplateLiteralSyntax)
|
|
871
904
|
return;
|
|
872
905
|
let content = is_valid_prop_mjs_default.content;
|
|
873
906
|
content = content.replace(
|
|
874
|
-
|
|
875
|
-
`var
|
|
907
|
+
'var userGeneratedStr = "";',
|
|
908
|
+
`var userGeneratedStr = "${(0, import_ts_pattern.match)(ctx.jsx.styleProps).with("all", () => Array.from(new Set(ctx.properties)).join(",")).with("minimal", () => "css").with("none", () => "").exhaustive()}"`
|
|
876
909
|
);
|
|
910
|
+
content = content.replace(memoFnDeclarationRegex, "var selectorRegex");
|
|
911
|
+
if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") {
|
|
912
|
+
content = content.replace("/* @__PURE__ */ memo(", "/* @__PURE__ */ (");
|
|
913
|
+
content = content.replace(cssPropRegex, 'var cssPropertiesStr = "";');
|
|
914
|
+
} else {
|
|
915
|
+
content = ctx.file.import("memo", "../helpers") + "\n" + content;
|
|
916
|
+
}
|
|
877
917
|
return {
|
|
878
918
|
js: content,
|
|
879
919
|
dts: import_outdent9.outdent`
|
|
@@ -888,12 +928,12 @@ function generateisValidProp(ctx) {
|
|
|
888
928
|
var import_shared = require("@pandacss/shared");
|
|
889
929
|
var import_javascript_stringify = require("javascript-stringify");
|
|
890
930
|
var import_outdent10 = require("outdent");
|
|
891
|
-
var
|
|
931
|
+
var import_ts_pattern2 = require("ts-pattern");
|
|
892
932
|
function generatePattern(ctx) {
|
|
893
933
|
if (ctx.patterns.isEmpty())
|
|
894
934
|
return;
|
|
895
935
|
return ctx.patterns.details.map((pattern) => {
|
|
896
|
-
const {
|
|
936
|
+
const { baseName, config, dashName, upperName, styleFnName, blocklistType } = pattern;
|
|
897
937
|
const { properties, transform, strict, description } = config;
|
|
898
938
|
const transformFn = (0, import_javascript_stringify.stringify)({ transform }) ?? "";
|
|
899
939
|
const helperImports = ["mapObject"];
|
|
@@ -914,7 +954,7 @@ function generatePattern(ctx) {
|
|
|
914
954
|
export type ${upperName}Properties = {
|
|
915
955
|
${Object.keys(properties ?? {}).map((key) => {
|
|
916
956
|
const value = properties[key];
|
|
917
|
-
return (0,
|
|
957
|
+
return (0, import_ts_pattern2.match)(value).with({ type: "property" }, (value2) => {
|
|
918
958
|
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
919
959
|
}).with({ type: "token" }, (value2) => {
|
|
920
960
|
if (value2.property) {
|
|
@@ -929,7 +969,7 @@ function generatePattern(ctx) {
|
|
|
929
969
|
}).join("\n ")}
|
|
930
970
|
}
|
|
931
971
|
|
|
932
|
-
${strict ? import_outdent10.outdent`export declare function ${
|
|
972
|
+
${strict ? import_outdent10.outdent`export declare function ${baseName}(options: ${upperName}Properties): string` : import_outdent10.outdent`
|
|
933
973
|
|
|
934
974
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
935
975
|
|
|
@@ -939,7 +979,7 @@ function generatePattern(ctx) {
|
|
|
939
979
|
}
|
|
940
980
|
|
|
941
981
|
${description ? `/** ${description} */` : ""}
|
|
942
|
-
export declare const ${
|
|
982
|
+
export declare const ${baseName}: ${upperName}PatternFn;
|
|
943
983
|
`}
|
|
944
984
|
|
|
945
985
|
`,
|
|
@@ -947,22 +987,24 @@ function generatePattern(ctx) {
|
|
|
947
987
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
948
988
|
${ctx.file.import("css", "../css/index")}
|
|
949
989
|
|
|
950
|
-
const ${
|
|
990
|
+
const ${baseName}Config = ${transformFn.replace(`{transform`, `{
|
|
951
991
|
transform`)}
|
|
952
992
|
|
|
953
|
-
export const ${styleFnName} = (styles = {}) => ${
|
|
993
|
+
export const ${styleFnName} = (styles = {}) => ${baseName}Config.transform(styles, { map: mapObject })
|
|
954
994
|
|
|
955
|
-
export const ${
|
|
956
|
-
${
|
|
995
|
+
export const ${baseName} = (styles) => css(${styleFnName}(styles))
|
|
996
|
+
${baseName}.raw = (styles) => styles
|
|
957
997
|
`
|
|
958
998
|
};
|
|
959
999
|
});
|
|
960
1000
|
}
|
|
961
1001
|
|
|
962
1002
|
// src/artifacts/js/recipe.ts
|
|
1003
|
+
var import_core4 = require("@pandacss/core");
|
|
963
1004
|
var import_shared2 = require("@pandacss/shared");
|
|
964
1005
|
var import_outdent11 = require("outdent");
|
|
965
|
-
var
|
|
1006
|
+
var import_ts_pattern3 = require("ts-pattern");
|
|
1007
|
+
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
966
1008
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
967
1009
|
function generateRecipes(ctx) {
|
|
968
1010
|
const {
|
|
@@ -995,9 +1037,9 @@ function generateRecipes(ctx) {
|
|
|
995
1037
|
}
|
|
996
1038
|
|
|
997
1039
|
const recipeCss = createCss({
|
|
998
|
-
|
|
1040
|
+
${hash ? "hash: true," : ""}
|
|
999
1041
|
utility: {
|
|
1000
|
-
|
|
1042
|
+
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
1001
1043
|
transform,
|
|
1002
1044
|
}
|
|
1003
1045
|
})
|
|
@@ -1018,28 +1060,61 @@ function generateRecipes(ctx) {
|
|
|
1018
1060
|
return [
|
|
1019
1061
|
createRecipeFn,
|
|
1020
1062
|
...ctx.recipes.details.map((recipe) => {
|
|
1021
|
-
const { config, upperName, variantKeyMap, dashName } = recipe;
|
|
1022
|
-
const {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1063
|
+
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
1064
|
+
const { description, defaultVariants, compoundVariants } = config;
|
|
1065
|
+
const jsCode = (0, import_ts_pattern3.match)(config).when(
|
|
1066
|
+
import_core4.isSlotRecipe,
|
|
1067
|
+
(config2) => import_outdent11.outdent`
|
|
1068
|
+
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1069
|
+
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1070
|
+
|
|
1071
|
+
const ${baseName}DefaultVariants = ${stringify2(defaultVariants ?? {})}
|
|
1072
|
+
const ${baseName}CompoundVariants = ${stringify2(compoundVariants ?? [])}
|
|
1073
|
+
|
|
1074
|
+
const ${baseName}SlotNames = ${stringify2(config2.slots.map((slot) => [slot, `${config2.className}__${slot}`]))}
|
|
1075
|
+
const ${baseName}SlotFns = ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
|
|
1076
|
+
|
|
1077
|
+
const ${baseName}Fn = (props = {}) => {
|
|
1078
|
+
return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn(props)]))
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
const ${baseName}VariantKeys = ${stringify2(Object.keys(variantKeyMap))}
|
|
1082
|
+
|
|
1083
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1084
|
+
__recipe__: false,
|
|
1085
|
+
raw: (props) => props,
|
|
1086
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1087
|
+
variantMap: ${stringify2(variantKeyMap)},
|
|
1088
|
+
splitVariantProps(props) {
|
|
1089
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1090
|
+
},
|
|
1091
|
+
})
|
|
1092
|
+
`
|
|
1093
|
+
).otherwise(
|
|
1094
|
+
(config2) => import_outdent11.outdent`
|
|
1026
1095
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1027
1096
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1028
1097
|
|
|
1029
|
-
const ${
|
|
1098
|
+
const ${baseName}Fn = createRecipe('${config2.className}', ${stringify2(defaultVariants ?? {})}, ${stringify2(
|
|
1030
1099
|
compoundVariants ?? []
|
|
1031
1100
|
)})
|
|
1032
1101
|
|
|
1033
|
-
|
|
1102
|
+
const ${baseName}VariantMap = ${stringify2(variantKeyMap)}
|
|
1103
|
+
const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
|
|
1104
|
+
export const ${baseName} = Object.assign(${baseName}Fn, {
|
|
1034
1105
|
__recipe__: true,
|
|
1035
1106
|
raw: (props) => props,
|
|
1036
|
-
variantKeys: ${
|
|
1037
|
-
variantMap: ${
|
|
1107
|
+
variantKeys: ${baseName}VariantKeys,
|
|
1108
|
+
variantMap: ${baseName}VariantMap,
|
|
1038
1109
|
splitVariantProps(props) {
|
|
1039
|
-
return splitProps(props, ${
|
|
1110
|
+
return splitProps(props, ${baseName}VariantKeys)
|
|
1040
1111
|
},
|
|
1041
1112
|
})
|
|
1042
|
-
|
|
1113
|
+
`
|
|
1114
|
+
);
|
|
1115
|
+
return {
|
|
1116
|
+
name: dashName,
|
|
1117
|
+
js: jsCode,
|
|
1043
1118
|
dts: import_outdent11.outdent`
|
|
1044
1119
|
import type { ConditionalValue } from '../types'
|
|
1045
1120
|
import type { Pretty } from '../types/helpers'
|
|
@@ -1063,7 +1138,7 @@ function generateRecipes(ctx) {
|
|
|
1063
1138
|
|
|
1064
1139
|
interface ${upperName}Recipe {
|
|
1065
1140
|
__type: ${upperName}VariantProps
|
|
1066
|
-
(props?: ${upperName}VariantProps): string
|
|
1141
|
+
(props?: ${upperName}VariantProps): ${(0, import_core4.isSlotRecipe)(config) ? `Pretty<Record<${(0, import_shared2.unionType)(config.slots)}, string>>` : "string"}
|
|
1067
1142
|
raw: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
|
|
1068
1143
|
variantMap: ${upperName}VariantMap
|
|
1069
1144
|
variantKeys: Array<keyof ${upperName}Variant>
|
|
@@ -1071,15 +1146,49 @@ function generateRecipes(ctx) {
|
|
|
1071
1146
|
}
|
|
1072
1147
|
|
|
1073
1148
|
${description ? `/** ${description} */` : ""}
|
|
1074
|
-
export declare const ${
|
|
1149
|
+
export declare const ${baseName}: ${upperName}Recipe
|
|
1075
1150
|
`
|
|
1076
1151
|
};
|
|
1077
1152
|
})
|
|
1078
1153
|
];
|
|
1079
1154
|
}
|
|
1080
1155
|
|
|
1156
|
+
// src/artifacts/js/sva.ts
|
|
1157
|
+
var import_outdent12 = require("outdent");
|
|
1158
|
+
function generateSvaFn(ctx) {
|
|
1159
|
+
return {
|
|
1160
|
+
js: import_outdent12.outdent`
|
|
1161
|
+
${ctx.file.import("getSlotRecipes", "../helpers")}
|
|
1162
|
+
${ctx.file.import("cva", "./cva")}
|
|
1163
|
+
|
|
1164
|
+
export function sva(config) {
|
|
1165
|
+
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
1166
|
+
|
|
1167
|
+
function svaFn(props) {
|
|
1168
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
1169
|
+
return Object.fromEntries(result)
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const [, firstCva] = slots[0]
|
|
1173
|
+
|
|
1174
|
+
return Object.assign(svaFn, {
|
|
1175
|
+
__cva__: false,
|
|
1176
|
+
variantMap: firstCva.variantMap,
|
|
1177
|
+
variantKeys: firstCva.variantKeys,
|
|
1178
|
+
splitVariantProps: firstCva.splitVariantProps,
|
|
1179
|
+
})
|
|
1180
|
+
}
|
|
1181
|
+
`,
|
|
1182
|
+
dts: import_outdent12.outdent`
|
|
1183
|
+
import type { SlotRecipeCreatorFn } from '../types/recipe'
|
|
1184
|
+
|
|
1185
|
+
export declare const sva: SlotRecipeCreatorFn
|
|
1186
|
+
`
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1081
1190
|
// src/artifacts/js/token.ts
|
|
1082
|
-
var
|
|
1191
|
+
var import_outdent13 = __toESM(require("outdent"));
|
|
1083
1192
|
function generateTokenJs(ctx) {
|
|
1084
1193
|
const { tokens } = ctx;
|
|
1085
1194
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1090,7 +1199,7 @@ function generateTokenJs(ctx) {
|
|
|
1090
1199
|
});
|
|
1091
1200
|
const obj = Object.fromEntries(map);
|
|
1092
1201
|
return {
|
|
1093
|
-
js:
|
|
1202
|
+
js: import_outdent13.default`
|
|
1094
1203
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1095
1204
|
|
|
1096
1205
|
export function token(path, fallback) {
|
|
@@ -1103,7 +1212,7 @@ function generateTokenJs(ctx) {
|
|
|
1103
1212
|
|
|
1104
1213
|
token.var = tokenVar
|
|
1105
1214
|
`,
|
|
1106
|
-
dts:
|
|
1215
|
+
dts: import_outdent13.default`
|
|
1107
1216
|
import type { Token } from './tokens'
|
|
1108
1217
|
|
|
1109
1218
|
export declare const token: {
|
|
@@ -1117,43 +1226,43 @@ function generateTokenJs(ctx) {
|
|
|
1117
1226
|
}
|
|
1118
1227
|
|
|
1119
1228
|
// src/artifacts/preact-jsx/jsx.ts
|
|
1120
|
-
var
|
|
1229
|
+
var import_outdent14 = require("outdent");
|
|
1121
1230
|
function generatePreactJsxFactory(ctx) {
|
|
1122
1231
|
const { factoryName, componentName } = ctx.jsx;
|
|
1123
1232
|
return {
|
|
1124
|
-
js:
|
|
1233
|
+
js: import_outdent14.outdent`
|
|
1125
1234
|
import { h } from 'preact'
|
|
1126
1235
|
import { forwardRef } from 'preact/compat'
|
|
1127
1236
|
import { useMemo } from 'preact/hooks'
|
|
1128
1237
|
${ctx.file.import("css, cx, assignCss", "../css/index")}
|
|
1129
1238
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1130
1239
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1131
|
-
|
|
1240
|
+
|
|
1132
1241
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1133
1242
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1134
|
-
|
|
1135
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1243
|
+
|
|
1244
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1136
1245
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1137
1246
|
|
|
1138
1247
|
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1139
1248
|
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1140
1249
|
}, [restProps])
|
|
1141
|
-
|
|
1250
|
+
|
|
1142
1251
|
function recipeClass() {
|
|
1143
1252
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1144
1253
|
const styles = assignCss(propStyles, cssStyles)
|
|
1145
1254
|
return cx(cvaFn(variantProps), css(styles), elementProps.className, elementProps.class)
|
|
1146
1255
|
}
|
|
1147
|
-
|
|
1256
|
+
|
|
1148
1257
|
function cvaClass() {
|
|
1149
1258
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1150
1259
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1151
1260
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1152
1261
|
return cx(css(styles), elementProps.className, elementProps.class)
|
|
1153
1262
|
}
|
|
1154
|
-
|
|
1263
|
+
|
|
1155
1264
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1156
|
-
|
|
1265
|
+
|
|
1157
1266
|
return h(Element, {
|
|
1158
1267
|
...elementProps,
|
|
1159
1268
|
...normalizeHTMLProps(htmlProps),
|
|
@@ -1161,14 +1270,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1161
1270
|
className: classes()
|
|
1162
1271
|
})
|
|
1163
1272
|
})
|
|
1164
|
-
|
|
1273
|
+
|
|
1165
1274
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1166
1275
|
return ${componentName}
|
|
1167
1276
|
}
|
|
1168
|
-
|
|
1277
|
+
|
|
1169
1278
|
function createJsxFactory() {
|
|
1170
1279
|
const cache = new Map()
|
|
1171
|
-
|
|
1280
|
+
|
|
1172
1281
|
return new Proxy(styledFn, {
|
|
1173
1282
|
apply(_, __, args) {
|
|
1174
1283
|
return styledFn(...args)
|
|
@@ -1182,14 +1291,14 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1182
1291
|
})
|
|
1183
1292
|
}
|
|
1184
1293
|
|
|
1185
|
-
export const ${factoryName} = createJsxFactory()
|
|
1294
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1186
1295
|
`
|
|
1187
1296
|
};
|
|
1188
1297
|
}
|
|
1189
1298
|
|
|
1190
1299
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1191
|
-
var
|
|
1192
|
-
var
|
|
1300
|
+
var import_outdent15 = require("outdent");
|
|
1301
|
+
var import_ts_pattern4 = require("ts-pattern");
|
|
1193
1302
|
function generatePreactJsxPattern(ctx) {
|
|
1194
1303
|
const { typeName, factoryName } = ctx.jsx;
|
|
1195
1304
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1197,35 +1306,35 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1197
1306
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1198
1307
|
return {
|
|
1199
1308
|
name: dashName,
|
|
1200
|
-
js:
|
|
1309
|
+
js: import_outdent15.outdent`
|
|
1201
1310
|
import { h } from 'preact'
|
|
1202
1311
|
import { forwardRef } from 'preact/compat'
|
|
1203
1312
|
${ctx.file.import(factoryName, "./factory")}
|
|
1204
1313
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1205
|
-
|
|
1206
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1207
|
-
${(0,
|
|
1314
|
+
|
|
1315
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1316
|
+
${(0, import_ts_pattern4.match)(props.length).with(
|
|
1208
1317
|
0,
|
|
1209
|
-
() =>
|
|
1318
|
+
() => import_outdent15.outdent`
|
|
1210
1319
|
const styleProps = ${styleFnName}()
|
|
1211
1320
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1212
1321
|
`
|
|
1213
1322
|
).otherwise(
|
|
1214
|
-
() =>
|
|
1323
|
+
() => import_outdent15.outdent`
|
|
1215
1324
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1216
1325
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1217
1326
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1218
1327
|
`
|
|
1219
1328
|
)}
|
|
1220
|
-
})
|
|
1329
|
+
})
|
|
1221
1330
|
`,
|
|
1222
|
-
dts:
|
|
1331
|
+
dts: import_outdent15.outdent`
|
|
1223
1332
|
import type { FunctionComponent } from 'preact'
|
|
1224
1333
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1225
1334
|
import type { ${typeName} } from '../types/jsx'
|
|
1226
|
-
|
|
1335
|
+
|
|
1227
1336
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1228
|
-
|
|
1337
|
+
|
|
1229
1338
|
${description ? `/** ${description} */` : ""}
|
|
1230
1339
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1231
1340
|
`
|
|
@@ -1234,15 +1343,15 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1234
1343
|
}
|
|
1235
1344
|
|
|
1236
1345
|
// src/artifacts/preact-jsx/types.ts
|
|
1237
|
-
var
|
|
1346
|
+
var import_outdent16 = require("outdent");
|
|
1238
1347
|
function generatePreactJsxTypes(ctx) {
|
|
1239
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1348
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1240
1349
|
return {
|
|
1241
|
-
jsxFactory:
|
|
1350
|
+
jsxFactory: import_outdent16.outdent`
|
|
1242
1351
|
import type { ${upperName} } from '../types/jsx'
|
|
1243
1352
|
export declare const ${factoryName}: ${upperName}
|
|
1244
1353
|
`,
|
|
1245
|
-
jsxType:
|
|
1354
|
+
jsxType: import_outdent16.outdent`
|
|
1246
1355
|
import type { ComponentProps, JSX } from 'preact'
|
|
1247
1356
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1248
1357
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1259,7 +1368,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1259
1368
|
type RecipeFn = { __type: any }
|
|
1260
1369
|
|
|
1261
1370
|
interface JsxFactory {
|
|
1262
|
-
|
|
1371
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1263
1372
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1264
1373
|
T,
|
|
1265
1374
|
RecipeSelection<P>
|
|
@@ -1269,7 +1378,7 @@ interface JsxFactory {
|
|
|
1269
1378
|
|
|
1270
1379
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1271
1380
|
|
|
1272
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1381
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1273
1382
|
|
|
1274
1383
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1275
1384
|
`
|
|
@@ -1277,37 +1386,37 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1277
1386
|
}
|
|
1278
1387
|
|
|
1279
1388
|
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1280
|
-
var
|
|
1389
|
+
var import_outdent17 = require("outdent");
|
|
1281
1390
|
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1282
1391
|
const { factoryName, componentName } = ctx.jsx;
|
|
1283
1392
|
return {
|
|
1284
|
-
js:
|
|
1393
|
+
js: import_outdent17.outdent`
|
|
1285
1394
|
import { h } from 'preact'
|
|
1286
1395
|
import { forwardRef } from 'preact/compat'
|
|
1287
1396
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1288
|
-
|
|
1397
|
+
|
|
1289
1398
|
function createStyledFn(Dynamic) {
|
|
1290
1399
|
return function styledFn(template) {
|
|
1291
1400
|
const baseClassName = css(template)
|
|
1292
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1401
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1293
1402
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1294
1403
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1295
|
-
|
|
1404
|
+
|
|
1296
1405
|
return h(Element, {
|
|
1297
1406
|
ref,
|
|
1298
1407
|
...elementProps,
|
|
1299
1408
|
className: classes(),
|
|
1300
1409
|
})
|
|
1301
1410
|
})
|
|
1302
|
-
|
|
1411
|
+
|
|
1303
1412
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1304
1413
|
return ${componentName}
|
|
1305
1414
|
}
|
|
1306
1415
|
}
|
|
1307
|
-
|
|
1416
|
+
|
|
1308
1417
|
function createJsxFactory() {
|
|
1309
1418
|
const cache = new Map()
|
|
1310
|
-
|
|
1419
|
+
|
|
1311
1420
|
return new Proxy(createStyledFn, {
|
|
1312
1421
|
apply(_, __, args) {
|
|
1313
1422
|
return createStyledFn(...args)
|
|
@@ -1321,21 +1430,21 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1321
1430
|
})
|
|
1322
1431
|
}
|
|
1323
1432
|
|
|
1324
|
-
export const ${factoryName} = createJsxFactory()
|
|
1433
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1325
1434
|
`
|
|
1326
1435
|
};
|
|
1327
1436
|
}
|
|
1328
1437
|
|
|
1329
1438
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1330
|
-
var
|
|
1439
|
+
var import_outdent18 = require("outdent");
|
|
1331
1440
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1332
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1441
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1333
1442
|
return {
|
|
1334
|
-
jsxFactory:
|
|
1443
|
+
jsxFactory: import_outdent18.outdent`
|
|
1335
1444
|
import type { ${upperName} } from '../types/jsx'
|
|
1336
1445
|
export declare const ${factoryName}: ${upperName}
|
|
1337
1446
|
`,
|
|
1338
|
-
jsxType:
|
|
1447
|
+
jsxType: import_outdent18.outdent`
|
|
1339
1448
|
import type { ComponentProps, JSX } from 'preact'
|
|
1340
1449
|
|
|
1341
1450
|
type ElementType = keyof JSX.IntrinsicElements
|
|
@@ -1353,7 +1462,7 @@ interface JsxFactory {
|
|
|
1353
1462
|
|
|
1354
1463
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1355
1464
|
|
|
1356
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1465
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1357
1466
|
|
|
1358
1467
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1359
1468
|
`
|
|
@@ -1361,54 +1470,54 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1361
1470
|
}
|
|
1362
1471
|
|
|
1363
1472
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1364
|
-
var
|
|
1473
|
+
var import_outdent19 = require("outdent");
|
|
1365
1474
|
function generateQwikJsxFactory(ctx) {
|
|
1366
1475
|
const { factoryName, componentName } = ctx.jsx;
|
|
1367
1476
|
return {
|
|
1368
|
-
js:
|
|
1477
|
+
js: import_outdent19.outdent`
|
|
1369
1478
|
import { h } from '@builder.io/qwik'
|
|
1370
1479
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1371
1480
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1372
1481
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1373
|
-
|
|
1482
|
+
|
|
1374
1483
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1375
1484
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1376
|
-
|
|
1485
|
+
|
|
1377
1486
|
const ${componentName} = function ${componentName}(props) {
|
|
1378
1487
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1379
|
-
|
|
1380
|
-
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1488
|
+
|
|
1489
|
+
const [variantProps, styleProps, htmlProps, elementProps] =
|
|
1381
1490
|
splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1382
|
-
|
|
1491
|
+
|
|
1383
1492
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1384
|
-
|
|
1493
|
+
|
|
1385
1494
|
function recipeClass() {
|
|
1386
1495
|
const styles = assignCss(propStyles, cssStyles)
|
|
1387
1496
|
return cx(cvaFn(variantProps), css(styles), elementProps.class)
|
|
1388
1497
|
}
|
|
1389
|
-
|
|
1498
|
+
|
|
1390
1499
|
function cvaClass() {
|
|
1391
1500
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1392
1501
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1393
1502
|
return cx(css(styles), elementProps.class)
|
|
1394
1503
|
}
|
|
1395
|
-
|
|
1504
|
+
|
|
1396
1505
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1397
|
-
|
|
1506
|
+
|
|
1398
1507
|
return h(Element, {
|
|
1399
1508
|
...elementProps,
|
|
1400
1509
|
...normalizeHTMLProps(htmlProps),
|
|
1401
1510
|
class: classes(),
|
|
1402
1511
|
})
|
|
1403
1512
|
}
|
|
1404
|
-
|
|
1513
|
+
|
|
1405
1514
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1406
1515
|
return ${componentName}
|
|
1407
1516
|
}
|
|
1408
|
-
|
|
1517
|
+
|
|
1409
1518
|
function createJsxFactory() {
|
|
1410
1519
|
const cache = new Map()
|
|
1411
|
-
|
|
1520
|
+
|
|
1412
1521
|
return new Proxy(styledFn, {
|
|
1413
1522
|
apply(_, __, args) {
|
|
1414
1523
|
return styledFn(...args)
|
|
@@ -1422,15 +1531,15 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1422
1531
|
})
|
|
1423
1532
|
}
|
|
1424
1533
|
|
|
1425
|
-
export const ${factoryName} = createJsxFactory()
|
|
1534
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1426
1535
|
|
|
1427
1536
|
`
|
|
1428
1537
|
};
|
|
1429
1538
|
}
|
|
1430
1539
|
|
|
1431
1540
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1432
|
-
var
|
|
1433
|
-
var
|
|
1541
|
+
var import_outdent20 = require("outdent");
|
|
1542
|
+
var import_ts_pattern5 = require("ts-pattern");
|
|
1434
1543
|
function generateQwikJsxPattern(ctx) {
|
|
1435
1544
|
const { typeName, factoryName } = ctx.jsx;
|
|
1436
1545
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1438,20 +1547,20 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1438
1547
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1439
1548
|
return {
|
|
1440
1549
|
name: dashName,
|
|
1441
|
-
js:
|
|
1550
|
+
js: import_outdent20.outdent`
|
|
1442
1551
|
import { h } from '@builder.io/qwik'
|
|
1443
1552
|
${ctx.file.import(factoryName, "./factory")}
|
|
1444
1553
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1445
1554
|
|
|
1446
1555
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1447
|
-
${(0,
|
|
1556
|
+
${(0, import_ts_pattern5.match)(props.length).with(
|
|
1448
1557
|
0,
|
|
1449
|
-
() =>
|
|
1558
|
+
() => import_outdent20.outdent`
|
|
1450
1559
|
const styleProps = ${styleFnName}()
|
|
1451
1560
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1452
1561
|
`
|
|
1453
1562
|
).otherwise(
|
|
1454
|
-
() =>
|
|
1563
|
+
() => import_outdent20.outdent`
|
|
1455
1564
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1456
1565
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1457
1566
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1459,7 +1568,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1459
1568
|
)}
|
|
1460
1569
|
}
|
|
1461
1570
|
`,
|
|
1462
|
-
dts:
|
|
1571
|
+
dts: import_outdent20.outdent`
|
|
1463
1572
|
import type { FunctionComponent } from '@builder.io/qwik'
|
|
1464
1573
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1465
1574
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1478,15 +1587,15 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1478
1587
|
}
|
|
1479
1588
|
|
|
1480
1589
|
// src/artifacts/qwik-jsx/types.ts
|
|
1481
|
-
var
|
|
1590
|
+
var import_outdent21 = require("outdent");
|
|
1482
1591
|
function generateQwikJsxTypes(ctx) {
|
|
1483
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1592
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1484
1593
|
return {
|
|
1485
|
-
jsxFactory:
|
|
1594
|
+
jsxFactory: import_outdent21.outdent`
|
|
1486
1595
|
import { ${upperName} } from '../types/jsx'
|
|
1487
1596
|
export declare const ${factoryName}: ${upperName}
|
|
1488
1597
|
`,
|
|
1489
|
-
jsxType:
|
|
1598
|
+
jsxType: import_outdent21.outdent`
|
|
1490
1599
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1491
1600
|
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1492
1601
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1522,7 +1631,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = Funct
|
|
|
1522
1631
|
type RecipeFn = { __type: any }
|
|
1523
1632
|
|
|
1524
1633
|
interface JsxFactory {
|
|
1525
|
-
|
|
1634
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1526
1635
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1527
1636
|
T,
|
|
1528
1637
|
RecipeSelection<P>
|
|
@@ -1532,7 +1641,7 @@ interface JsxFactory {
|
|
|
1532
1641
|
|
|
1533
1642
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}> }
|
|
1534
1643
|
|
|
1535
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1644
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1536
1645
|
|
|
1537
1646
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1538
1647
|
`
|
|
@@ -1540,35 +1649,35 @@ export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxSt
|
|
|
1540
1649
|
}
|
|
1541
1650
|
|
|
1542
1651
|
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1543
|
-
var
|
|
1652
|
+
var import_outdent22 = require("outdent");
|
|
1544
1653
|
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1545
1654
|
const { factoryName, componentName } = ctx.jsx;
|
|
1546
1655
|
return {
|
|
1547
|
-
js:
|
|
1656
|
+
js: import_outdent22.outdent`
|
|
1548
1657
|
import { h } from '@builder.io/qwik'
|
|
1549
1658
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1550
|
-
|
|
1659
|
+
|
|
1551
1660
|
function createStyledFn(Dynamic) {
|
|
1552
1661
|
return function styledFn(template) {
|
|
1553
1662
|
const baseClassName = css(template)
|
|
1554
1663
|
const ${componentName} = function ${componentName}(props) {
|
|
1555
1664
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1556
1665
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1557
|
-
|
|
1666
|
+
|
|
1558
1667
|
return h(Element, {
|
|
1559
1668
|
...elementProps,
|
|
1560
1669
|
className: classes(),
|
|
1561
1670
|
})
|
|
1562
1671
|
}
|
|
1563
|
-
|
|
1672
|
+
|
|
1564
1673
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1565
1674
|
return ${componentName}
|
|
1566
1675
|
}
|
|
1567
1676
|
}
|
|
1568
|
-
|
|
1677
|
+
|
|
1569
1678
|
function createJsxFactory() {
|
|
1570
1679
|
const cache = new Map()
|
|
1571
|
-
|
|
1680
|
+
|
|
1572
1681
|
return new Proxy(createStyledFn, {
|
|
1573
1682
|
apply(_, __, args) {
|
|
1574
1683
|
return createStyledFn(...args)
|
|
@@ -1582,22 +1691,22 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1582
1691
|
})
|
|
1583
1692
|
}
|
|
1584
1693
|
|
|
1585
|
-
export const ${factoryName} = createJsxFactory()
|
|
1694
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1586
1695
|
|
|
1587
1696
|
`
|
|
1588
1697
|
};
|
|
1589
1698
|
}
|
|
1590
1699
|
|
|
1591
1700
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1592
|
-
var
|
|
1701
|
+
var import_outdent23 = require("outdent");
|
|
1593
1702
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1594
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1703
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1595
1704
|
return {
|
|
1596
|
-
jsxFactory:
|
|
1705
|
+
jsxFactory: import_outdent23.outdent`
|
|
1597
1706
|
import { ${upperName} } from '../types/jsx'
|
|
1598
1707
|
export declare const ${factoryName}: ${upperName}
|
|
1599
1708
|
`,
|
|
1600
|
-
jsxType:
|
|
1709
|
+
jsxType: import_outdent23.outdent`
|
|
1601
1710
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1602
1711
|
|
|
1603
1712
|
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
@@ -1620,7 +1729,7 @@ interface JsxFactory {
|
|
|
1620
1729
|
|
|
1621
1730
|
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1622
1731
|
|
|
1623
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1732
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1624
1733
|
|
|
1625
1734
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1626
1735
|
`
|
|
@@ -1628,41 +1737,76 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1628
1737
|
}
|
|
1629
1738
|
|
|
1630
1739
|
// src/artifacts/react-jsx/jsx.ts
|
|
1631
|
-
var
|
|
1740
|
+
var import_outdent24 = require("outdent");
|
|
1741
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
1632
1742
|
function generateReactJsxFactory(ctx) {
|
|
1633
1743
|
const { factoryName, componentName } = ctx.jsx;
|
|
1634
1744
|
return {
|
|
1635
|
-
js:
|
|
1745
|
+
js: import_outdent24.outdent`
|
|
1636
1746
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1637
1747
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1638
1748
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1639
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1640
|
-
|
|
1749
|
+
${ctx.jsx.styleProps === "all" ? ctx.file.import("isCssProperty", "./is-valid-prop") : ""}
|
|
1750
|
+
|
|
1641
1751
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
1642
1752
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1643
|
-
|
|
1644
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1753
|
+
|
|
1754
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1645
1755
|
const { as: Element = Dynamic, ...restProps } = props
|
|
1646
|
-
|
|
1647
|
-
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1648
|
-
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1649
|
-
}, [restProps])
|
|
1650
1756
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1757
|
+
${(0, import_ts_pattern6.match)(ctx.jsx.styleProps).with("all", () => {
|
|
1758
|
+
return import_outdent24.outdent`
|
|
1759
|
+
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1760
|
+
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1761
|
+
}, [restProps])
|
|
1762
|
+
|
|
1763
|
+
function recipeClass() {
|
|
1764
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1765
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1766
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
function cvaClass() {
|
|
1770
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1771
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1772
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1773
|
+
return cx(css(styles), elementProps.className)
|
|
1774
|
+
}`;
|
|
1775
|
+
}).with("minimal", () => {
|
|
1776
|
+
return import_outdent24.outdent`
|
|
1777
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1778
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1779
|
+
}, [restProps])
|
|
1780
|
+
|
|
1781
|
+
function recipeClass() {
|
|
1782
|
+
return cx(cvaFn(variantProps), css(assignCss(elementProps.css)), elementProps.className)
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
function cvaClass() {
|
|
1786
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1787
|
+
const styles = assignCss(cvaStyles, elementProps.css)
|
|
1788
|
+
return cx(css(styles), elementProps.className)
|
|
1789
|
+
}`;
|
|
1790
|
+
}).with("none", () => {
|
|
1791
|
+
return import_outdent24.outdent`
|
|
1792
|
+
const [variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
1793
|
+
return splitProps(restProps, cvaFn.variantKeys, normalizeHTMLProps.keys)
|
|
1794
|
+
}, [restProps])
|
|
1795
|
+
|
|
1796
|
+
function recipeClass() {
|
|
1797
|
+
return cx(cvaFn(variantProps), elementProps.className)
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
function cvaClass() {
|
|
1801
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1802
|
+
const styles = assignCss(cvaStyles)
|
|
1803
|
+
return cx(css(styles), elementProps.className)
|
|
1804
|
+
}`;
|
|
1805
|
+
}).run()}
|
|
1806
|
+
|
|
1807
|
+
|
|
1664
1808
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1665
|
-
|
|
1809
|
+
|
|
1666
1810
|
return createElement(Element, {
|
|
1667
1811
|
ref,
|
|
1668
1812
|
...elementProps,
|
|
@@ -1670,14 +1814,14 @@ function generateReactJsxFactory(ctx) {
|
|
|
1670
1814
|
className: classes(),
|
|
1671
1815
|
})
|
|
1672
1816
|
})
|
|
1673
|
-
|
|
1817
|
+
|
|
1674
1818
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1675
1819
|
return ${componentName}
|
|
1676
1820
|
}
|
|
1677
|
-
|
|
1821
|
+
|
|
1678
1822
|
function createJsxFactory() {
|
|
1679
1823
|
const cache = new Map()
|
|
1680
|
-
|
|
1824
|
+
|
|
1681
1825
|
return new Proxy(styledFn, {
|
|
1682
1826
|
apply(_, __, args) {
|
|
1683
1827
|
return styledFn(...args)
|
|
@@ -1691,15 +1835,15 @@ function generateReactJsxFactory(ctx) {
|
|
|
1691
1835
|
})
|
|
1692
1836
|
}
|
|
1693
1837
|
|
|
1694
|
-
export const ${factoryName} = createJsxFactory()
|
|
1838
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1695
1839
|
|
|
1696
1840
|
`
|
|
1697
1841
|
};
|
|
1698
1842
|
}
|
|
1699
1843
|
|
|
1700
1844
|
// src/artifacts/react-jsx/pattern.ts
|
|
1701
|
-
var
|
|
1702
|
-
var
|
|
1845
|
+
var import_outdent25 = require("outdent");
|
|
1846
|
+
var import_ts_pattern7 = require("ts-pattern");
|
|
1703
1847
|
function generateReactJsxPattern(ctx) {
|
|
1704
1848
|
const { typeName, factoryName } = ctx.jsx;
|
|
1705
1849
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1707,34 +1851,34 @@ function generateReactJsxPattern(ctx) {
|
|
|
1707
1851
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1708
1852
|
return {
|
|
1709
1853
|
name: dashName,
|
|
1710
|
-
js:
|
|
1854
|
+
js: import_outdent25.outdent`
|
|
1711
1855
|
import { createElement, forwardRef } from 'react'
|
|
1712
1856
|
${ctx.file.import(factoryName, "./factory")}
|
|
1713
1857
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1714
|
-
|
|
1715
|
-
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1716
|
-
${(0,
|
|
1858
|
+
|
|
1859
|
+
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1860
|
+
${(0, import_ts_pattern7.match)(props.length).with(
|
|
1717
1861
|
0,
|
|
1718
|
-
() =>
|
|
1862
|
+
() => import_outdent25.outdent`
|
|
1719
1863
|
const styleProps = ${styleFnName}()
|
|
1720
1864
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1721
1865
|
`
|
|
1722
1866
|
).otherwise(
|
|
1723
|
-
() =>
|
|
1867
|
+
() => import_outdent25.outdent`
|
|
1724
1868
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1725
1869
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1726
1870
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
1727
1871
|
`
|
|
1728
1872
|
)}
|
|
1729
|
-
})
|
|
1873
|
+
})
|
|
1730
1874
|
`,
|
|
1731
|
-
dts:
|
|
1875
|
+
dts: import_outdent25.outdent`
|
|
1732
1876
|
import type { FunctionComponent } from 'react'
|
|
1733
1877
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1734
1878
|
import type { ${typeName} } from '../types/jsx'
|
|
1735
|
-
|
|
1879
|
+
|
|
1736
1880
|
export type ${upperName}Props = ${upperName}Properties & Omit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}>
|
|
1737
|
-
|
|
1881
|
+
|
|
1738
1882
|
${description ? `/** ${description} */` : ""}
|
|
1739
1883
|
export declare const ${jsxName}: FunctionComponent<${upperName}Props>
|
|
1740
1884
|
`
|
|
@@ -1743,15 +1887,15 @@ function generateReactJsxPattern(ctx) {
|
|
|
1743
1887
|
}
|
|
1744
1888
|
|
|
1745
1889
|
// src/artifacts/react-jsx/types.ts
|
|
1746
|
-
var
|
|
1890
|
+
var import_outdent26 = require("outdent");
|
|
1747
1891
|
function generateReactJsxTypes(ctx) {
|
|
1748
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1892
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1749
1893
|
return {
|
|
1750
|
-
jsxFactory:
|
|
1894
|
+
jsxFactory: import_outdent26.outdent`
|
|
1751
1895
|
import { ${upperName} } from '../types/jsx'
|
|
1752
1896
|
export declare const ${factoryName}: ${upperName}
|
|
1753
1897
|
`,
|
|
1754
|
-
jsxType:
|
|
1898
|
+
jsxType: import_outdent26.outdent`
|
|
1755
1899
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1756
1900
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1757
1901
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1770,7 +1914,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
1770
1914
|
type RecipeFn = { __type: any }
|
|
1771
1915
|
|
|
1772
1916
|
interface JsxFactory {
|
|
1773
|
-
|
|
1917
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
1774
1918
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
1775
1919
|
T,
|
|
1776
1920
|
RecipeSelection<P>
|
|
@@ -1780,7 +1924,7 @@ interface JsxFactory {
|
|
|
1780
1924
|
|
|
1781
1925
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1782
1926
|
|
|
1783
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
1927
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1784
1928
|
|
|
1785
1929
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1786
1930
|
`
|
|
@@ -1788,36 +1932,36 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1788
1932
|
}
|
|
1789
1933
|
|
|
1790
1934
|
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
1791
|
-
var
|
|
1935
|
+
var import_outdent27 = require("outdent");
|
|
1792
1936
|
function generateReactJsxStringLiteralFactory(ctx) {
|
|
1793
1937
|
const { factoryName, componentName } = ctx.jsx;
|
|
1794
1938
|
return {
|
|
1795
|
-
js:
|
|
1939
|
+
js: import_outdent27.outdent`
|
|
1796
1940
|
import { createElement, forwardRef } from 'react'
|
|
1797
1941
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1798
|
-
|
|
1942
|
+
|
|
1799
1943
|
function createStyledFn(Dynamic) {
|
|
1800
1944
|
return function styledFn(template) {
|
|
1801
1945
|
const baseClassName = css(template)
|
|
1802
|
-
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1946
|
+
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1803
1947
|
const { as: Element = Dynamic, ...elementProps } = props
|
|
1804
1948
|
const classes = () => cx(baseClassName, elementProps.className)
|
|
1805
|
-
|
|
1949
|
+
|
|
1806
1950
|
return createElement(Element, {
|
|
1807
1951
|
ref,
|
|
1808
1952
|
...elementProps,
|
|
1809
1953
|
className: classes(),
|
|
1810
1954
|
})
|
|
1811
1955
|
})
|
|
1812
|
-
|
|
1956
|
+
|
|
1813
1957
|
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1814
1958
|
return ${componentName}
|
|
1815
1959
|
}
|
|
1816
1960
|
}
|
|
1817
|
-
|
|
1961
|
+
|
|
1818
1962
|
function createJsxFactory() {
|
|
1819
1963
|
const cache = new Map()
|
|
1820
|
-
|
|
1964
|
+
|
|
1821
1965
|
return new Proxy(createStyledFn, {
|
|
1822
1966
|
apply(_, __, args) {
|
|
1823
1967
|
return createStyledFn(...args)
|
|
@@ -1831,22 +1975,22 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
1831
1975
|
})
|
|
1832
1976
|
}
|
|
1833
1977
|
|
|
1834
|
-
export const ${factoryName} = createJsxFactory()
|
|
1978
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1835
1979
|
|
|
1836
1980
|
`
|
|
1837
1981
|
};
|
|
1838
1982
|
}
|
|
1839
1983
|
|
|
1840
1984
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
1841
|
-
var
|
|
1985
|
+
var import_outdent28 = require("outdent");
|
|
1842
1986
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
1843
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1987
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
1844
1988
|
return {
|
|
1845
|
-
jsxFactory:
|
|
1989
|
+
jsxFactory: import_outdent28.outdent`
|
|
1846
1990
|
import { ${upperName} } from '../types/jsx'
|
|
1847
1991
|
export declare const ${factoryName}: ${upperName}
|
|
1848
1992
|
`,
|
|
1849
|
-
jsxType:
|
|
1993
|
+
jsxType: import_outdent28.outdent`
|
|
1850
1994
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1851
1995
|
|
|
1852
1996
|
type Dict = Record<string, unknown>
|
|
@@ -1866,7 +2010,7 @@ interface JsxFactory {
|
|
|
1866
2010
|
|
|
1867
2011
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1868
2012
|
|
|
1869
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2013
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
1870
2014
|
|
|
1871
2015
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1872
2016
|
`
|
|
@@ -1874,24 +2018,24 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1874
2018
|
}
|
|
1875
2019
|
|
|
1876
2020
|
// src/artifacts/solid-jsx/jsx.ts
|
|
1877
|
-
var
|
|
2021
|
+
var import_outdent29 = require("outdent");
|
|
1878
2022
|
function generateSolidJsxFactory(ctx) {
|
|
1879
2023
|
const { componentName, factoryName } = ctx.jsx;
|
|
1880
2024
|
return {
|
|
1881
|
-
js:
|
|
2025
|
+
js: import_outdent29.outdent`
|
|
1882
2026
|
import { Dynamic } from 'solid-js/web'
|
|
1883
2027
|
import { mergeProps, splitProps } from 'solid-js'
|
|
1884
2028
|
import { createComponent } from 'solid-js/web'
|
|
1885
2029
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1886
2030
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
1887
2031
|
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
1888
|
-
|
|
2032
|
+
|
|
1889
2033
|
function styledFn(element, configOrCva = {}) {
|
|
1890
2034
|
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1891
|
-
|
|
2035
|
+
|
|
1892
2036
|
return function ${componentName}(props) {
|
|
1893
2037
|
const mergedProps = mergeProps({ as: element }, props)
|
|
1894
|
-
|
|
2038
|
+
|
|
1895
2039
|
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
1896
2040
|
mergedProps,
|
|
1897
2041
|
['as', 'class'],
|
|
@@ -1905,16 +2049,16 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1905
2049
|
const styles = assignCss(propStyles, cssStyles)
|
|
1906
2050
|
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1907
2051
|
}
|
|
1908
|
-
|
|
2052
|
+
|
|
1909
2053
|
function cvaClass() {
|
|
1910
2054
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1911
2055
|
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1912
2056
|
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1913
2057
|
return cx(css(styles), localProps.class)
|
|
1914
2058
|
}
|
|
1915
|
-
|
|
2059
|
+
|
|
1916
2060
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1917
|
-
|
|
2061
|
+
|
|
1918
2062
|
return createComponent(
|
|
1919
2063
|
Dynamic,
|
|
1920
2064
|
mergeProps(
|
|
@@ -1932,10 +2076,10 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1932
2076
|
)
|
|
1933
2077
|
}
|
|
1934
2078
|
}
|
|
1935
|
-
|
|
2079
|
+
|
|
1936
2080
|
function createJsxFactory() {
|
|
1937
2081
|
const cache = new Map()
|
|
1938
|
-
|
|
2082
|
+
|
|
1939
2083
|
return new Proxy(styledFn, {
|
|
1940
2084
|
apply(_, __, args) {
|
|
1941
2085
|
return styledFn(...args)
|
|
@@ -1948,15 +2092,15 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1948
2092
|
},
|
|
1949
2093
|
})
|
|
1950
2094
|
}
|
|
1951
|
-
|
|
1952
|
-
export const ${factoryName} = createJsxFactory()
|
|
2095
|
+
|
|
2096
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
1953
2097
|
`
|
|
1954
2098
|
};
|
|
1955
2099
|
}
|
|
1956
2100
|
|
|
1957
2101
|
// src/artifacts/solid-jsx/pattern.ts
|
|
1958
|
-
var
|
|
1959
|
-
var
|
|
2102
|
+
var import_outdent30 = require("outdent");
|
|
2103
|
+
var import_ts_pattern8 = require("ts-pattern");
|
|
1960
2104
|
function generateSolidJsxPattern(ctx) {
|
|
1961
2105
|
const { typeName, factoryName } = ctx.jsx;
|
|
1962
2106
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1964,21 +2108,21 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1964
2108
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1965
2109
|
return {
|
|
1966
2110
|
name: dashName,
|
|
1967
|
-
js:
|
|
2111
|
+
js: import_outdent30.outdent`
|
|
1968
2112
|
import { splitProps, mergeProps } from 'solid-js'
|
|
1969
2113
|
import { createComponent } from 'solid-js/web'
|
|
1970
2114
|
${ctx.file.import(factoryName, "./factory")}
|
|
1971
2115
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1972
2116
|
|
|
1973
2117
|
export function ${jsxName}(props) {
|
|
1974
|
-
${(0,
|
|
2118
|
+
${(0, import_ts_pattern8.match)(props.length).with(
|
|
1975
2119
|
0,
|
|
1976
|
-
() =>
|
|
2120
|
+
() => import_outdent30.outdent`
|
|
1977
2121
|
const styleProps = ${styleFnName}()
|
|
1978
2122
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
1979
2123
|
`
|
|
1980
2124
|
).otherwise(
|
|
1981
|
-
() =>
|
|
2125
|
+
() => import_outdent30.outdent`
|
|
1982
2126
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
1983
2127
|
const styleProps = ${styleFnName}(patternProps)
|
|
1984
2128
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -1986,7 +2130,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1986
2130
|
)}
|
|
1987
2131
|
}
|
|
1988
2132
|
`,
|
|
1989
|
-
dts:
|
|
2133
|
+
dts: import_outdent30.outdent`
|
|
1990
2134
|
import { Component } from 'solid-js'
|
|
1991
2135
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1992
2136
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -2001,15 +2145,15 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2001
2145
|
}
|
|
2002
2146
|
|
|
2003
2147
|
// src/artifacts/solid-jsx/types.ts
|
|
2004
|
-
var
|
|
2148
|
+
var import_outdent31 = require("outdent");
|
|
2005
2149
|
function generateSolidJsxTypes(ctx) {
|
|
2006
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2150
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2007
2151
|
return {
|
|
2008
|
-
jsxFactory:
|
|
2152
|
+
jsxFactory: import_outdent31.outdent`
|
|
2009
2153
|
import type { ${upperName} } from '../types/jsx'
|
|
2010
2154
|
export declare const ${factoryName}: ${upperName}
|
|
2011
2155
|
`,
|
|
2012
|
-
jsxType:
|
|
2156
|
+
jsxType: import_outdent31.outdent`
|
|
2013
2157
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
2014
2158
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
2015
2159
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -2026,7 +2170,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
2026
2170
|
type RecipeFn = { __type: any }
|
|
2027
2171
|
|
|
2028
2172
|
interface JsxFactory {
|
|
2029
|
-
|
|
2173
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2030
2174
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2031
2175
|
T,
|
|
2032
2176
|
RecipeSelection<P>
|
|
@@ -2036,7 +2180,7 @@ interface JsxFactory {
|
|
|
2036
2180
|
|
|
2037
2181
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2038
2182
|
|
|
2039
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2183
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2040
2184
|
|
|
2041
2185
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2042
2186
|
`
|
|
@@ -2044,11 +2188,11 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
2044
2188
|
}
|
|
2045
2189
|
|
|
2046
2190
|
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
2047
|
-
var
|
|
2191
|
+
var import_outdent32 = require("outdent");
|
|
2048
2192
|
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
2049
2193
|
const { componentName, factoryName } = ctx.jsx;
|
|
2050
2194
|
return {
|
|
2051
|
-
js:
|
|
2195
|
+
js: import_outdent32.outdent`
|
|
2052
2196
|
import { mergeProps, splitProps } from 'solid-js'
|
|
2053
2197
|
import { Dynamic, createComponent } from 'solid-js/web'
|
|
2054
2198
|
${ctx.file.import("css, cx", "../css/index")}
|
|
@@ -2059,7 +2203,7 @@ function createStyled(element) {
|
|
|
2059
2203
|
return function ${componentName}(props) {
|
|
2060
2204
|
const mergedProps = mergeProps({ as: element }, props)
|
|
2061
2205
|
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2062
|
-
|
|
2206
|
+
|
|
2063
2207
|
return createComponent(
|
|
2064
2208
|
Dynamic,
|
|
2065
2209
|
mergeProps(
|
|
@@ -2094,21 +2238,21 @@ function createJsxFactory() {
|
|
|
2094
2238
|
})
|
|
2095
2239
|
}
|
|
2096
2240
|
|
|
2097
|
-
export const ${factoryName} = createJsxFactory()
|
|
2241
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2098
2242
|
`
|
|
2099
2243
|
};
|
|
2100
2244
|
}
|
|
2101
2245
|
|
|
2102
2246
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2103
|
-
var
|
|
2247
|
+
var import_outdent33 = require("outdent");
|
|
2104
2248
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2105
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2249
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2106
2250
|
return {
|
|
2107
|
-
jsxFactory:
|
|
2251
|
+
jsxFactory: import_outdent33.outdent`
|
|
2108
2252
|
import type { ${upperName} } from '../types/jsx'
|
|
2109
2253
|
export declare const ${factoryName}: ${upperName}
|
|
2110
2254
|
`,
|
|
2111
|
-
jsxType:
|
|
2255
|
+
jsxType: import_outdent33.outdent`
|
|
2112
2256
|
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2113
2257
|
|
|
2114
2258
|
type Dict = Record<string, unknown>
|
|
@@ -2126,7 +2270,7 @@ interface JsxFactory {
|
|
|
2126
2270
|
|
|
2127
2271
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2128
2272
|
|
|
2129
|
-
export type
|
|
2273
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2130
2274
|
|
|
2131
2275
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2132
2276
|
`
|
|
@@ -2134,16 +2278,16 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2134
2278
|
}
|
|
2135
2279
|
|
|
2136
2280
|
// src/artifacts/vue-jsx/jsx.ts
|
|
2137
|
-
var
|
|
2281
|
+
var import_outdent34 = require("outdent");
|
|
2138
2282
|
function generateVueJsxFactory(ctx) {
|
|
2139
2283
|
const { factoryName } = ctx.jsx;
|
|
2140
2284
|
return {
|
|
2141
|
-
js:
|
|
2285
|
+
js: import_outdent34.outdent`
|
|
2142
2286
|
import { defineComponent, h, computed } from 'vue'
|
|
2143
2287
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
2144
2288
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2145
2289
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2146
|
-
|
|
2290
|
+
|
|
2147
2291
|
function styledFn(Dynamic, configOrCva = {}) {
|
|
2148
2292
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2149
2293
|
|
|
@@ -2171,10 +2315,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2171
2315
|
})
|
|
2172
2316
|
|
|
2173
2317
|
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
2174
|
-
|
|
2318
|
+
|
|
2175
2319
|
return () => {
|
|
2176
2320
|
const [_styleProps, _variantProps, htmlProps, elementProps] = splittedProps.value
|
|
2177
|
-
|
|
2321
|
+
|
|
2178
2322
|
return h(
|
|
2179
2323
|
props.as,
|
|
2180
2324
|
{
|
|
@@ -2188,10 +2332,10 @@ function generateVueJsxFactory(ctx) {
|
|
|
2188
2332
|
},
|
|
2189
2333
|
})
|
|
2190
2334
|
}
|
|
2191
|
-
|
|
2335
|
+
|
|
2192
2336
|
function createJsxFactory() {
|
|
2193
2337
|
const cache = new Map()
|
|
2194
|
-
|
|
2338
|
+
|
|
2195
2339
|
return new Proxy(styledFn, {
|
|
2196
2340
|
apply(_, __, args) {
|
|
2197
2341
|
return styledFn(...args)
|
|
@@ -2205,21 +2349,21 @@ function generateVueJsxFactory(ctx) {
|
|
|
2205
2349
|
})
|
|
2206
2350
|
}
|
|
2207
2351
|
|
|
2208
|
-
export const ${factoryName} = createJsxFactory()
|
|
2352
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2209
2353
|
|
|
2210
2354
|
`
|
|
2211
2355
|
};
|
|
2212
2356
|
}
|
|
2213
2357
|
|
|
2214
2358
|
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2215
|
-
var
|
|
2359
|
+
var import_outdent35 = require("outdent");
|
|
2216
2360
|
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2217
2361
|
const { factoryName } = ctx.jsx;
|
|
2218
2362
|
return {
|
|
2219
|
-
js:
|
|
2363
|
+
js: import_outdent35.outdent`
|
|
2220
2364
|
import { defineComponent, h, computed } from 'vue'
|
|
2221
2365
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2222
|
-
|
|
2366
|
+
|
|
2223
2367
|
function createStyled(Dynamic) {
|
|
2224
2368
|
function styledFn(template) {
|
|
2225
2369
|
const baseClassName = css(template)
|
|
@@ -2243,10 +2387,10 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2243
2387
|
})
|
|
2244
2388
|
}
|
|
2245
2389
|
}
|
|
2246
|
-
|
|
2390
|
+
|
|
2247
2391
|
function createJsxFactory() {
|
|
2248
2392
|
const cache = new Map()
|
|
2249
|
-
|
|
2393
|
+
|
|
2250
2394
|
return new Proxy(createStyled, {
|
|
2251
2395
|
apply(_, __, args) {
|
|
2252
2396
|
return createStyled(...args)
|
|
@@ -2260,13 +2404,13 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2260
2404
|
})
|
|
2261
2405
|
}
|
|
2262
2406
|
|
|
2263
|
-
export const ${factoryName} = createJsxFactory()
|
|
2407
|
+
export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
2264
2408
|
`
|
|
2265
2409
|
};
|
|
2266
2410
|
}
|
|
2267
2411
|
|
|
2268
2412
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2269
|
-
var
|
|
2413
|
+
var import_outdent36 = require("outdent");
|
|
2270
2414
|
function generateVueJsxPattern(ctx) {
|
|
2271
2415
|
const { typeName, factoryName } = ctx.jsx;
|
|
2272
2416
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2275,7 +2419,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2275
2419
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2276
2420
|
return {
|
|
2277
2421
|
name: dashName,
|
|
2278
|
-
js:
|
|
2422
|
+
js: import_outdent36.outdent`
|
|
2279
2423
|
import { defineComponent, h, computed } from 'vue'
|
|
2280
2424
|
${ctx.file.import(factoryName, "./factory")}
|
|
2281
2425
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -2293,7 +2437,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2293
2437
|
}
|
|
2294
2438
|
})
|
|
2295
2439
|
`,
|
|
2296
|
-
dts:
|
|
2440
|
+
dts: import_outdent36.outdent`
|
|
2297
2441
|
import { FunctionalComponent } from 'vue'
|
|
2298
2442
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
2299
2443
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -2308,15 +2452,15 @@ function generateVueJsxPattern(ctx) {
|
|
|
2308
2452
|
}
|
|
2309
2453
|
|
|
2310
2454
|
// src/artifacts/vue-jsx/types.ts
|
|
2311
|
-
var
|
|
2455
|
+
var import_outdent37 = require("outdent");
|
|
2312
2456
|
function generateVueJsxTypes(ctx) {
|
|
2313
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2457
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2314
2458
|
return {
|
|
2315
|
-
jsxFactory:
|
|
2459
|
+
jsxFactory: import_outdent37.outdent`
|
|
2316
2460
|
import { ${upperName} } from '../types/jsx'
|
|
2317
2461
|
export declare const ${factoryName}: ${upperName}
|
|
2318
2462
|
`,
|
|
2319
|
-
jsxType:
|
|
2463
|
+
jsxType: import_outdent37.outdent`
|
|
2320
2464
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2321
2465
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
2322
2466
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -2455,33 +2599,33 @@ type IntrinsicElement =
|
|
|
2455
2599
|
type RecipeFn = { __type: any }
|
|
2456
2600
|
|
|
2457
2601
|
interface JsxFactory {
|
|
2458
|
-
|
|
2602
|
+
${styleProps === "none" ? "" : `<T extends ElementType>(component: T): ${componentName}<T, {}>`}
|
|
2459
2603
|
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>): ${componentName}<
|
|
2460
2604
|
T,
|
|
2461
2605
|
RecipeSelection<P>
|
|
2462
2606
|
>
|
|
2463
2607
|
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
2464
2608
|
}
|
|
2465
|
-
|
|
2609
|
+
|
|
2466
2610
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
2467
|
-
|
|
2468
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2469
|
-
|
|
2611
|
+
|
|
2612
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2613
|
+
|
|
2470
2614
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2471
2615
|
`
|
|
2472
2616
|
};
|
|
2473
2617
|
}
|
|
2474
2618
|
|
|
2475
2619
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2476
|
-
var
|
|
2620
|
+
var import_outdent38 = require("outdent");
|
|
2477
2621
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2478
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2622
|
+
const { factoryName, styleProps, componentName, upperName, typeName } = ctx.jsx;
|
|
2479
2623
|
return {
|
|
2480
|
-
jsxFactory:
|
|
2624
|
+
jsxFactory: import_outdent38.outdent`
|
|
2481
2625
|
import { ${upperName} } from '../types/jsx'
|
|
2482
2626
|
export declare const ${factoryName}: ${upperName}
|
|
2483
2627
|
`,
|
|
2484
|
-
jsxType:
|
|
2628
|
+
jsxType: import_outdent38.outdent`
|
|
2485
2629
|
import type { Component, FunctionalComponent } from 'vue'
|
|
2486
2630
|
|
|
2487
2631
|
type IntrinsicElement =
|
|
@@ -2617,11 +2761,11 @@ type IntrinsicElement =
|
|
|
2617
2761
|
interface JsxFactory {
|
|
2618
2762
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2619
2763
|
}
|
|
2620
|
-
|
|
2764
|
+
|
|
2621
2765
|
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2622
|
-
|
|
2623
|
-
export type ${upperName} = JsxFactory & JsxElements
|
|
2624
|
-
|
|
2766
|
+
|
|
2767
|
+
export type ${upperName} = JsxFactory ${styleProps === "none" ? "" : "& JsxElements"}
|
|
2768
|
+
|
|
2625
2769
|
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2626
2770
|
`
|
|
2627
2771
|
};
|
|
@@ -2636,8 +2780,8 @@ var typesMap = {
|
|
|
2636
2780
|
qwik: generateQwikJsxTypes
|
|
2637
2781
|
};
|
|
2638
2782
|
var typesStringLiteralMap = {
|
|
2639
|
-
react:
|
|
2640
|
-
solid:
|
|
2783
|
+
react: generateReactJsxStringLiteralTypes,
|
|
2784
|
+
solid: generateSolidJsxStringLiteralTypes,
|
|
2641
2785
|
qwik: generateQwikJsxStringLiteralTypes,
|
|
2642
2786
|
preact: generatePreactJsxStringLiteralTypes,
|
|
2643
2787
|
vue: generateVueJsxStringLiteralTypes
|
|
@@ -2735,7 +2879,7 @@ var csstype_d_ts_default = {
|
|
|
2735
2879
|
|
|
2736
2880
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2737
2881
|
var system_types_d_ts_default = {
|
|
2738
|
-
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 =
|
|
2882
|
+
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"
|
|
2739
2883
|
};
|
|
2740
2884
|
|
|
2741
2885
|
// src/artifacts/generated/composition.d.ts.json
|
|
@@ -2745,12 +2889,12 @@ var composition_d_ts_default = {
|
|
|
2745
2889
|
|
|
2746
2890
|
// src/artifacts/generated/recipe.d.ts.json
|
|
2747
2891
|
var recipe_d_ts_default = {
|
|
2748
|
-
content: "import type { SystemStyleObject } from './system-types'\n\ntype Pretty<T> =
|
|
2892
|
+
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"
|
|
2749
2893
|
};
|
|
2750
2894
|
|
|
2751
2895
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2752
2896
|
var pattern_d_ts_default = {
|
|
2753
|
-
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n
|
|
2897
|
+
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\nexport type PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
2754
2898
|
};
|
|
2755
2899
|
|
|
2756
2900
|
// src/artifacts/generated/parts.d.ts.json
|
|
@@ -2764,7 +2908,9 @@ var selectors_d_ts_default = {
|
|
|
2764
2908
|
};
|
|
2765
2909
|
|
|
2766
2910
|
// src/artifacts/types/generated.ts
|
|
2767
|
-
|
|
2911
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
2912
|
+
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2913
|
+
function getGeneratedTypes(ctx) {
|
|
2768
2914
|
return {
|
|
2769
2915
|
cssType: csstype_d_ts_default.content,
|
|
2770
2916
|
recipe: recipe_d_ts_default.content,
|
|
@@ -2772,15 +2918,15 @@ function getGeneratedTypes() {
|
|
|
2772
2918
|
parts: parts_d_ts_default.content,
|
|
2773
2919
|
composition: composition_d_ts_default.content,
|
|
2774
2920
|
selectors: selectors_d_ts_default.content,
|
|
2775
|
-
system: system_types_d_ts_default.content
|
|
2921
|
+
system: (0, import_ts_pattern9.match)(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()
|
|
2776
2922
|
};
|
|
2777
2923
|
}
|
|
2778
2924
|
|
|
2779
2925
|
// src/artifacts/types/main.ts
|
|
2780
|
-
var
|
|
2926
|
+
var import_outdent39 = require("outdent");
|
|
2781
2927
|
var generateTypesEntry = () => ({
|
|
2782
|
-
global:
|
|
2783
|
-
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2928
|
+
global: import_outdent39.outdent`
|
|
2929
|
+
import type { RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig } from './recipe'
|
|
2784
2930
|
import type { Parts } from './parts'
|
|
2785
2931
|
import type { PatternConfig, PatternProperties } from './pattern'
|
|
2786
2932
|
import type { GlobalStyleObject, SystemStyleObject } from './system-types'
|
|
@@ -2788,27 +2934,28 @@ var generateTypesEntry = () => ({
|
|
|
2788
2934
|
|
|
2789
2935
|
declare module '@pandacss/dev' {
|
|
2790
2936
|
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig
|
|
2937
|
+
export function defineSlotRecipe<S extends string, V extends SlotRecipeVariantRecord<S>>(config: SlotRecipeConfig<S, V>): SlotRecipeConfig
|
|
2791
2938
|
export function defineStyles(definition: SystemStyleObject): SystemStyleObject
|
|
2792
2939
|
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
2793
2940
|
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
2794
2941
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
2795
2942
|
export function definePattern<T extends PatternProperties>(config: PatternConfig<T>): PatternConfig
|
|
2796
|
-
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject
|
|
2943
|
+
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
2797
2944
|
}
|
|
2798
2945
|
`,
|
|
2799
|
-
index:
|
|
2946
|
+
index: import_outdent39.outdent`
|
|
2800
2947
|
import './global'
|
|
2801
2948
|
export type { ConditionalValue } from './conditions'
|
|
2802
2949
|
export type { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
2803
2950
|
|
|
2804
2951
|
`,
|
|
2805
|
-
helpers:
|
|
2952
|
+
helpers: import_outdent39.outdent`
|
|
2806
2953
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2807
2954
|
`
|
|
2808
2955
|
});
|
|
2809
2956
|
|
|
2810
2957
|
// src/artifacts/types/prop-types.ts
|
|
2811
|
-
var
|
|
2958
|
+
var import_outdent40 = require("outdent");
|
|
2812
2959
|
function generatePropTypes(ctx) {
|
|
2813
2960
|
const {
|
|
2814
2961
|
config: { strictTokens },
|
|
@@ -2816,7 +2963,7 @@ function generatePropTypes(ctx) {
|
|
|
2816
2963
|
} = ctx;
|
|
2817
2964
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2818
2965
|
const result = [
|
|
2819
|
-
|
|
2966
|
+
import_outdent40.outdent`
|
|
2820
2967
|
import type { ConditionalValue } from './conditions';
|
|
2821
2968
|
import type { CssProperties } from './system-types'
|
|
2822
2969
|
import type { Tokens } from '../tokens'
|
|
@@ -2839,7 +2986,7 @@ function generatePropTypes(ctx) {
|
|
|
2839
2986
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2840
2987
|
});
|
|
2841
2988
|
result.push("}");
|
|
2842
|
-
return
|
|
2989
|
+
return import_outdent40.outdent`
|
|
2843
2990
|
${result.join("\n")}
|
|
2844
2991
|
|
|
2845
2992
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2852,10 +2999,10 @@ function generatePropTypes(ctx) {
|
|
|
2852
2999
|
|
|
2853
3000
|
// src/artifacts/types/style-props.ts
|
|
2854
3001
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
2855
|
-
var
|
|
3002
|
+
var import_outdent41 = __toESM(require("outdent"));
|
|
2856
3003
|
function generateStyleProps(ctx) {
|
|
2857
|
-
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()));
|
|
2858
|
-
return
|
|
3004
|
+
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
3005
|
+
return import_outdent41.default`
|
|
2859
3006
|
import type { ConditionalValue } from './conditions'
|
|
2860
3007
|
import type { PropertyValue } from './prop-type'
|
|
2861
3008
|
import type { Token } from '../tokens'
|
|
@@ -2872,7 +3019,7 @@ function generateStyleProps(ctx) {
|
|
|
2872
3019
|
|
|
2873
3020
|
// src/artifacts/types/token-types.ts
|
|
2874
3021
|
var import_shared3 = require("@pandacss/shared");
|
|
2875
|
-
var
|
|
3022
|
+
var import_outdent42 = require("outdent");
|
|
2876
3023
|
var import_pluralize = __toESM(require("pluralize"));
|
|
2877
3024
|
var categories = [
|
|
2878
3025
|
"zIndex",
|
|
@@ -2917,12 +3064,12 @@ function generateTokenTypes(ctx) {
|
|
|
2917
3064
|
result.add("} & { [token: string]: never }");
|
|
2918
3065
|
set.add(Array.from(result).join("\n"));
|
|
2919
3066
|
set.add(`export type TokenCategory = ${(0, import_shared3.unionType)(categories)}`);
|
|
2920
|
-
return
|
|
3067
|
+
return import_outdent42.outdent.string(Array.from(set).join("\n\n"));
|
|
2921
3068
|
}
|
|
2922
3069
|
|
|
2923
3070
|
// src/artifacts/index.ts
|
|
2924
3071
|
function setupHelpers(ctx) {
|
|
2925
|
-
const code = generateHelpers();
|
|
3072
|
+
const code = generateHelpers(ctx);
|
|
2926
3073
|
return {
|
|
2927
3074
|
files: [{ file: ctx.file.ext("helpers"), code: code.js }]
|
|
2928
3075
|
};
|
|
@@ -2950,7 +3097,7 @@ function setupDesignTokens(ctx) {
|
|
|
2950
3097
|
};
|
|
2951
3098
|
}
|
|
2952
3099
|
function setupTypes(ctx) {
|
|
2953
|
-
const gen = getGeneratedTypes();
|
|
3100
|
+
const gen = getGeneratedTypes(ctx);
|
|
2954
3101
|
const conditions = generateConditions(ctx);
|
|
2955
3102
|
const jsx = generateJsxTypes(ctx);
|
|
2956
3103
|
const entry = generateTypesEntry();
|
|
@@ -2998,6 +3145,18 @@ function setupCva(ctx) {
|
|
|
2998
3145
|
]
|
|
2999
3146
|
};
|
|
3000
3147
|
}
|
|
3148
|
+
function setupSva(ctx) {
|
|
3149
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
3150
|
+
return;
|
|
3151
|
+
const code = generateSvaFn(ctx);
|
|
3152
|
+
return {
|
|
3153
|
+
dir: ctx.paths.css,
|
|
3154
|
+
files: [
|
|
3155
|
+
{ file: ctx.file.ext("sva"), code: code.js },
|
|
3156
|
+
{ file: "sva.d.ts", code: code.dts }
|
|
3157
|
+
]
|
|
3158
|
+
};
|
|
3159
|
+
}
|
|
3001
3160
|
function setupCx(ctx) {
|
|
3002
3161
|
const code = generateCx();
|
|
3003
3162
|
return {
|
|
@@ -3014,8 +3173,8 @@ function setupRecipes(ctx) {
|
|
|
3014
3173
|
return;
|
|
3015
3174
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
3016
3175
|
const index = {
|
|
3017
|
-
js:
|
|
3018
|
-
dts:
|
|
3176
|
+
js: import_outdent43.default.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3177
|
+
dts: import_outdent43.default.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
3019
3178
|
};
|
|
3020
3179
|
return {
|
|
3021
3180
|
dir: ctx.paths.recipe,
|
|
@@ -3034,8 +3193,8 @@ function setupPatterns(ctx) {
|
|
|
3034
3193
|
if (!files)
|
|
3035
3194
|
return;
|
|
3036
3195
|
const index = {
|
|
3037
|
-
js:
|
|
3038
|
-
dts:
|
|
3196
|
+
js: import_outdent43.default.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
3197
|
+
dts: import_outdent43.default.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
3039
3198
|
};
|
|
3040
3199
|
return {
|
|
3041
3200
|
dir: ctx.paths.pattern,
|
|
@@ -3050,20 +3209,20 @@ function setupPatterns(ctx) {
|
|
|
3050
3209
|
function setupJsx(ctx) {
|
|
3051
3210
|
if (!ctx.jsx.framework)
|
|
3052
3211
|
return;
|
|
3053
|
-
const isValidProp =
|
|
3212
|
+
const isValidProp = generateIsValidProp(ctx);
|
|
3054
3213
|
const types = generateJsxTypes(ctx);
|
|
3055
3214
|
const factory = generateJsxFactory(ctx);
|
|
3056
3215
|
const patterns = generateJsxPatterns(ctx);
|
|
3057
3216
|
const index = {
|
|
3058
|
-
js:
|
|
3217
|
+
js: import_outdent43.default`
|
|
3059
3218
|
${ctx.file.export("./factory")}
|
|
3060
3219
|
${isValidProp?.js ? ctx.file.export("./is-valid-prop") : ""}
|
|
3061
|
-
${
|
|
3220
|
+
${import_outdent43.default.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
3062
3221
|
`,
|
|
3063
|
-
dts:
|
|
3222
|
+
dts: import_outdent43.default`
|
|
3064
3223
|
export * from './factory'
|
|
3065
3224
|
${isValidProp?.dts ? `export * from './is-valid-prop'` : ""}
|
|
3066
|
-
${
|
|
3225
|
+
${import_outdent43.default.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
3067
3226
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
3068
3227
|
`
|
|
3069
3228
|
};
|
|
@@ -3083,15 +3242,17 @@ function setupJsx(ctx) {
|
|
|
3083
3242
|
}
|
|
3084
3243
|
function setupCssIndex(ctx) {
|
|
3085
3244
|
const index = {
|
|
3086
|
-
js:
|
|
3245
|
+
js: import_outdent43.default`
|
|
3087
3246
|
${ctx.file.export("./css")}
|
|
3088
3247
|
${ctx.file.export("./cx")}
|
|
3089
3248
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./cva")}
|
|
3249
|
+
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./sva")}
|
|
3090
3250
|
`,
|
|
3091
|
-
dts:
|
|
3251
|
+
dts: import_outdent43.default`
|
|
3092
3252
|
export * from './css'
|
|
3093
3253
|
export * from './cx'
|
|
3094
3254
|
${ctx.isTemplateLiteralSyntax ? "" : `export * from './cva'`}
|
|
3255
|
+
${ctx.isTemplateLiteralSyntax ? "" : `export * from './sva'`}
|
|
3095
3256
|
`
|
|
3096
3257
|
};
|
|
3097
3258
|
return {
|
|
@@ -3135,6 +3296,7 @@ var generateArtifacts = (ctx) => () => {
|
|
|
3135
3296
|
setupKeyframes(ctx),
|
|
3136
3297
|
setupTypes(ctx),
|
|
3137
3298
|
setupCva(ctx),
|
|
3299
|
+
setupSva(ctx),
|
|
3138
3300
|
setupCx(ctx),
|
|
3139
3301
|
setupCss(ctx),
|
|
3140
3302
|
setupRecipes(ctx),
|
|
@@ -3185,7 +3347,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3185
3347
|
// src/artifacts/css/parser-css.ts
|
|
3186
3348
|
var import_logger2 = require("@pandacss/logger");
|
|
3187
3349
|
var import_func = require("lil-fp/func");
|
|
3188
|
-
var
|
|
3350
|
+
var import_ts_pattern10 = require("ts-pattern");
|
|
3189
3351
|
var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
3190
3352
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3191
3353
|
(0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3199,26 +3361,31 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3199
3361
|
sheet.processAtomicRecipe(data);
|
|
3200
3362
|
});
|
|
3201
3363
|
});
|
|
3364
|
+
result2.sva.forEach((sva) => {
|
|
3365
|
+
sva.data.forEach((data) => {
|
|
3366
|
+
sheet.processAtomicSlotRecipe(data);
|
|
3367
|
+
});
|
|
3368
|
+
});
|
|
3202
3369
|
result2.jsx.forEach((jsx) => {
|
|
3203
3370
|
jsx.data.forEach((data) => {
|
|
3204
3371
|
sheet.processStyleProps(data);
|
|
3205
3372
|
});
|
|
3206
3373
|
});
|
|
3207
|
-
result2.recipe.forEach((recipeSet,
|
|
3374
|
+
result2.recipe.forEach((recipeSet, recipeName) => {
|
|
3208
3375
|
try {
|
|
3209
3376
|
for (const recipe of recipeSet) {
|
|
3210
|
-
const recipeConfig = recipes.getConfig(
|
|
3377
|
+
const recipeConfig = recipes.getConfig(recipeName);
|
|
3211
3378
|
if (!recipeConfig)
|
|
3212
3379
|
continue;
|
|
3213
|
-
(0,
|
|
3380
|
+
(0, import_ts_pattern10.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3214
3381
|
recipe.data.forEach((data) => {
|
|
3215
|
-
const [recipeProps, styleProps] = recipes.splitProps(
|
|
3382
|
+
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3216
3383
|
sheet.processStyleProps(styleProps);
|
|
3217
|
-
sheet.processRecipe(recipeConfig, recipeProps);
|
|
3384
|
+
sheet.processRecipe(recipeName, recipeConfig, recipeProps);
|
|
3218
3385
|
});
|
|
3219
3386
|
}).otherwise(() => {
|
|
3220
3387
|
recipe.data.forEach((data) => {
|
|
3221
|
-
sheet.processRecipe(recipeConfig, data);
|
|
3388
|
+
sheet.processRecipe(recipeName, recipeConfig, data);
|
|
3222
3389
|
});
|
|
3223
3390
|
});
|
|
3224
3391
|
}
|
|
@@ -3229,9 +3396,9 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3229
3396
|
result2.pattern.forEach((patternSet, name) => {
|
|
3230
3397
|
try {
|
|
3231
3398
|
for (const pattern of patternSet) {
|
|
3232
|
-
(0,
|
|
3399
|
+
(0, import_ts_pattern10.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern10.P.string }, ({ name: jsxName }) => {
|
|
3233
3400
|
pattern.data.forEach((data) => {
|
|
3234
|
-
const fnName = patterns.getFnName(
|
|
3401
|
+
const fnName = patterns.getFnName(jsxName);
|
|
3235
3402
|
const styleProps = patterns.transform(fnName, data);
|
|
3236
3403
|
sheet.processStyleProps(styleProps);
|
|
3237
3404
|
});
|
|
@@ -3260,7 +3427,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3260
3427
|
);
|
|
3261
3428
|
|
|
3262
3429
|
// src/engines/base.ts
|
|
3263
|
-
var
|
|
3430
|
+
var import_core5 = require("@pandacss/core");
|
|
3264
3431
|
var import_is_valid_prop3 = require("@pandacss/is-valid-prop");
|
|
3265
3432
|
var import_shared5 = require("@pandacss/shared");
|
|
3266
3433
|
var import_token_dictionary = require("@pandacss/token-dictionary");
|
|
@@ -3288,14 +3455,14 @@ var getBaseEngine = (conf) => {
|
|
|
3288
3455
|
prefix: prefix.tokens,
|
|
3289
3456
|
hash: hash.tokens
|
|
3290
3457
|
});
|
|
3291
|
-
const utility = new
|
|
3458
|
+
const utility = new import_core5.Utility({
|
|
3292
3459
|
prefix: prefix.className,
|
|
3293
3460
|
tokens,
|
|
3294
3461
|
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
3295
3462
|
separator: config.separator,
|
|
3296
3463
|
shorthands: config.shorthands
|
|
3297
3464
|
});
|
|
3298
|
-
const conditions = new
|
|
3465
|
+
const conditions = new import_core5.Conditions({
|
|
3299
3466
|
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
|
3300
3467
|
breakpoints: config.theme?.breakpoints
|
|
3301
3468
|
});
|
|
@@ -3305,7 +3472,7 @@ var getBaseEngine = (conf) => {
|
|
|
3305
3472
|
layerStyle: layerStyles
|
|
3306
3473
|
});
|
|
3307
3474
|
const compositionContext = { conditions, utility };
|
|
3308
|
-
(0,
|
|
3475
|
+
(0, import_core5.assignCompositions)(compositions, compositionContext);
|
|
3309
3476
|
const createSheetContext = () => ({
|
|
3310
3477
|
root: import_postcss3.default.root(),
|
|
3311
3478
|
conditions,
|
|
@@ -3315,13 +3482,15 @@ var getBaseEngine = (conf) => {
|
|
|
3315
3482
|
});
|
|
3316
3483
|
const createSheet = (options) => {
|
|
3317
3484
|
const sheetContext = createSheetContext();
|
|
3318
|
-
return new
|
|
3485
|
+
return new import_core5.Stylesheet(sheetContext, {
|
|
3319
3486
|
content: options?.content,
|
|
3320
|
-
recipes: theme?.recipes
|
|
3487
|
+
recipes: theme?.recipes,
|
|
3488
|
+
slotRecipes: theme?.slotRecipes
|
|
3321
3489
|
});
|
|
3322
3490
|
};
|
|
3323
3491
|
const recipeContext = createSheetContext();
|
|
3324
|
-
const
|
|
3492
|
+
const recipeConfigs = Object.assign({}, theme.recipes ?? {}, theme.slotRecipes ?? {});
|
|
3493
|
+
const recipes = new import_core5.Recipes(recipeConfigs, recipeContext);
|
|
3325
3494
|
recipes.save();
|
|
3326
3495
|
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
3327
3496
|
const propertyMap = new Map(properties.map((prop) => [prop, true]));
|
|
@@ -3352,13 +3521,14 @@ var getBaseEngine = (conf) => {
|
|
|
3352
3521
|
// src/engines/jsx.ts
|
|
3353
3522
|
var import_shared6 = require("@pandacss/shared");
|
|
3354
3523
|
var getJsxEngine = (config) => {
|
|
3355
|
-
const { jsxFactory, jsxFramework } = config;
|
|
3524
|
+
const { jsxFactory, jsxFramework, jsxStyleProps: jsxStyleProps2 } = config;
|
|
3356
3525
|
return {
|
|
3357
3526
|
factoryName: jsxFactory,
|
|
3358
3527
|
upperName: (0, import_shared6.capitalize)(jsxFactory),
|
|
3359
3528
|
typeName: `HTML${(0, import_shared6.capitalize)(jsxFactory)}Props`,
|
|
3360
3529
|
componentName: `${(0, import_shared6.capitalize)(jsxFactory)}Component`,
|
|
3361
|
-
framework: jsxFramework
|
|
3530
|
+
framework: jsxFramework,
|
|
3531
|
+
styleProps: jsxStyleProps2 ?? "all"
|
|
3362
3532
|
};
|
|
3363
3533
|
};
|
|
3364
3534
|
|
|
@@ -3381,52 +3551,47 @@ var getPathEngine = ({ cwd, emitPackage, outdir }) => {
|
|
|
3381
3551
|
|
|
3382
3552
|
// src/engines/pattern.ts
|
|
3383
3553
|
var import_shared7 = require("@pandacss/shared");
|
|
3384
|
-
var import_lil_fp2 = require("lil-fp");
|
|
3385
3554
|
var helpers2 = { map: import_shared7.mapObject };
|
|
3386
3555
|
var getPatternEngine = (config) => {
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
}
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
baseName: name
|
|
3421
|
-
}));
|
|
3556
|
+
const patterns = config.patterns ?? {};
|
|
3557
|
+
const getNames = (name) => {
|
|
3558
|
+
const upperName = (0, import_shared7.capitalize)(name);
|
|
3559
|
+
return {
|
|
3560
|
+
upperName,
|
|
3561
|
+
baseName: name,
|
|
3562
|
+
dashName: (0, import_shared7.dashCase)(name),
|
|
3563
|
+
styleFnName: `get${upperName}Style`,
|
|
3564
|
+
jsxName: patterns[name]?.jsxName ?? upperName
|
|
3565
|
+
};
|
|
3566
|
+
};
|
|
3567
|
+
const details = Object.entries(patterns).map(([name, pattern]) => {
|
|
3568
|
+
const names = getNames(name);
|
|
3569
|
+
const jsx = (pattern.jsx ?? []).concat([names.jsxName]);
|
|
3570
|
+
return {
|
|
3571
|
+
...names,
|
|
3572
|
+
props: Object.keys(pattern?.properties ?? {}),
|
|
3573
|
+
blocklistType: pattern?.blocklist ? `| '${pattern.blocklist.join("' | '")}'` : "",
|
|
3574
|
+
config: pattern,
|
|
3575
|
+
type: "pattern",
|
|
3576
|
+
match: (0, import_shared7.createRegex)(jsx),
|
|
3577
|
+
jsx
|
|
3578
|
+
};
|
|
3579
|
+
});
|
|
3580
|
+
return {
|
|
3581
|
+
getConfig: (name) => patterns[name],
|
|
3582
|
+
transform: (name, data) => {
|
|
3583
|
+
return patterns[name]?.transform?.(data, helpers2) ?? {};
|
|
3584
|
+
},
|
|
3585
|
+
getNames,
|
|
3586
|
+
details,
|
|
3587
|
+
getFnName: (0, import_shared7.memo)((jsxName) => {
|
|
3588
|
+
return details.find((node) => node.jsxName === jsxName)?.baseName ?? (0, import_shared7.uncapitalize)(jsxName);
|
|
3422
3589
|
}),
|
|
3423
|
-
|
|
3424
|
-
return
|
|
3590
|
+
filter: (0, import_shared7.memo)((jsxName) => {
|
|
3591
|
+
return details.filter((node) => node.match.test(jsxName));
|
|
3425
3592
|
}),
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
})
|
|
3429
|
-
);
|
|
3593
|
+
isEmpty: () => Object.keys(patterns).length === 0
|
|
3594
|
+
};
|
|
3430
3595
|
};
|
|
3431
3596
|
|
|
3432
3597
|
// src/engines/index.ts
|
|
@@ -3454,6 +3619,7 @@ var defaults = (conf) => ({
|
|
|
3454
3619
|
config: {
|
|
3455
3620
|
cssVarRoot: ":where(:root, :host)",
|
|
3456
3621
|
jsxFactory: "styled",
|
|
3622
|
+
jsxStyleProps: "all",
|
|
3457
3623
|
outExtension: "mjs",
|
|
3458
3624
|
shorthands: true,
|
|
3459
3625
|
syntax: "object-literal",
|
|
@@ -3483,10 +3649,12 @@ var createGenerator = (conf) => {
|
|
|
3483
3649
|
importMap: getImportMap(config.outdir.replace(relativeBaseUrl, "")),
|
|
3484
3650
|
jsx: {
|
|
3485
3651
|
factory: jsx.factoryName,
|
|
3652
|
+
styleProps: jsx.styleProps,
|
|
3486
3653
|
isStyleProp: isValidProperty,
|
|
3487
|
-
nodes: [...patterns.
|
|
3654
|
+
nodes: [...patterns.details, ...recipes.details]
|
|
3488
3655
|
},
|
|
3489
3656
|
getRecipesByJsxName: recipes.filter,
|
|
3657
|
+
getPatternsByJsxName: patterns.filter,
|
|
3490
3658
|
compilerOptions,
|
|
3491
3659
|
tsOptions: conf.tsOptions
|
|
3492
3660
|
}
|