@pandacss/generator 0.16.0 → 0.17.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 +18 -15
- package/dist/index.d.ts +18 -15
- package/dist/index.js +609 -313
- package/dist/index.mjs +609 -313
- 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_outdent44 = __toESM(require("outdent"));
|
|
134
134
|
|
|
135
135
|
// src/artifacts/css/global-css.ts
|
|
136
136
|
var generateGlobalCss = (ctx) => {
|
|
@@ -518,12 +518,25 @@ function getDeepestNode(node) {
|
|
|
518
518
|
function cleanupSelectors(css2, varSelector) {
|
|
519
519
|
const root = import_postcss2.default.parse(css2);
|
|
520
520
|
root.walkRules((rule) => {
|
|
521
|
+
const selectors = [];
|
|
521
522
|
rule.selectors.forEach((selector) => {
|
|
522
|
-
|
|
523
|
-
if (res.length === 0)
|
|
524
|
-
return;
|
|
525
|
-
rule.selector = res.join(varSelector);
|
|
523
|
+
selectors.push(selector.trim());
|
|
526
524
|
});
|
|
525
|
+
const ruleSelector = selectors.join(", ");
|
|
526
|
+
if (ruleSelector === varSelector) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const trimmedSelector = selectors.join(",");
|
|
530
|
+
if (trimmedSelector === varSelector) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const selectorsWithoutVarRoot = selectors.map((selector) => {
|
|
534
|
+
const res = selector.split(varSelector).filter(Boolean);
|
|
535
|
+
return res.join("");
|
|
536
|
+
}).filter(Boolean);
|
|
537
|
+
if (selectorsWithoutVarRoot.length === 0)
|
|
538
|
+
return;
|
|
539
|
+
rule.selector = selectorsWithoutVarRoot.join(", ");
|
|
527
540
|
});
|
|
528
541
|
return root.toString();
|
|
529
542
|
}
|
|
@@ -637,11 +650,7 @@ function generateStringLiteralConditions(ctx) {
|
|
|
637
650
|
// src/artifacts/js/css-fn.ts
|
|
638
651
|
var import_outdent4 = require("outdent");
|
|
639
652
|
function generateCssFn(ctx) {
|
|
640
|
-
const {
|
|
641
|
-
utility,
|
|
642
|
-
config: { hash, prefix },
|
|
643
|
-
conditions
|
|
644
|
-
} = ctx;
|
|
653
|
+
const { utility, hash, prefix, conditions } = ctx;
|
|
645
654
|
const { separator, getPropShorthands } = utility;
|
|
646
655
|
return {
|
|
647
656
|
dts: import_outdent4.outdent`
|
|
@@ -696,14 +705,14 @@ function generateCssFn(ctx) {
|
|
|
696
705
|
`}
|
|
697
706
|
|
|
698
707
|
const context = {
|
|
699
|
-
${hash ? "hash: true," : ""}
|
|
708
|
+
${hash.className ? "hash: true," : ""}
|
|
700
709
|
conditions: {
|
|
701
710
|
shift: sortConditions,
|
|
702
711
|
finalize: finalizeConditions,
|
|
703
712
|
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
704
713
|
},
|
|
705
714
|
utility: {
|
|
706
|
-
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
715
|
+
${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
|
|
707
716
|
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
708
717
|
const key = resolveShorthand(prop)
|
|
709
718
|
const propKey = classNameByProp.get(key) || hypenateProperty(key)
|
|
@@ -726,18 +735,15 @@ function generateCssFn(ctx) {
|
|
|
726
735
|
// src/artifacts/js/css-fn.string-literal.ts
|
|
727
736
|
var import_outdent5 = require("outdent");
|
|
728
737
|
function generateStringLiteralCssFn(ctx) {
|
|
729
|
-
const {
|
|
730
|
-
utility,
|
|
731
|
-
config: { hash, prefix }
|
|
732
|
-
} = ctx;
|
|
738
|
+
const { utility, hash, prefix } = ctx;
|
|
733
739
|
const { separator } = utility;
|
|
734
740
|
return {
|
|
735
741
|
dts: import_outdent5.outdent`
|
|
736
742
|
export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
|
|
737
743
|
`,
|
|
738
744
|
js: import_outdent5.outdent`
|
|
739
|
-
${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
|
|
740
|
-
${ctx.file.import("
|
|
745
|
+
${ctx.file.import("astish, createCss, isObject, mergeProps, withoutSpace", "../helpers")}
|
|
746
|
+
${ctx.file.import("finalizeConditions, sortConditions", "./conditions")}
|
|
741
747
|
|
|
742
748
|
function transform(prop, value) {
|
|
743
749
|
const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
|
|
@@ -745,14 +751,14 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
745
751
|
}
|
|
746
752
|
|
|
747
753
|
const context = {
|
|
748
|
-
hash: ${hash ? "true" : "false"},
|
|
754
|
+
hash: ${hash.className ? "true" : "false"},
|
|
749
755
|
conditions: {
|
|
750
756
|
shift: sortConditions,
|
|
751
757
|
finalize: finalizeConditions,
|
|
752
758
|
breakpoints: { keys: [] },
|
|
753
759
|
},
|
|
754
760
|
utility: {
|
|
755
|
-
prefix: ${prefix ? JSON.stringify(prefix) : void 0},
|
|
761
|
+
prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
|
|
756
762
|
transform,
|
|
757
763
|
hasShorthand: false,
|
|
758
764
|
resolveShorthand(prop) {
|
|
@@ -763,9 +769,9 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
763
769
|
|
|
764
770
|
const cssFn = createCss(context)
|
|
765
771
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
772
|
+
const fn = (style) => (isObject(style) ? style : astish(style[0]))
|
|
773
|
+
export const css = (...styles) => cssFn(mergeProps(...styles.filter(Boolean).map(fn)))
|
|
774
|
+
css.raw = (...styles) => mergeProps(...styles.filter(Boolean).map(fn))
|
|
769
775
|
`
|
|
770
776
|
};
|
|
771
777
|
}
|
|
@@ -775,11 +781,19 @@ var import_outdent6 = require("outdent");
|
|
|
775
781
|
function generateCvaFn(ctx) {
|
|
776
782
|
return {
|
|
777
783
|
js: import_outdent6.outdent`
|
|
778
|
-
${ctx.file.import("compact, splitProps", "../helpers")}
|
|
784
|
+
${ctx.file.import("compact, mergeProps, splitProps, uniq", "../helpers")}
|
|
779
785
|
${ctx.file.import("css, mergeCss", "./css")}
|
|
780
786
|
|
|
787
|
+
const defaults = (conf) => ({
|
|
788
|
+
base: {},
|
|
789
|
+
variants: {},
|
|
790
|
+
defaultVariants: {},
|
|
791
|
+
compoundVariants: [],
|
|
792
|
+
...conf,
|
|
793
|
+
})
|
|
794
|
+
|
|
781
795
|
export function cva(config) {
|
|
782
|
-
const { base
|
|
796
|
+
const { base, variants, defaultVariants, compoundVariants } = defaults(config)
|
|
783
797
|
|
|
784
798
|
function resolve(props = {}) {
|
|
785
799
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
@@ -793,6 +807,19 @@ function generateCvaFn(ctx) {
|
|
|
793
807
|
return mergeCss(variantCss, compoundVariantCss)
|
|
794
808
|
}
|
|
795
809
|
|
|
810
|
+
function merge(cvaConfig) {
|
|
811
|
+
const override = defaults(cvaConfig)
|
|
812
|
+
const variantKeys = uniq(override.variantKeys, Object.keys(variants))
|
|
813
|
+
return cva({
|
|
814
|
+
base: mergeCss(base, override.base),
|
|
815
|
+
variants: Object.fromEntries(
|
|
816
|
+
variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
|
|
817
|
+
),
|
|
818
|
+
defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
|
|
819
|
+
compoundVariants: [...compoundVariants, ...override.compoundVariants],
|
|
820
|
+
})
|
|
821
|
+
}
|
|
822
|
+
|
|
796
823
|
function cvaFn(props) {
|
|
797
824
|
return css(resolve(props))
|
|
798
825
|
}
|
|
@@ -811,6 +838,7 @@ function generateCvaFn(ctx) {
|
|
|
811
838
|
variantKeys,
|
|
812
839
|
raw: resolve,
|
|
813
840
|
config,
|
|
841
|
+
merge,
|
|
814
842
|
splitVariantProps,
|
|
815
843
|
})
|
|
816
844
|
}
|
|
@@ -885,7 +913,7 @@ var import_outdent8 = require("outdent");
|
|
|
885
913
|
|
|
886
914
|
// src/artifacts/generated/helpers.mjs.json
|
|
887
915
|
var helpers_mjs_default = {
|
|
888
|
-
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
|
|
916
|
+
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 __sources = sources.filter(Boolean);\n const result = {};\n for (const source of __sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate-property.ts\nvar wordRegex = /([A-Z])/g;\nvar msRegex = /^ms-/;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();\n});\n\n// src/slot.ts\nvar getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join("__"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const slots = recipe.slots ?? [];\n const recipeParts = slots.map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {\n for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {\n recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n }\n }\n return Object.fromEntries(recipeParts);\n};\nvar getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));\n\n// src/split-props.ts\nfunction splitProps(props, ...keys) {\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const dKeys = Object.keys(descriptors);\n const split = (k) => {\n const clone = {};\n for (let i = 0; i < k.length; i++) {\n const key = k[i];\n if (descriptors[key]) {\n Object.defineProperty(clone, key, descriptors[key]);\n delete descriptors[key];\n }\n }\n return clone;\n };\n const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));\n return keys.map(fn).concat(split(dKeys));\n}\n\n// src/uniq.ts\nvar uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(/* @__PURE__ */ new Set([...acc, ...item])), []);\nexport {\n compact,\n createCss,\n createMergeCss,\n filterBaseConditions,\n getSlotCompoundVariant,\n getSlotRecipes,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n memo,\n mergeProps,\n splitProps,\n toHash,\n uniq,\n walkObject,\n withoutSpace\n};\n'
|
|
889
917
|
};
|
|
890
918
|
|
|
891
919
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -953,11 +981,52 @@ function generateIsValidProp(ctx) {
|
|
|
953
981
|
};
|
|
954
982
|
}
|
|
955
983
|
|
|
984
|
+
// src/artifacts/js/jsx-helper.ts
|
|
985
|
+
var import_outdent10 = require("outdent");
|
|
986
|
+
var import_ts_pattern2 = require("ts-pattern");
|
|
987
|
+
function generatedJsxHelpers(ctx) {
|
|
988
|
+
return {
|
|
989
|
+
js: (0, import_ts_pattern2.match)(ctx.isTemplateLiteralSyntax).with(
|
|
990
|
+
true,
|
|
991
|
+
() => import_outdent10.outdent`
|
|
992
|
+
export const getDisplayName = (Component) => {
|
|
993
|
+
if (typeof Component === 'string') return Component
|
|
994
|
+
return Component?.displayName || Component?.name || 'Component'
|
|
995
|
+
}`
|
|
996
|
+
).otherwise(
|
|
997
|
+
() => import_outdent10.outdent`
|
|
998
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
999
|
+
|
|
1000
|
+
export const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1001
|
+
|
|
1002
|
+
export const composeShouldForwardProps = (tag, shouldForwardProp) =>
|
|
1003
|
+
tag.__shouldForwardProps__ && shouldForwardProp
|
|
1004
|
+
? (propName) => tag.__shouldForwardProps__(propName) && shouldForwardProp(propName)
|
|
1005
|
+
: shouldForwardProp
|
|
1006
|
+
|
|
1007
|
+
export const composeCvaFn = (cvaA, cvaB) => {
|
|
1008
|
+
if (cvaA && !cvaB) return cvaA
|
|
1009
|
+
if (!cvaA && cvaB) return cvaB
|
|
1010
|
+
if ((cvaA.__cva__ && cvaB.__cva__) || (cvaA.__recipe__ && cvaB.__recipe__)) return cvaA.merge(cvaB.config)
|
|
1011
|
+
const error = new TypeError('Cannot merge cva with recipe. Please use either cva or recipe.')
|
|
1012
|
+
TypeError.captureStackTrace?.(error)
|
|
1013
|
+
throw error
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
export const getDisplayName = (Component) => {
|
|
1017
|
+
if (typeof Component === 'string') return Component
|
|
1018
|
+
return Component?.displayName || Component?.name || 'Component'
|
|
1019
|
+
}
|
|
1020
|
+
`
|
|
1021
|
+
)
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
|
|
956
1025
|
// src/artifacts/js/pattern.ts
|
|
957
1026
|
var import_shared = require("@pandacss/shared");
|
|
958
1027
|
var import_javascript_stringify = require("javascript-stringify");
|
|
959
|
-
var
|
|
960
|
-
var
|
|
1028
|
+
var import_outdent11 = require("outdent");
|
|
1029
|
+
var import_ts_pattern3 = require("ts-pattern");
|
|
961
1030
|
function generatePattern(ctx) {
|
|
962
1031
|
if (ctx.patterns.isEmpty())
|
|
963
1032
|
return;
|
|
@@ -974,7 +1043,7 @@ function generatePattern(ctx) {
|
|
|
974
1043
|
}
|
|
975
1044
|
return {
|
|
976
1045
|
name: dashName,
|
|
977
|
-
dts:
|
|
1046
|
+
dts: import_outdent11.outdent`
|
|
978
1047
|
${ctx.file.importType("SystemStyleObject, ConditionalValue", "../types/index")}
|
|
979
1048
|
${ctx.file.importType("Properties", "../types/csstype")}
|
|
980
1049
|
${ctx.file.importType("PropertyValue", "../types/prop-type")}
|
|
@@ -984,7 +1053,7 @@ function generatePattern(ctx) {
|
|
|
984
1053
|
export interface ${upperName}Properties {
|
|
985
1054
|
${Object.keys(properties ?? {}).map((key) => {
|
|
986
1055
|
const value = properties[key];
|
|
987
|
-
return (0,
|
|
1056
|
+
return (0, import_ts_pattern3.match)(value).with({ type: "property" }, (value2) => {
|
|
988
1057
|
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
989
1058
|
}).with({ type: "token" }, (value2) => {
|
|
990
1059
|
if (value2.property) {
|
|
@@ -999,7 +1068,7 @@ function generatePattern(ctx) {
|
|
|
999
1068
|
}).join("\n ")}
|
|
1000
1069
|
}
|
|
1001
1070
|
|
|
1002
|
-
${strict ?
|
|
1071
|
+
${strict ? import_outdent11.outdent`export declare function ${baseName}(styles: ${upperName}Properties): string` : import_outdent11.outdent`
|
|
1003
1072
|
|
|
1004
1073
|
interface ${upperName}Styles extends ${upperName}Properties, DistributiveOmit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}> {}
|
|
1005
1074
|
|
|
@@ -1013,7 +1082,7 @@ function generatePattern(ctx) {
|
|
|
1013
1082
|
`}
|
|
1014
1083
|
|
|
1015
1084
|
`,
|
|
1016
|
-
js:
|
|
1085
|
+
js: import_outdent11.outdent`
|
|
1017
1086
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
1018
1087
|
${ctx.file.import("css", "../css/index")}
|
|
1019
1088
|
|
|
@@ -1032,8 +1101,8 @@ transform`)}
|
|
|
1032
1101
|
// src/artifacts/js/recipe.ts
|
|
1033
1102
|
var import_core4 = require("@pandacss/core");
|
|
1034
1103
|
var import_shared2 = require("@pandacss/shared");
|
|
1035
|
-
var
|
|
1036
|
-
var
|
|
1104
|
+
var import_outdent12 = require("outdent");
|
|
1105
|
+
var import_ts_pattern4 = require("ts-pattern");
|
|
1037
1106
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
1038
1107
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
1039
1108
|
function generateRecipes(ctx) {
|
|
@@ -1047,11 +1116,11 @@ function generateRecipes(ctx) {
|
|
|
1047
1116
|
const createRecipeFn = {
|
|
1048
1117
|
name: "create-recipe",
|
|
1049
1118
|
dts: "",
|
|
1050
|
-
js:
|
|
1119
|
+
js: import_outdent12.outdent`
|
|
1051
1120
|
${ctx.file.import("css", "../css/css")}
|
|
1052
1121
|
${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
|
|
1053
1122
|
${ctx.file.import("cx", "../css/cx")}
|
|
1054
|
-
${ctx.file.import("compact, createCss, withoutSpace", "../helpers")}
|
|
1123
|
+
${ctx.file.import("compact, createCss, splitProps, uniq, withoutSpace", "../helpers")}
|
|
1055
1124
|
|
|
1056
1125
|
export const createRecipe = (name, defaultVariants, compoundVariants) => {
|
|
1057
1126
|
const getRecipeStyles = (variants) => {
|
|
@@ -1098,6 +1167,30 @@ function generateRecipes(ctx) {
|
|
|
1098
1167
|
},
|
|
1099
1168
|
})
|
|
1100
1169
|
}
|
|
1170
|
+
|
|
1171
|
+
export const mergeRecipes = (recipeA, recipeB) => {
|
|
1172
|
+
if (recipeA && !recipeB) return recipeA
|
|
1173
|
+
if (!recipeA && recipeB) return recipeB
|
|
1174
|
+
|
|
1175
|
+
const recipeFn = (...args) => cx(recipeA(...args), recipeB(...args))
|
|
1176
|
+
const variantKeys = uniq(recipeA.variantKeys, recipeB.variantKeys)
|
|
1177
|
+
const variantMap = variantKeys.reduce((acc, key) => {
|
|
1178
|
+
acc[key] = uniq(recipeA.variantMap[key], recipeB.variantMap[key])
|
|
1179
|
+
return acc
|
|
1180
|
+
}, {})
|
|
1181
|
+
|
|
1182
|
+
return Object.assign(recipeFn, {
|
|
1183
|
+
__recipe__: true,
|
|
1184
|
+
__name__: \`$\{recipeA.__name__} \${recipeB.__name__}\`,
|
|
1185
|
+
raw: (props) => props,
|
|
1186
|
+
variantKeys,
|
|
1187
|
+
variantMap,
|
|
1188
|
+
splitVariantProps(props) {
|
|
1189
|
+
return splitProps(props, variantKeys)
|
|
1190
|
+
},
|
|
1191
|
+
})
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1101
1194
|
`
|
|
1102
1195
|
};
|
|
1103
1196
|
return [
|
|
@@ -1105,9 +1198,9 @@ function generateRecipes(ctx) {
|
|
|
1105
1198
|
...ctx.recipes.details.map((recipe) => {
|
|
1106
1199
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
1107
1200
|
const { description, defaultVariants, compoundVariants } = config;
|
|
1108
|
-
const jsCode = (0,
|
|
1201
|
+
const jsCode = (0, import_ts_pattern4.match)(config).when(
|
|
1109
1202
|
import_core4.isSlotRecipe,
|
|
1110
|
-
(config2) =>
|
|
1203
|
+
(config2) => import_outdent12.outdent`
|
|
1111
1204
|
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1112
1205
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1113
1206
|
|
|
@@ -1135,9 +1228,9 @@ function generateRecipes(ctx) {
|
|
|
1135
1228
|
})
|
|
1136
1229
|
`
|
|
1137
1230
|
).otherwise(
|
|
1138
|
-
(config2) =>
|
|
1231
|
+
(config2) => import_outdent12.outdent`
|
|
1139
1232
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1140
|
-
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1233
|
+
${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
|
|
1141
1234
|
|
|
1142
1235
|
const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
|
|
1143
1236
|
defaultVariants ?? {}
|
|
@@ -1153,6 +1246,9 @@ function generateRecipes(ctx) {
|
|
|
1153
1246
|
raw: (props) => props,
|
|
1154
1247
|
variantKeys: ${baseName}VariantKeys,
|
|
1155
1248
|
variantMap: ${baseName}VariantMap,
|
|
1249
|
+
merge(recipe) {
|
|
1250
|
+
return mergeRecipes(this, recipe)
|
|
1251
|
+
},
|
|
1156
1252
|
splitVariantProps(props) {
|
|
1157
1253
|
return splitProps(props, ${baseName}VariantKeys)
|
|
1158
1254
|
},
|
|
@@ -1162,10 +1258,9 @@ function generateRecipes(ctx) {
|
|
|
1162
1258
|
return {
|
|
1163
1259
|
name: dashName,
|
|
1164
1260
|
js: jsCode,
|
|
1165
|
-
dts:
|
|
1261
|
+
dts: import_outdent12.outdent`
|
|
1166
1262
|
${ctx.file.importType("ConditionalValue", "../types/index")}
|
|
1167
|
-
${ctx.file.importType("Pretty", "../types/
|
|
1168
|
-
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
1263
|
+
${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
|
|
1169
1264
|
|
|
1170
1265
|
interface ${upperName}Variant {
|
|
1171
1266
|
${Object.keys(variantKeyMap).map((key) => {
|
|
@@ -1202,10 +1297,10 @@ function generateRecipes(ctx) {
|
|
|
1202
1297
|
}
|
|
1203
1298
|
|
|
1204
1299
|
// src/artifacts/js/sva.ts
|
|
1205
|
-
var
|
|
1300
|
+
var import_outdent13 = require("outdent");
|
|
1206
1301
|
function generateSvaFn(ctx) {
|
|
1207
1302
|
return {
|
|
1208
|
-
js:
|
|
1303
|
+
js: import_outdent13.outdent`
|
|
1209
1304
|
${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
|
|
1210
1305
|
${ctx.file.import("cva", "./cva")}
|
|
1211
1306
|
|
|
@@ -1242,7 +1337,7 @@ function generateSvaFn(ctx) {
|
|
|
1242
1337
|
})
|
|
1243
1338
|
}
|
|
1244
1339
|
`,
|
|
1245
|
-
dts:
|
|
1340
|
+
dts: import_outdent13.outdent`
|
|
1246
1341
|
${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
|
|
1247
1342
|
|
|
1248
1343
|
export declare const sva: SlotRecipeCreatorFn
|
|
@@ -1251,7 +1346,7 @@ function generateSvaFn(ctx) {
|
|
|
1251
1346
|
}
|
|
1252
1347
|
|
|
1253
1348
|
// src/artifacts/js/token.ts
|
|
1254
|
-
var
|
|
1349
|
+
var import_outdent14 = __toESM(require("outdent"));
|
|
1255
1350
|
function generateTokenJs(ctx) {
|
|
1256
1351
|
const { tokens } = ctx;
|
|
1257
1352
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1262,7 +1357,7 @@ function generateTokenJs(ctx) {
|
|
|
1262
1357
|
});
|
|
1263
1358
|
const obj = Object.fromEntries(map);
|
|
1264
1359
|
return {
|
|
1265
|
-
js:
|
|
1360
|
+
js: import_outdent14.default`
|
|
1266
1361
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1267
1362
|
|
|
1268
1363
|
export function token(path, fallback) {
|
|
@@ -1275,7 +1370,7 @@ function generateTokenJs(ctx) {
|
|
|
1275
1370
|
|
|
1276
1371
|
token.var = tokenVar
|
|
1277
1372
|
`,
|
|
1278
|
-
dts:
|
|
1373
|
+
dts: import_outdent14.default`
|
|
1279
1374
|
${ctx.file.importType("Token", "./tokens")}
|
|
1280
1375
|
|
|
1281
1376
|
export declare const token: {
|
|
@@ -1289,19 +1384,21 @@ function generateTokenJs(ctx) {
|
|
|
1289
1384
|
}
|
|
1290
1385
|
|
|
1291
1386
|
// src/artifacts/preact-jsx/jsx.ts
|
|
1292
|
-
var
|
|
1387
|
+
var import_outdent15 = require("outdent");
|
|
1293
1388
|
function generatePreactJsxFactory(ctx) {
|
|
1294
1389
|
const { factoryName, componentName } = ctx.jsx;
|
|
1295
1390
|
return {
|
|
1296
|
-
js:
|
|
1391
|
+
js: import_outdent15.outdent`
|
|
1297
1392
|
import { h } from 'preact'
|
|
1298
1393
|
import { forwardRef } from 'preact/compat'
|
|
1299
1394
|
import { useMemo } from 'preact/hooks'
|
|
1395
|
+
${ctx.file.import(
|
|
1396
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
1397
|
+
"./factory-helper"
|
|
1398
|
+
)}
|
|
1399
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1300
1400
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1301
1401
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1302
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1303
|
-
|
|
1304
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1305
1402
|
|
|
1306
1403
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1307
1404
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
@@ -1315,23 +1412,26 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1315
1412
|
)
|
|
1316
1413
|
|
|
1317
1414
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1318
|
-
const { as: Element = Dynamic, children, ...restProps } = props
|
|
1415
|
+
const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
|
|
1416
|
+
|
|
1417
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
1418
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
1319
1419
|
|
|
1320
1420
|
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1321
1421
|
|
|
1322
1422
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1323
|
-
return splitProps(combinedProps,
|
|
1423
|
+
return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1324
1424
|
}, [combinedProps])
|
|
1325
1425
|
|
|
1326
1426
|
function recipeClass() {
|
|
1327
1427
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1328
|
-
const compoundVariantStyles =
|
|
1329
|
-
return cx(
|
|
1428
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
|
|
1429
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1330
1430
|
}
|
|
1331
1431
|
|
|
1332
1432
|
function cvaClass() {
|
|
1333
1433
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1334
|
-
const cvaStyles =
|
|
1434
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1335
1435
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1336
1436
|
}
|
|
1337
1437
|
|
|
@@ -1347,8 +1447,13 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1347
1447
|
})
|
|
1348
1448
|
})
|
|
1349
1449
|
|
|
1350
|
-
const name = (
|
|
1450
|
+
const name = getDisplayName(Dynamic)
|
|
1451
|
+
|
|
1351
1452
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1453
|
+
${componentName}.__cva__ = cvaFn
|
|
1454
|
+
${componentName}.__base__ = Dynamic
|
|
1455
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
1456
|
+
|
|
1352
1457
|
return ${componentName}
|
|
1353
1458
|
}
|
|
1354
1459
|
|
|
@@ -1374,8 +1479,8 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1374
1479
|
}
|
|
1375
1480
|
|
|
1376
1481
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1377
|
-
var
|
|
1378
|
-
var
|
|
1482
|
+
var import_outdent16 = require("outdent");
|
|
1483
|
+
var import_ts_pattern5 = require("ts-pattern");
|
|
1379
1484
|
function generatePreactJsxPattern(ctx) {
|
|
1380
1485
|
const { typeName, factoryName } = ctx.jsx;
|
|
1381
1486
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1383,21 +1488,21 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1383
1488
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1384
1489
|
return {
|
|
1385
1490
|
name: dashName,
|
|
1386
|
-
js:
|
|
1491
|
+
js: import_outdent16.outdent`
|
|
1387
1492
|
import { h } from 'preact'
|
|
1388
1493
|
import { forwardRef } from 'preact/compat'
|
|
1389
1494
|
${ctx.file.import(factoryName, "./factory")}
|
|
1390
1495
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1391
1496
|
|
|
1392
1497
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1393
|
-
${(0,
|
|
1498
|
+
${(0, import_ts_pattern5.match)(props.length).with(
|
|
1394
1499
|
0,
|
|
1395
|
-
() =>
|
|
1500
|
+
() => import_outdent16.outdent`
|
|
1396
1501
|
const styleProps = ${styleFnName}()
|
|
1397
1502
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1398
1503
|
`
|
|
1399
1504
|
).otherwise(
|
|
1400
|
-
() =>
|
|
1505
|
+
() => import_outdent16.outdent`
|
|
1401
1506
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1402
1507
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1403
1508
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1405,7 +1510,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1405
1510
|
)}
|
|
1406
1511
|
})
|
|
1407
1512
|
`,
|
|
1408
|
-
dts:
|
|
1513
|
+
dts: import_outdent16.outdent`
|
|
1409
1514
|
import type { FunctionComponent } from 'preact'
|
|
1410
1515
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1411
1516
|
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
@@ -1421,72 +1526,92 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1421
1526
|
}
|
|
1422
1527
|
|
|
1423
1528
|
// src/artifacts/preact-jsx/types.ts
|
|
1424
|
-
var
|
|
1529
|
+
var import_outdent17 = require("outdent");
|
|
1425
1530
|
function generatePreactJsxTypes(ctx) {
|
|
1426
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1531
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1427
1532
|
return {
|
|
1428
|
-
jsxFactory:
|
|
1533
|
+
jsxFactory: import_outdent17.outdent`
|
|
1429
1534
|
import type { ${upperName} } from '../types/jsx'
|
|
1430
1535
|
export declare const ${factoryName}: ${upperName}
|
|
1431
1536
|
`,
|
|
1432
|
-
jsxType:
|
|
1537
|
+
jsxType: import_outdent17.outdent`
|
|
1433
1538
|
import type { ComponentProps, JSX } from 'preact'
|
|
1434
|
-
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
1435
1539
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
1540
|
+
${ctx.file.importType(
|
|
1541
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
1542
|
+
"./system-types"
|
|
1543
|
+
)}
|
|
1436
1544
|
|
|
1437
|
-
type ElementType =
|
|
1545
|
+
export type ElementType = JSX.ElementType
|
|
1438
1546
|
|
|
1439
|
-
|
|
1547
|
+
interface Dict {
|
|
1548
|
+
[k: string]: unknown
|
|
1549
|
+
}
|
|
1440
1550
|
|
|
1441
1551
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
1442
1552
|
(props: JsxHTMLProps<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
1443
1553
|
displayName?: string
|
|
1444
1554
|
}
|
|
1445
1555
|
|
|
1446
|
-
interface RecipeFn {
|
|
1556
|
+
interface RecipeFn {
|
|
1557
|
+
__type: any
|
|
1558
|
+
}
|
|
1447
1559
|
|
|
1448
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1560
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
1449
1561
|
dataAttr?: boolean
|
|
1450
1562
|
defaultProps?: TProps
|
|
1451
1563
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
1452
1564
|
}
|
|
1453
1565
|
|
|
1454
|
-
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P
|
|
1566
|
+
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>
|
|
1567
|
+
|
|
1568
|
+
export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
|
|
1569
|
+
? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
|
|
1570
|
+
: ${componentName}<T, P>
|
|
1455
1571
|
|
|
1456
|
-
interface JsxFactory {
|
|
1572
|
+
export interface JsxFactory {
|
|
1457
1573
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1458
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>):
|
|
1574
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
|
|
1459
1575
|
T,
|
|
1460
1576
|
RecipeSelection<P>
|
|
1461
1577
|
>
|
|
1462
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>):
|
|
1578
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
|
|
1463
1579
|
}
|
|
1464
1580
|
|
|
1465
|
-
type JsxElements = {
|
|
1581
|
+
export type JsxElements = {
|
|
1582
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
1583
|
+
}
|
|
1466
1584
|
|
|
1467
1585
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1468
1586
|
|
|
1469
1587
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1588
|
+
|
|
1589
|
+
export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
|
|
1470
1590
|
`
|
|
1471
1591
|
};
|
|
1472
1592
|
}
|
|
1473
1593
|
|
|
1474
1594
|
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1475
|
-
var
|
|
1595
|
+
var import_outdent18 = require("outdent");
|
|
1476
1596
|
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1477
1597
|
const { factoryName, componentName } = ctx.jsx;
|
|
1478
1598
|
return {
|
|
1479
|
-
js:
|
|
1599
|
+
js: import_outdent18.outdent`
|
|
1480
1600
|
import { h } from 'preact'
|
|
1481
1601
|
import { forwardRef } from 'preact/compat'
|
|
1602
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
1482
1603
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1483
1604
|
|
|
1484
1605
|
function createStyledFn(Dynamic) {
|
|
1485
1606
|
return function styledFn(template) {
|
|
1486
|
-
const
|
|
1607
|
+
const styles = css.raw(template)
|
|
1608
|
+
|
|
1487
1609
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1488
|
-
const { as: Element = Dynamic, ...elementProps } = props
|
|
1489
|
-
|
|
1610
|
+
const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
|
|
1611
|
+
|
|
1612
|
+
function classes() {
|
|
1613
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
1614
|
+
}
|
|
1490
1615
|
|
|
1491
1616
|
return h(Element, {
|
|
1492
1617
|
ref,
|
|
@@ -1495,8 +1620,12 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1495
1620
|
})
|
|
1496
1621
|
})
|
|
1497
1622
|
|
|
1498
|
-
const name = (
|
|
1623
|
+
const name = getDisplayName(Dynamic)
|
|
1624
|
+
|
|
1499
1625
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1626
|
+
${componentName}.__styles__ = styles
|
|
1627
|
+
${componentName}.__base__ = Dynamic
|
|
1628
|
+
|
|
1500
1629
|
return ${componentName}
|
|
1501
1630
|
}
|
|
1502
1631
|
}
|
|
@@ -1523,31 +1652,35 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1523
1652
|
}
|
|
1524
1653
|
|
|
1525
1654
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1526
|
-
var
|
|
1655
|
+
var import_outdent19 = require("outdent");
|
|
1527
1656
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1528
1657
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1529
1658
|
return {
|
|
1530
|
-
jsxFactory:
|
|
1659
|
+
jsxFactory: import_outdent19.outdent`
|
|
1531
1660
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1532
1661
|
export declare const ${factoryName}: ${upperName}
|
|
1533
1662
|
`,
|
|
1534
|
-
jsxType:
|
|
1663
|
+
jsxType: import_outdent19.outdent`
|
|
1535
1664
|
import type { ComponentProps, JSX } from 'preact'
|
|
1536
1665
|
|
|
1537
|
-
type ElementType =
|
|
1666
|
+
export type ElementType = JSX.ElementType
|
|
1538
1667
|
|
|
1539
|
-
|
|
1668
|
+
interface Dict {
|
|
1669
|
+
[k: string]: unknown
|
|
1670
|
+
}
|
|
1540
1671
|
|
|
1541
1672
|
export type ${componentName}<T extends ElementType> = {
|
|
1542
1673
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1543
1674
|
displayName?: string
|
|
1544
1675
|
}
|
|
1545
1676
|
|
|
1546
|
-
interface JsxFactory {
|
|
1677
|
+
export interface JsxFactory {
|
|
1547
1678
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1548
1679
|
}
|
|
1549
1680
|
|
|
1550
|
-
type JsxElements = {
|
|
1681
|
+
export type JsxElements = {
|
|
1682
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
1683
|
+
}
|
|
1551
1684
|
|
|
1552
1685
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1553
1686
|
|
|
@@ -1557,18 +1690,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1557
1690
|
}
|
|
1558
1691
|
|
|
1559
1692
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1560
|
-
var
|
|
1693
|
+
var import_outdent20 = require("outdent");
|
|
1561
1694
|
function generateQwikJsxFactory(ctx) {
|
|
1562
1695
|
const { factoryName, componentName } = ctx.jsx;
|
|
1563
1696
|
return {
|
|
1564
|
-
js:
|
|
1697
|
+
js: import_outdent20.outdent`
|
|
1565
1698
|
import { h } from '@builder.io/qwik'
|
|
1699
|
+
${ctx.file.import(
|
|
1700
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
1701
|
+
"./factory-helper"
|
|
1702
|
+
)}
|
|
1703
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1566
1704
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1567
1705
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1568
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1569
1706
|
|
|
1570
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1571
|
-
|
|
1572
1707
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1573
1708
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1574
1709
|
|
|
@@ -1581,22 +1716,25 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1581
1716
|
)
|
|
1582
1717
|
|
|
1583
1718
|
const ${componentName} = function ${componentName}(props) {
|
|
1584
|
-
const { as: Element = Dynamic, children, className, ...restProps } = props
|
|
1719
|
+
const { as: Element = Dynamic.__base__ || Dynamic, children, className, ...restProps } = props
|
|
1720
|
+
|
|
1721
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
1722
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
1585
1723
|
|
|
1586
1724
|
const combinedProps = Object.assign({}, defaultProps, restProps)
|
|
1587
1725
|
|
|
1588
1726
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
|
|
1589
|
-
splitProps(combinedProps,
|
|
1590
|
-
|
|
1591
|
-
const { css: cssStyles, ...propStyles } = styleProps
|
|
1727
|
+
splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1592
1728
|
|
|
1593
1729
|
function recipeClass() {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1730
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1731
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
1732
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1596
1733
|
}
|
|
1597
|
-
|
|
1734
|
+
|
|
1598
1735
|
function cvaClass() {
|
|
1599
|
-
const
|
|
1736
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1737
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1600
1738
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1601
1739
|
}
|
|
1602
1740
|
|
|
@@ -1611,8 +1749,13 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1611
1749
|
})
|
|
1612
1750
|
}
|
|
1613
1751
|
|
|
1614
|
-
const name = (
|
|
1752
|
+
const name = getDisplayName(Dynamic)
|
|
1753
|
+
|
|
1615
1754
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1755
|
+
${componentName}.__cva__ = cvaFn
|
|
1756
|
+
${componentName}.__base__ = Dynamic
|
|
1757
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
1758
|
+
|
|
1616
1759
|
return ${componentName}
|
|
1617
1760
|
}
|
|
1618
1761
|
|
|
@@ -1639,8 +1782,8 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1639
1782
|
}
|
|
1640
1783
|
|
|
1641
1784
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1642
|
-
var
|
|
1643
|
-
var
|
|
1785
|
+
var import_outdent21 = require("outdent");
|
|
1786
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
1644
1787
|
function generateQwikJsxPattern(ctx) {
|
|
1645
1788
|
const { typeName, factoryName } = ctx.jsx;
|
|
1646
1789
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1648,20 +1791,20 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1648
1791
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1649
1792
|
return {
|
|
1650
1793
|
name: dashName,
|
|
1651
|
-
js:
|
|
1794
|
+
js: import_outdent21.outdent`
|
|
1652
1795
|
import { h } from '@builder.io/qwik'
|
|
1653
1796
|
${ctx.file.import(factoryName, "./factory")}
|
|
1654
1797
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1655
1798
|
|
|
1656
1799
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1657
|
-
${(0,
|
|
1800
|
+
${(0, import_ts_pattern6.match)(props.length).with(
|
|
1658
1801
|
0,
|
|
1659
|
-
() =>
|
|
1802
|
+
() => import_outdent21.outdent`
|
|
1660
1803
|
const styleProps = ${styleFnName}()
|
|
1661
1804
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1662
1805
|
`
|
|
1663
1806
|
).otherwise(
|
|
1664
|
-
() =>
|
|
1807
|
+
() => import_outdent21.outdent`
|
|
1665
1808
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1666
1809
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1667
1810
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1669,7 +1812,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1669
1812
|
)}
|
|
1670
1813
|
}
|
|
1671
1814
|
`,
|
|
1672
|
-
dts:
|
|
1815
|
+
dts: import_outdent21.outdent`
|
|
1673
1816
|
import type { Component } from '@builder.io/qwik'
|
|
1674
1817
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1675
1818
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -1685,20 +1828,23 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1685
1828
|
}
|
|
1686
1829
|
|
|
1687
1830
|
// src/artifacts/qwik-jsx/types.ts
|
|
1688
|
-
var
|
|
1831
|
+
var import_outdent22 = require("outdent");
|
|
1689
1832
|
function generateQwikJsxTypes(ctx) {
|
|
1690
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1833
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1691
1834
|
return {
|
|
1692
|
-
jsxFactory:
|
|
1835
|
+
jsxFactory: import_outdent22.outdent`
|
|
1693
1836
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1694
1837
|
export declare const ${factoryName}: ${upperName}
|
|
1695
1838
|
`,
|
|
1696
|
-
jsxType:
|
|
1839
|
+
jsxType: import_outdent22.outdent`
|
|
1697
1840
|
import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1698
|
-
|
|
1699
|
-
|
|
1841
|
+
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
1842
|
+
${ctx.file.importType(
|
|
1843
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxStyleProps, PatchedHTMLProps, Pretty",
|
|
1844
|
+
"./system-types"
|
|
1845
|
+
)}
|
|
1700
1846
|
|
|
1701
|
-
type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1847
|
+
export type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1702
1848
|
|
|
1703
1849
|
export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1704
1850
|
? QwikIntrinsicElements[T]
|
|
@@ -1706,13 +1852,17 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
|
|
|
1706
1852
|
? P
|
|
1707
1853
|
: never
|
|
1708
1854
|
|
|
1709
|
-
|
|
1855
|
+
interface Dict {
|
|
1856
|
+
[k: string]: unknown
|
|
1857
|
+
}
|
|
1710
1858
|
|
|
1711
1859
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T>, Assign<PatchedHTMLProps, Assign<JsxStyleProps, P>>>> {}
|
|
1712
1860
|
|
|
1713
|
-
interface RecipeFn {
|
|
1861
|
+
interface RecipeFn {
|
|
1862
|
+
__type: any
|
|
1863
|
+
}
|
|
1714
1864
|
|
|
1715
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1865
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
1716
1866
|
dataAttr?: boolean
|
|
1717
1867
|
defaultProps?: TProps
|
|
1718
1868
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -1720,48 +1870,65 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
1720
1870
|
|
|
1721
1871
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1722
1872
|
|
|
1723
|
-
|
|
1873
|
+
export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
|
|
1874
|
+
? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
|
|
1875
|
+
: ${componentName}<T, P>
|
|
1876
|
+
|
|
1877
|
+
export interface JsxFactory {
|
|
1724
1878
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1725
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>):
|
|
1879
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
|
|
1726
1880
|
T,
|
|
1727
1881
|
RecipeSelection<P>
|
|
1728
1882
|
>
|
|
1729
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>):
|
|
1883
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
|
|
1730
1884
|
}
|
|
1731
1885
|
|
|
1732
|
-
type JsxElements = {
|
|
1886
|
+
export type JsxElements = {
|
|
1887
|
+
[K in keyof QwikIntrinsicElements]: ${componentName}<K, {}>
|
|
1888
|
+
}
|
|
1733
1889
|
|
|
1734
1890
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1735
1891
|
|
|
1736
1892
|
export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxStyleProps>
|
|
1893
|
+
|
|
1894
|
+
export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
|
|
1737
1895
|
`
|
|
1738
1896
|
};
|
|
1739
1897
|
}
|
|
1740
1898
|
|
|
1741
1899
|
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1742
|
-
var
|
|
1900
|
+
var import_outdent23 = require("outdent");
|
|
1743
1901
|
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1744
1902
|
const { factoryName, componentName } = ctx.jsx;
|
|
1745
1903
|
return {
|
|
1746
|
-
js:
|
|
1904
|
+
js: import_outdent23.outdent`
|
|
1747
1905
|
import { h } from '@builder.io/qwik'
|
|
1906
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
1748
1907
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1749
1908
|
|
|
1750
1909
|
function createStyledFn(Dynamic) {
|
|
1751
1910
|
return function styledFn(template) {
|
|
1752
|
-
const
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1911
|
+
const styles = css.raw(template)
|
|
1912
|
+
|
|
1913
|
+
const ${componentName} = (props) => {
|
|
1914
|
+
const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
|
|
1915
|
+
|
|
1916
|
+
function classes() {
|
|
1917
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
return h(Element, {
|
|
1921
|
+
...elementProps,
|
|
1922
|
+
className: classes(),
|
|
1923
|
+
})
|
|
1761
1924
|
}
|
|
1762
1925
|
|
|
1763
|
-
const name = (
|
|
1926
|
+
const name = getDisplayName(Dynamic)
|
|
1927
|
+
|
|
1764
1928
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1929
|
+
${componentName}.__styles__ = styles
|
|
1930
|
+
${componentName}.__base__ = Dynamic
|
|
1931
|
+
|
|
1765
1932
|
return ${componentName}
|
|
1766
1933
|
}
|
|
1767
1934
|
}
|
|
@@ -1789,18 +1956,18 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1789
1956
|
}
|
|
1790
1957
|
|
|
1791
1958
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1792
|
-
var
|
|
1959
|
+
var import_outdent24 = require("outdent");
|
|
1793
1960
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1794
1961
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1795
1962
|
return {
|
|
1796
|
-
jsxFactory:
|
|
1963
|
+
jsxFactory: import_outdent24.outdent`
|
|
1797
1964
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1798
1965
|
export declare const ${factoryName}: ${upperName}
|
|
1799
1966
|
`,
|
|
1800
|
-
jsxType:
|
|
1967
|
+
jsxType: import_outdent24.outdent`
|
|
1801
1968
|
import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1802
1969
|
|
|
1803
|
-
type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1970
|
+
export type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1804
1971
|
|
|
1805
1972
|
export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1806
1973
|
? QwikIntrinsicElements[T]
|
|
@@ -1808,17 +1975,21 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
|
|
|
1808
1975
|
? P
|
|
1809
1976
|
: never
|
|
1810
1977
|
|
|
1811
|
-
|
|
1978
|
+
interface Dict {
|
|
1979
|
+
[k: string]: unknown
|
|
1980
|
+
}
|
|
1812
1981
|
|
|
1813
1982
|
export type ${componentName}<T extends ElementType> = {
|
|
1814
1983
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1815
1984
|
}
|
|
1816
1985
|
|
|
1817
|
-
interface JsxFactory {
|
|
1986
|
+
export interface JsxFactory {
|
|
1818
1987
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1819
1988
|
}
|
|
1820
1989
|
|
|
1821
|
-
type JsxElements = {
|
|
1990
|
+
export type JsxElements = {
|
|
1991
|
+
[K in keyof QwikIntrinsicElements]: ${componentName}<K>
|
|
1992
|
+
}
|
|
1822
1993
|
|
|
1823
1994
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1824
1995
|
|
|
@@ -1828,18 +1999,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1828
1999
|
}
|
|
1829
2000
|
|
|
1830
2001
|
// src/artifacts/react-jsx/jsx.ts
|
|
1831
|
-
var
|
|
2002
|
+
var import_outdent25 = require("outdent");
|
|
1832
2003
|
function generateReactJsxFactory(ctx) {
|
|
1833
2004
|
const { factoryName, componentName } = ctx.jsx;
|
|
1834
2005
|
return {
|
|
1835
|
-
js:
|
|
2006
|
+
js: import_outdent25.outdent`
|
|
1836
2007
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1837
2008
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2009
|
+
${ctx.file.import(
|
|
2010
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
2011
|
+
"./factory-helper"
|
|
2012
|
+
)}
|
|
1838
2013
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1839
2014
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1840
2015
|
|
|
1841
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1842
|
-
|
|
1843
2016
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1844
2017
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1845
2018
|
|
|
@@ -1852,23 +2025,26 @@ function generateReactJsxFactory(ctx) {
|
|
|
1852
2025
|
)
|
|
1853
2026
|
|
|
1854
2027
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1855
|
-
const { as: Element = Dynamic, children, ...restProps } = props
|
|
2028
|
+
const { as: Element = Dynamic.__base__ || Dynamic, children, ...restProps } = props
|
|
2029
|
+
|
|
2030
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
2031
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
1856
2032
|
|
|
1857
2033
|
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1858
2034
|
|
|
1859
2035
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1860
|
-
return splitProps(combinedProps,
|
|
2036
|
+
return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1861
2037
|
}, [combinedProps])
|
|
1862
2038
|
|
|
1863
2039
|
function recipeClass() {
|
|
1864
2040
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1865
|
-
const compoundVariantStyles =
|
|
1866
|
-
return cx(
|
|
2041
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
|
|
2042
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
|
|
1867
2043
|
}
|
|
1868
2044
|
|
|
1869
2045
|
function cvaClass() {
|
|
1870
2046
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1871
|
-
const cvaStyles =
|
|
2047
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1872
2048
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
|
|
1873
2049
|
}
|
|
1874
2050
|
|
|
@@ -1884,8 +2060,13 @@ function generateReactJsxFactory(ctx) {
|
|
|
1884
2060
|
})
|
|
1885
2061
|
})
|
|
1886
2062
|
|
|
1887
|
-
const name = (
|
|
2063
|
+
const name = getDisplayName(Dynamic)
|
|
2064
|
+
|
|
1888
2065
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2066
|
+
${componentName}.__cva__ = cvaFn
|
|
2067
|
+
${componentName}.__base__ = Dynamic
|
|
2068
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
2069
|
+
|
|
1889
2070
|
return ${componentName}
|
|
1890
2071
|
}
|
|
1891
2072
|
|
|
@@ -1912,8 +2093,8 @@ function generateReactJsxFactory(ctx) {
|
|
|
1912
2093
|
}
|
|
1913
2094
|
|
|
1914
2095
|
// src/artifacts/react-jsx/pattern.ts
|
|
1915
|
-
var
|
|
1916
|
-
var
|
|
2096
|
+
var import_outdent26 = require("outdent");
|
|
2097
|
+
var import_ts_pattern7 = require("ts-pattern");
|
|
1917
2098
|
function generateReactJsxPattern(ctx) {
|
|
1918
2099
|
const { typeName, factoryName } = ctx.jsx;
|
|
1919
2100
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1921,20 +2102,20 @@ function generateReactJsxPattern(ctx) {
|
|
|
1921
2102
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1922
2103
|
return {
|
|
1923
2104
|
name: dashName,
|
|
1924
|
-
js:
|
|
2105
|
+
js: import_outdent26.outdent`
|
|
1925
2106
|
import { createElement, forwardRef } from 'react'
|
|
1926
2107
|
${ctx.file.import(factoryName, "./factory")}
|
|
1927
2108
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1928
2109
|
|
|
1929
2110
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1930
|
-
${(0,
|
|
2111
|
+
${(0, import_ts_pattern7.match)(props.length).with(
|
|
1931
2112
|
0,
|
|
1932
|
-
() =>
|
|
2113
|
+
() => import_outdent26.outdent`
|
|
1933
2114
|
const styleProps = ${styleFnName}()
|
|
1934
2115
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1935
2116
|
`
|
|
1936
2117
|
).otherwise(
|
|
1937
|
-
() =>
|
|
2118
|
+
() => import_outdent26.outdent`
|
|
1938
2119
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1939
2120
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1940
2121
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1942,7 +2123,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1942
2123
|
)}
|
|
1943
2124
|
})
|
|
1944
2125
|
`,
|
|
1945
|
-
dts:
|
|
2126
|
+
dts: import_outdent26.outdent`
|
|
1946
2127
|
import type { FunctionComponent } from 'react'
|
|
1947
2128
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1948
2129
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -1958,20 +2139,25 @@ function generateReactJsxPattern(ctx) {
|
|
|
1958
2139
|
}
|
|
1959
2140
|
|
|
1960
2141
|
// src/artifacts/react-jsx/types.ts
|
|
1961
|
-
var
|
|
2142
|
+
var import_outdent27 = require("outdent");
|
|
1962
2143
|
function generateReactJsxTypes(ctx) {
|
|
1963
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2144
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1964
2145
|
return {
|
|
1965
|
-
jsxFactory:
|
|
2146
|
+
jsxFactory: import_outdent27.outdent`
|
|
1966
2147
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1967
2148
|
export declare const ${factoryName}: ${upperName}
|
|
1968
2149
|
`,
|
|
1969
|
-
jsxType:
|
|
2150
|
+
jsxType: import_outdent27.outdent`
|
|
1970
2151
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1971
|
-
${ctx.file.importType("Assign, DistributiveOmit, JsxHTMLProps, JsxStyleProps", "./system-types")}
|
|
1972
2152
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2153
|
+
${ctx.file.importType(
|
|
2154
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
2155
|
+
"./system-types"
|
|
2156
|
+
)}
|
|
1973
2157
|
|
|
1974
|
-
|
|
2158
|
+
interface Dict {
|
|
2159
|
+
[k: string]: unknown
|
|
2160
|
+
}
|
|
1975
2161
|
|
|
1976
2162
|
export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
|
|
1977
2163
|
ref?: Ref<ElementRef<T>>
|
|
@@ -1982,7 +2168,9 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1982
2168
|
displayName?: string
|
|
1983
2169
|
}
|
|
1984
2170
|
|
|
1985
|
-
interface RecipeFn {
|
|
2171
|
+
interface RecipeFn {
|
|
2172
|
+
__type: any
|
|
2173
|
+
}
|
|
1986
2174
|
|
|
1987
2175
|
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1988
2176
|
dataAttr?: boolean
|
|
@@ -1992,49 +2180,66 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
1992
2180
|
|
|
1993
2181
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1994
2182
|
|
|
1995
|
-
|
|
2183
|
+
export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
|
|
2184
|
+
? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
|
|
2185
|
+
: ${componentName}<T, P>
|
|
2186
|
+
|
|
2187
|
+
export interface JsxFactory {
|
|
1996
2188
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1997
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>):
|
|
2189
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
|
|
1998
2190
|
T,
|
|
1999
2191
|
RecipeSelection<P>
|
|
2000
2192
|
>
|
|
2001
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>):
|
|
2193
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
|
|
2002
2194
|
}
|
|
2003
2195
|
|
|
2004
|
-
type JsxElements = {
|
|
2196
|
+
export type JsxElements = {
|
|
2197
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
2198
|
+
}
|
|
2005
2199
|
|
|
2006
2200
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2007
2201
|
|
|
2008
2202
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2203
|
+
|
|
2204
|
+
export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
|
|
2009
2205
|
`
|
|
2010
2206
|
};
|
|
2011
2207
|
}
|
|
2012
2208
|
|
|
2013
2209
|
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
2014
|
-
var
|
|
2210
|
+
var import_outdent28 = require("outdent");
|
|
2015
2211
|
function generateReactJsxStringLiteralFactory(ctx) {
|
|
2016
2212
|
const { factoryName, componentName } = ctx.jsx;
|
|
2017
2213
|
return {
|
|
2018
|
-
js:
|
|
2214
|
+
js: import_outdent28.outdent`
|
|
2019
2215
|
import { createElement, forwardRef } from 'react'
|
|
2216
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2020
2217
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2021
2218
|
|
|
2022
2219
|
function createStyledFn(Dynamic) {
|
|
2023
2220
|
return function styledFn(template) {
|
|
2024
|
-
const
|
|
2221
|
+
const styles = css.raw(template)
|
|
2222
|
+
|
|
2025
2223
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
2026
|
-
|
|
2027
|
-
|
|
2224
|
+
const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
|
|
2225
|
+
|
|
2226
|
+
function classes() {
|
|
2227
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
2228
|
+
}
|
|
2028
2229
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2230
|
+
return createElement(Element, {
|
|
2231
|
+
ref,
|
|
2232
|
+
...elementProps,
|
|
2233
|
+
className: classes(),
|
|
2234
|
+
})
|
|
2034
2235
|
})
|
|
2035
2236
|
|
|
2036
|
-
const name = (
|
|
2237
|
+
const name = getDisplayName(Dynamic)
|
|
2238
|
+
|
|
2037
2239
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2240
|
+
${componentName}.__styles__ = styles
|
|
2241
|
+
${componentName}.__base__ = Dynamic
|
|
2242
|
+
|
|
2038
2243
|
return ${componentName}
|
|
2039
2244
|
}
|
|
2040
2245
|
}
|
|
@@ -2062,19 +2267,21 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
2062
2267
|
}
|
|
2063
2268
|
|
|
2064
2269
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
2065
|
-
var
|
|
2270
|
+
var import_outdent29 = require("outdent");
|
|
2066
2271
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
2067
2272
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2068
2273
|
return {
|
|
2069
|
-
jsxFactory:
|
|
2274
|
+
jsxFactory: import_outdent29.outdent`
|
|
2070
2275
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2071
2276
|
export declare const ${factoryName}: ${upperName}
|
|
2072
2277
|
`,
|
|
2073
|
-
jsxType:
|
|
2278
|
+
jsxType: import_outdent29.outdent`
|
|
2074
2279
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
2075
2280
|
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
2076
2281
|
|
|
2077
|
-
|
|
2282
|
+
interface Dict {
|
|
2283
|
+
[k: string]: unknown
|
|
2284
|
+
}
|
|
2078
2285
|
|
|
2079
2286
|
export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
|
|
2080
2287
|
ref?: Ref<ElementRef<T>>
|
|
@@ -2085,11 +2292,13 @@ export type ${componentName}<T extends ElementType> = {
|
|
|
2085
2292
|
displayName?: string
|
|
2086
2293
|
}
|
|
2087
2294
|
|
|
2088
|
-
interface JsxFactory {
|
|
2295
|
+
export interface JsxFactory {
|
|
2089
2296
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2090
2297
|
}
|
|
2091
2298
|
|
|
2092
|
-
type JsxElements = {
|
|
2299
|
+
export type JsxElements = {
|
|
2300
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
2301
|
+
}
|
|
2093
2302
|
|
|
2094
2303
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2095
2304
|
|
|
@@ -2099,19 +2308,21 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2099
2308
|
}
|
|
2100
2309
|
|
|
2101
2310
|
// src/artifacts/solid-jsx/jsx.ts
|
|
2102
|
-
var
|
|
2311
|
+
var import_outdent30 = require("outdent");
|
|
2103
2312
|
function generateSolidJsxFactory(ctx) {
|
|
2104
2313
|
const { componentName, factoryName } = ctx.jsx;
|
|
2105
2314
|
return {
|
|
2106
|
-
js:
|
|
2315
|
+
js: import_outdent30.outdent`
|
|
2107
2316
|
import { Dynamic } from 'solid-js/web'
|
|
2108
2317
|
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2109
2318
|
import { createComponent } from 'solid-js/web'
|
|
2319
|
+
${ctx.file.import(
|
|
2320
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
2321
|
+
"./factory-helper"
|
|
2322
|
+
)}
|
|
2323
|
+
${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
|
|
2110
2324
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2111
2325
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
2112
|
-
${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
|
|
2113
|
-
|
|
2114
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2115
2326
|
|
|
2116
2327
|
function styledFn(element, configOrCva = {}, options = {}) {
|
|
2117
2328
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
@@ -2124,28 +2335,32 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2124
2335
|
options.defaultProps,
|
|
2125
2336
|
)
|
|
2126
2337
|
|
|
2127
|
-
|
|
2128
|
-
const mergedProps = mergeProps({ as: element }, defaultProps, props)
|
|
2338
|
+
const ${componentName} = (props) => {
|
|
2339
|
+
const mergedProps = mergeProps({ as: element.__base__ || element }, defaultProps, props)
|
|
2340
|
+
|
|
2341
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
2342
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
2343
|
+
|
|
2129
2344
|
const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
|
|
2130
2345
|
|
|
2131
2346
|
const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2132
2347
|
mergedProps,
|
|
2133
2348
|
['as', 'class', 'className'],
|
|
2134
2349
|
forwardedKeys(),
|
|
2135
|
-
|
|
2350
|
+
__cvaFn__.variantKeys,
|
|
2136
2351
|
allCssProperties,
|
|
2137
2352
|
normalizeHTMLProps.keys
|
|
2138
2353
|
)
|
|
2139
2354
|
|
|
2140
2355
|
function recipeClass() {
|
|
2141
2356
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2142
|
-
const compoundVariantStyles =
|
|
2143
|
-
return cx(
|
|
2357
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
2358
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2144
2359
|
}
|
|
2145
2360
|
|
|
2146
2361
|
function cvaClass() {
|
|
2147
2362
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2148
|
-
const cvaStyles =
|
|
2363
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
2149
2364
|
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2150
2365
|
}
|
|
2151
2366
|
|
|
@@ -2172,6 +2387,15 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2172
2387
|
)
|
|
2173
2388
|
)
|
|
2174
2389
|
}
|
|
2390
|
+
|
|
2391
|
+
const name = getDisplayName(element)
|
|
2392
|
+
|
|
2393
|
+
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2394
|
+
${componentName}.__cva__ = cvaFn
|
|
2395
|
+
${componentName}.__base__ = element
|
|
2396
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
2397
|
+
|
|
2398
|
+
return ${componentName}
|
|
2175
2399
|
}
|
|
2176
2400
|
|
|
2177
2401
|
function createJsxFactory() {
|
|
@@ -2196,8 +2420,8 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2196
2420
|
}
|
|
2197
2421
|
|
|
2198
2422
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
2423
|
+
var import_outdent31 = require("outdent");
|
|
2424
|
+
var import_ts_pattern8 = require("ts-pattern");
|
|
2201
2425
|
function generateSolidJsxPattern(ctx) {
|
|
2202
2426
|
const { typeName, factoryName } = ctx.jsx;
|
|
2203
2427
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2205,21 +2429,21 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2205
2429
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2206
2430
|
return {
|
|
2207
2431
|
name: dashName,
|
|
2208
|
-
js:
|
|
2432
|
+
js: import_outdent31.outdent`
|
|
2209
2433
|
import { splitProps, mergeProps } from 'solid-js'
|
|
2210
2434
|
import { createComponent } from 'solid-js/web'
|
|
2211
2435
|
${ctx.file.import(factoryName, "./factory")}
|
|
2212
2436
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2213
2437
|
|
|
2214
2438
|
export function ${jsxName}(props) {
|
|
2215
|
-
${(0,
|
|
2439
|
+
${(0, import_ts_pattern8.match)(props.length).with(
|
|
2216
2440
|
0,
|
|
2217
|
-
() =>
|
|
2441
|
+
() => import_outdent31.outdent`
|
|
2218
2442
|
const styleProps = ${styleFnName}()
|
|
2219
2443
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
2220
2444
|
`
|
|
2221
2445
|
).otherwise(
|
|
2222
|
-
() =>
|
|
2446
|
+
() => import_outdent31.outdent`
|
|
2223
2447
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
2224
2448
|
const styleProps = ${styleFnName}(patternProps)
|
|
2225
2449
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -2227,7 +2451,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2227
2451
|
)}
|
|
2228
2452
|
}
|
|
2229
2453
|
`,
|
|
2230
|
-
dts:
|
|
2454
|
+
dts: import_outdent31.outdent`
|
|
2231
2455
|
import type { Component } from 'solid-js'
|
|
2232
2456
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
2233
2457
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -2243,31 +2467,38 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2243
2467
|
}
|
|
2244
2468
|
|
|
2245
2469
|
// src/artifacts/solid-jsx/types.ts
|
|
2246
|
-
var
|
|
2470
|
+
var import_outdent32 = require("outdent");
|
|
2247
2471
|
function generateSolidJsxTypes(ctx) {
|
|
2248
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2472
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
2249
2473
|
return {
|
|
2250
|
-
jsxFactory:
|
|
2474
|
+
jsxFactory: import_outdent32.outdent`
|
|
2251
2475
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2252
2476
|
export declare const ${factoryName}: ${upperName}
|
|
2253
2477
|
`,
|
|
2254
|
-
jsxType:
|
|
2478
|
+
jsxType: import_outdent32.outdent`
|
|
2255
2479
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
2256
|
-
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
2257
2480
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2481
|
+
${ctx.file.importType(
|
|
2482
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
2483
|
+
"./system-types"
|
|
2484
|
+
)}
|
|
2258
2485
|
|
|
2259
|
-
|
|
2486
|
+
interface Dict {
|
|
2487
|
+
[k: string]: unknown
|
|
2488
|
+
}
|
|
2260
2489
|
|
|
2261
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2490
|
+
export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2262
2491
|
|
|
2263
2492
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
2264
2493
|
(props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
|
|
2265
2494
|
displayName?: string
|
|
2266
2495
|
}
|
|
2267
2496
|
|
|
2268
|
-
interface RecipeFn {
|
|
2497
|
+
interface RecipeFn {
|
|
2498
|
+
__type: any
|
|
2499
|
+
}
|
|
2269
2500
|
|
|
2270
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2501
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
2271
2502
|
dataAttr?: boolean
|
|
2272
2503
|
defaultProps?: TProps
|
|
2273
2504
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -2275,41 +2506,51 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
2275
2506
|
|
|
2276
2507
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
2277
2508
|
|
|
2278
|
-
|
|
2509
|
+
export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
|
|
2510
|
+
? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
|
|
2511
|
+
: ${componentName}<T, P>
|
|
2512
|
+
|
|
2513
|
+
export interface JsxFactory {
|
|
2279
2514
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2280
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>):
|
|
2515
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
|
|
2281
2516
|
T,
|
|
2282
2517
|
RecipeSelection<P>
|
|
2283
2518
|
>
|
|
2284
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>):
|
|
2519
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
|
|
2285
2520
|
}
|
|
2286
2521
|
|
|
2287
|
-
type JsxElements = {
|
|
2522
|
+
export type JsxElements = {
|
|
2523
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
2524
|
+
}
|
|
2288
2525
|
|
|
2289
2526
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2290
2527
|
|
|
2291
2528
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2529
|
+
|
|
2530
|
+
export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
|
|
2292
2531
|
`
|
|
2293
2532
|
};
|
|
2294
2533
|
}
|
|
2295
2534
|
|
|
2296
2535
|
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
2297
|
-
var
|
|
2536
|
+
var import_outdent33 = require("outdent");
|
|
2298
2537
|
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
2299
2538
|
const { componentName, factoryName } = ctx.jsx;
|
|
2300
2539
|
return {
|
|
2301
|
-
js:
|
|
2540
|
+
js: import_outdent33.outdent`
|
|
2302
2541
|
import { mergeProps, splitProps } from 'solid-js'
|
|
2303
2542
|
import { Dynamic, createComponent } from 'solid-js/web'
|
|
2543
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2304
2544
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2305
2545
|
|
|
2306
2546
|
function createStyled(element) {
|
|
2307
2547
|
return function styledFn(template) {
|
|
2308
|
-
const
|
|
2309
|
-
return function ${componentName}(props) {
|
|
2310
|
-
const mergedProps = mergeProps({ as: element }, props)
|
|
2311
|
-
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2548
|
+
const styles = css.raw(template)
|
|
2312
2549
|
|
|
2550
|
+
const ${componentName} = (props) => {
|
|
2551
|
+
const mergedProps = mergeProps({ as: element.__base__ || element }, props)
|
|
2552
|
+
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2553
|
+
|
|
2313
2554
|
return createComponent(
|
|
2314
2555
|
Dynamic,
|
|
2315
2556
|
mergeProps(
|
|
@@ -2318,13 +2559,21 @@ function createStyled(element) {
|
|
|
2318
2559
|
return localProps.as
|
|
2319
2560
|
},
|
|
2320
2561
|
get class() {
|
|
2321
|
-
return cx(
|
|
2562
|
+
return cx(css(element.__styles__, styles), localProps.class)
|
|
2322
2563
|
},
|
|
2323
2564
|
},
|
|
2324
2565
|
elementProps,
|
|
2325
2566
|
),
|
|
2326
2567
|
)
|
|
2327
2568
|
}
|
|
2569
|
+
|
|
2570
|
+
const name = getDisplayName(element)
|
|
2571
|
+
|
|
2572
|
+
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2573
|
+
${componentName}.__styles__ = styles
|
|
2574
|
+
${componentName}.__base__ = element
|
|
2575
|
+
|
|
2576
|
+
return ${componentName}
|
|
2328
2577
|
}
|
|
2329
2578
|
}
|
|
2330
2579
|
|
|
@@ -2350,31 +2599,35 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
|
2350
2599
|
}
|
|
2351
2600
|
|
|
2352
2601
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2353
|
-
var
|
|
2602
|
+
var import_outdent34 = require("outdent");
|
|
2354
2603
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2355
2604
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2356
2605
|
return {
|
|
2357
|
-
jsxFactory:
|
|
2606
|
+
jsxFactory: import_outdent34.outdent`
|
|
2358
2607
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2359
2608
|
export declare const ${factoryName}: ${upperName}
|
|
2360
2609
|
`,
|
|
2361
|
-
jsxType:
|
|
2610
|
+
jsxType: import_outdent34.outdent`
|
|
2362
2611
|
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2363
2612
|
|
|
2364
|
-
|
|
2613
|
+
interface Dict {
|
|
2614
|
+
[k: string]: unknown
|
|
2615
|
+
}
|
|
2365
2616
|
|
|
2366
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2617
|
+
export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2367
2618
|
|
|
2368
2619
|
export type ${componentName}<T extends ElementType> = {
|
|
2369
2620
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
2370
2621
|
displayName?: string
|
|
2371
2622
|
}
|
|
2372
2623
|
|
|
2373
|
-
interface JsxFactory {
|
|
2624
|
+
export interface JsxFactory {
|
|
2374
2625
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2375
2626
|
}
|
|
2376
2627
|
|
|
2377
|
-
type JsxElements = {
|
|
2628
|
+
export type JsxElements = {
|
|
2629
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
2630
|
+
}
|
|
2378
2631
|
|
|
2379
2632
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2380
2633
|
|
|
@@ -2384,18 +2637,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2384
2637
|
}
|
|
2385
2638
|
|
|
2386
2639
|
// src/artifacts/vue-jsx/jsx.ts
|
|
2387
|
-
var
|
|
2640
|
+
var import_outdent35 = require("outdent");
|
|
2388
2641
|
function generateVueJsxFactory(ctx) {
|
|
2389
|
-
const { factoryName } = ctx.jsx;
|
|
2642
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
2390
2643
|
return {
|
|
2391
|
-
js:
|
|
2644
|
+
js: import_outdent35.outdent`
|
|
2392
2645
|
import { defineComponent, h, computed } from 'vue'
|
|
2646
|
+
${ctx.file.import(
|
|
2647
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
2648
|
+
"./factory-helper"
|
|
2649
|
+
)}
|
|
2650
|
+
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2393
2651
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2394
2652
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2395
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2396
2653
|
|
|
2397
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2398
|
-
|
|
2399
2654
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
2400
2655
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2401
2656
|
|
|
@@ -2407,30 +2662,33 @@ function generateVueJsxFactory(ctx) {
|
|
|
2407
2662
|
options.defaultProps,
|
|
2408
2663
|
)
|
|
2409
2664
|
|
|
2410
|
-
const name = (
|
|
2665
|
+
const name = getDisplayName(Dynamic)
|
|
2411
2666
|
|
|
2412
|
-
|
|
2667
|
+
const ${componentName} = defineComponent({
|
|
2413
2668
|
name: \`${factoryName}.\${name}\`,
|
|
2414
2669
|
inheritAttrs: false,
|
|
2415
|
-
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2670
|
+
props: { as: { type: [String, Object], default: Dynamic.__base__ || Dynamic } },
|
|
2416
2671
|
setup(props, { slots, attrs }) {
|
|
2672
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
2673
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
2674
|
+
|
|
2417
2675
|
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2418
2676
|
|
|
2419
2677
|
const splittedProps = computed(() => {
|
|
2420
|
-
return splitProps(combinedProps.value, shouldForwardProp,
|
|
2678
|
+
return splitProps(combinedProps.value, shouldForwardProp, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
2421
2679
|
})
|
|
2422
2680
|
|
|
2423
2681
|
const recipeClass = computed(() => {
|
|
2424
2682
|
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2425
2683
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2426
|
-
const compoundVariantStyles =
|
|
2427
|
-
return cx(
|
|
2684
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
2685
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2428
2686
|
})
|
|
2429
2687
|
|
|
2430
2688
|
const cvaClass = computed(() => {
|
|
2431
2689
|
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2432
2690
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2433
|
-
const cvaStyles =
|
|
2691
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
2434
2692
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2435
2693
|
})
|
|
2436
2694
|
|
|
@@ -2451,6 +2709,13 @@ function generateVueJsxFactory(ctx) {
|
|
|
2451
2709
|
}
|
|
2452
2710
|
},
|
|
2453
2711
|
})
|
|
2712
|
+
|
|
2713
|
+
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2714
|
+
${componentName}.__cva__ = cvaFn
|
|
2715
|
+
${componentName}.__base__ = Dynamic
|
|
2716
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
2717
|
+
|
|
2718
|
+
return ${componentName}
|
|
2454
2719
|
}
|
|
2455
2720
|
|
|
2456
2721
|
function createJsxFactory() {
|
|
@@ -2471,25 +2736,30 @@ function generateVueJsxFactory(ctx) {
|
|
|
2471
2736
|
}
|
|
2472
2737
|
|
|
2473
2738
|
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2474
|
-
var
|
|
2739
|
+
var import_outdent36 = require("outdent");
|
|
2475
2740
|
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2476
|
-
const { factoryName } = ctx.jsx;
|
|
2741
|
+
const { componentName, factoryName } = ctx.jsx;
|
|
2477
2742
|
return {
|
|
2478
|
-
js:
|
|
2743
|
+
js: import_outdent36.outdent`
|
|
2479
2744
|
import { defineComponent, h, computed } from 'vue'
|
|
2745
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2480
2746
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2481
2747
|
|
|
2482
2748
|
function createStyled(Dynamic) {
|
|
2483
|
-
const name = (
|
|
2749
|
+
const name = getDisplayName(Dynamic)
|
|
2484
2750
|
|
|
2485
2751
|
function styledFn(template) {
|
|
2486
|
-
const
|
|
2487
|
-
|
|
2752
|
+
const styles = css.raw(template)
|
|
2753
|
+
|
|
2754
|
+
const ${componentName} = defineComponent({
|
|
2488
2755
|
name: \`${factoryName}.\${name}\`,
|
|
2489
2756
|
inheritAttrs: false,
|
|
2490
2757
|
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2491
2758
|
setup(props, { slots, attrs }) {
|
|
2492
|
-
const classes = computed(() =>
|
|
2759
|
+
const classes = computed(() => {
|
|
2760
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
2761
|
+
})
|
|
2762
|
+
|
|
2493
2763
|
return () => {
|
|
2494
2764
|
return h(
|
|
2495
2765
|
props.as,
|
|
@@ -2502,6 +2772,11 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2502
2772
|
}
|
|
2503
2773
|
},
|
|
2504
2774
|
})
|
|
2775
|
+
|
|
2776
|
+
${componentName}.__styles__ = styles
|
|
2777
|
+
${componentName}.__base__ = element
|
|
2778
|
+
|
|
2779
|
+
return ${componentName}
|
|
2505
2780
|
}
|
|
2506
2781
|
}
|
|
2507
2782
|
|
|
@@ -2527,7 +2802,7 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2527
2802
|
}
|
|
2528
2803
|
|
|
2529
2804
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2530
|
-
var
|
|
2805
|
+
var import_outdent37 = require("outdent");
|
|
2531
2806
|
function generateVueJsxPattern(ctx) {
|
|
2532
2807
|
const { typeName, factoryName } = ctx.jsx;
|
|
2533
2808
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2536,7 +2811,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2536
2811
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2537
2812
|
return {
|
|
2538
2813
|
name: dashName,
|
|
2539
|
-
js:
|
|
2814
|
+
js: import_outdent37.outdent`
|
|
2540
2815
|
import { defineComponent, h, computed } from 'vue'
|
|
2541
2816
|
${ctx.file.import(factoryName, "./factory")}
|
|
2542
2817
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -2554,7 +2829,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2554
2829
|
}
|
|
2555
2830
|
})
|
|
2556
2831
|
`,
|
|
2557
|
-
dts:
|
|
2832
|
+
dts: import_outdent37.outdent`
|
|
2558
2833
|
import type { FunctionalComponent } from 'vue'
|
|
2559
2834
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
2560
2835
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -2570,23 +2845,27 @@ function generateVueJsxPattern(ctx) {
|
|
|
2570
2845
|
}
|
|
2571
2846
|
|
|
2572
2847
|
// src/artifacts/vue-jsx/types.ts
|
|
2573
|
-
var
|
|
2848
|
+
var import_outdent38 = require("outdent");
|
|
2574
2849
|
function generateVueJsxTypes(ctx) {
|
|
2575
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2850
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
2576
2851
|
return {
|
|
2577
|
-
jsxFactory:
|
|
2852
|
+
jsxFactory: import_outdent38.outdent`
|
|
2578
2853
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2579
2854
|
|
|
2580
2855
|
export declare const ${factoryName}: ${upperName}
|
|
2581
2856
|
`,
|
|
2582
|
-
jsxType:
|
|
2857
|
+
jsxType: import_outdent38.outdent`
|
|
2583
2858
|
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2584
2859
|
|
|
2585
2860
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2586
|
-
${ctx.file.importType(
|
|
2861
|
+
${ctx.file.importType(
|
|
2862
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
2863
|
+
"./system-types"
|
|
2864
|
+
)}
|
|
2865
|
+
|
|
2866
|
+
export type IntrinsicElement = keyof NativeElements
|
|
2587
2867
|
|
|
2588
|
-
type
|
|
2589
|
-
type ElementType = IntrinsicElement | Component
|
|
2868
|
+
export type ElementType = IntrinsicElement | Component
|
|
2590
2869
|
|
|
2591
2870
|
export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2592
2871
|
? NativeElements[T]
|
|
@@ -2594,13 +2873,15 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
|
2594
2873
|
? Props
|
|
2595
2874
|
: never
|
|
2596
2875
|
|
|
2597
|
-
|
|
2598
|
-
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2876
|
+
export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
|
|
2877
|
+
JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>
|
|
2599
2878
|
> {}
|
|
2600
2879
|
|
|
2601
|
-
interface RecipeFn {
|
|
2880
|
+
interface RecipeFn {
|
|
2881
|
+
__type: any
|
|
2882
|
+
}
|
|
2602
2883
|
|
|
2603
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2884
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
2604
2885
|
dataAttr?: boolean
|
|
2605
2886
|
defaultProps?: TProps
|
|
2606
2887
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -2608,39 +2889,48 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
2608
2889
|
|
|
2609
2890
|
export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
|
|
2610
2891
|
|
|
2611
|
-
|
|
2892
|
+
export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
|
|
2893
|
+
? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
|
|
2894
|
+
: ${componentName}<T, P>
|
|
2895
|
+
|
|
2896
|
+
export interface JsxFactory {
|
|
2612
2897
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2613
|
-
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>):
|
|
2898
|
+
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
|
|
2614
2899
|
T,
|
|
2615
2900
|
RecipeSelection<P>
|
|
2616
2901
|
>
|
|
2617
|
-
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ):
|
|
2902
|
+
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): JsxElement<T, P['__type']>
|
|
2618
2903
|
}
|
|
2619
2904
|
|
|
2620
|
-
type JsxElements = {
|
|
2905
|
+
export type JsxElements = {
|
|
2906
|
+
[K in IntrinsicElement]: ${componentName}<K, {}>
|
|
2907
|
+
}
|
|
2621
2908
|
|
|
2622
2909
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2623
2910
|
|
|
2624
2911
|
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
2912
|
+
|
|
2913
|
+
export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
|
|
2625
2914
|
`
|
|
2626
2915
|
};
|
|
2627
2916
|
}
|
|
2628
2917
|
|
|
2629
2918
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2630
|
-
var
|
|
2919
|
+
var import_outdent39 = require("outdent");
|
|
2631
2920
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2632
2921
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2633
2922
|
return {
|
|
2634
|
-
jsxFactory:
|
|
2923
|
+
jsxFactory: import_outdent39.outdent`
|
|
2635
2924
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2636
2925
|
|
|
2637
2926
|
export declare const ${factoryName}: ${upperName}
|
|
2638
2927
|
`,
|
|
2639
|
-
jsxType:
|
|
2928
|
+
jsxType: import_outdent39.outdent`
|
|
2640
2929
|
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2641
2930
|
|
|
2642
|
-
type IntrinsicElement = keyof NativeElements
|
|
2643
|
-
|
|
2931
|
+
export type IntrinsicElement = keyof NativeElements
|
|
2932
|
+
|
|
2933
|
+
export type ElementType = IntrinsicElement | Component
|
|
2644
2934
|
|
|
2645
2935
|
export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2646
2936
|
? NativeElements[T]
|
|
@@ -2648,14 +2938,16 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
|
2648
2938
|
? Props
|
|
2649
2939
|
: never
|
|
2650
2940
|
|
|
2651
|
-
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2941
|
+
export type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2652
2942
|
>
|
|
2653
2943
|
|
|
2654
|
-
interface JsxFactory {
|
|
2944
|
+
export interface JsxFactory {
|
|
2655
2945
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2656
2946
|
}
|
|
2657
2947
|
|
|
2658
|
-
type JsxElements = {
|
|
2948
|
+
export type JsxElements = {
|
|
2949
|
+
[K in IntrinsicElement]: ${componentName}<K>
|
|
2950
|
+
}
|
|
2659
2951
|
|
|
2660
2952
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2661
2953
|
|
|
@@ -2772,12 +3064,12 @@ var csstype_d_ts_default = {
|
|
|
2772
3064
|
|
|
2773
3065
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2774
3066
|
var system_types_d_ts_default = {
|
|
2775
|
-
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 interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface 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\ninterface 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 interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\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 * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemProperties & MinimalNested<SystemStyleObject>\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport
|
|
3067
|
+
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\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface 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\ninterface 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 interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\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 * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemProperties & MinimalNested<SystemStyleObject>\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport interface PatchedHTMLProps {\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' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<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"
|
|
2776
3068
|
};
|
|
2777
3069
|
|
|
2778
3070
|
// src/artifacts/generated/composition.d.ts.json
|
|
2779
3071
|
var composition_d_ts_default = {
|
|
2780
|
-
content: "import type { CompositionStyleObject } from './system-types'\n\ninterface Recursive<T> {\n [key: string]: Recursive<T> | T\n}\n\
|
|
3072
|
+
content: "import type { CompositionStyleObject } from './system-types'\nimport type { Token } from '../tokens'\n\ninterface Recursive<T> {\n [key: string]: Recursive<T> | T\n}\n\n/* -----------------------------------------------------------------------------\n * Text styles\n * -----------------------------------------------------------------------------*/\n\ntype TextStyleProperty =\n | 'fontSize'\n | 'fontSizeAdjust'\n | 'fontVariationSettings'\n | 'fontVariantPosition'\n | 'fontVariantCaps'\n | 'fontVariantNumeric'\n | 'fontVariantAlternates'\n | 'fontVariantLigatures'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontSynthesis'\n | 'fontStyle'\n | 'fontVariant'\n | 'lineHeight'\n | 'letterSpacing'\n | 'textDecoration'\n | 'textTransform'\n | 'textIndent'\n | 'textDecorationColor'\n | 'textDecorationLine'\n | 'textDecorationStyle'\n | 'textEmphasisColor'\n | 'textEmphasisPosition'\n | 'textEmphasisStyle'\n | 'hyphenateCharacter'\n | 'textOrientation'\n | 'textOverflow'\n | 'textRendering'\n\nexport type TextStyle = CompositionStyleObject<TextStyleProperty>\n\nexport type TextStyles = Recursive<Token<TextStyle>>\n\n/* -----------------------------------------------------------------------------\n * Layer styles\n * -----------------------------------------------------------------------------*/\n\ntype Placement =\n | 'Top'\n | 'Right'\n | 'Bottom'\n | 'Left'\n | 'Inline'\n | 'Block'\n | 'InlineStart'\n | 'InlineEnd'\n | 'BlockStart'\n | 'BlockEnd'\n\ntype Radius =\n | `Top${'Right' | 'Left'}`\n | `Bottom${'Right' | 'Left'}`\n | `Start${'Start' | 'End'}`\n | `End${'Start' | 'End'}`\n\ntype LayerStyleProperty =\n | 'background'\n | 'backgroundColor'\n | 'backgroundImage'\n | 'borderRadius'\n | 'border'\n | 'borderWidth'\n | 'borderColor'\n | 'borderStyle'\n | 'boxShadow'\n | 'filter'\n | 'backdropFilter'\n | 'transform'\n | 'color'\n | 'opacity'\n | 'backgroundBlendMode'\n | 'backgroundAttachment'\n | 'backgroundClip'\n | 'backgroundOrigin'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundSize'\n | `border${Placement}`\n | `border${Placement}Width`\n | 'borderRadius'\n | `border${Radius}Radius`\n | `border${Placement}Color`\n | `border${Placement}Style`\n | 'padding'\n | `padding${Placement}`\n\nexport type LayerStyle = CompositionStyleObject<LayerStyleProperty>\n\nexport type LayerStyles = Recursive<Token<LayerStyle>>\n\nexport interface CompositionStyles {\n textStyles: TextStyles\n layerStyles: LayerStyles\n}\n"
|
|
2781
3073
|
};
|
|
2782
3074
|
|
|
2783
3075
|
// src/artifacts/generated/recipe.d.ts.json
|
|
@@ -2801,7 +3093,7 @@ var selectors_d_ts_default = {
|
|
|
2801
3093
|
};
|
|
2802
3094
|
|
|
2803
3095
|
// src/artifacts/types/generated.ts
|
|
2804
|
-
var
|
|
3096
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
2805
3097
|
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2806
3098
|
function getGeneratedTypes(ctx) {
|
|
2807
3099
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
@@ -2813,15 +3105,15 @@ function getGeneratedTypes(ctx) {
|
|
|
2813
3105
|
composition: rewriteImports(composition_d_ts_default.content),
|
|
2814
3106
|
selectors: rewriteImports(selectors_d_ts_default.content),
|
|
2815
3107
|
system: rewriteImports(
|
|
2816
|
-
(0,
|
|
3108
|
+
(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()
|
|
2817
3109
|
)
|
|
2818
3110
|
};
|
|
2819
3111
|
}
|
|
2820
3112
|
|
|
2821
3113
|
// src/artifacts/types/main.ts
|
|
2822
|
-
var
|
|
3114
|
+
var import_outdent40 = require("outdent");
|
|
2823
3115
|
var generateTypesEntry = (ctx) => ({
|
|
2824
|
-
global:
|
|
3116
|
+
global: import_outdent40.outdent`
|
|
2825
3117
|
// @ts-nocheck
|
|
2826
3118
|
import type * as Panda from '@pandacss/dev'
|
|
2827
3119
|
${ctx.file.importType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
@@ -2842,7 +3134,7 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2842
3134
|
}
|
|
2843
3135
|
`,
|
|
2844
3136
|
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
|
|
2845
|
-
index:
|
|
3137
|
+
index: import_outdent40.outdent`
|
|
2846
3138
|
import '${ctx.file.extDts("./global")}'
|
|
2847
3139
|
${ctx.file.exportTypeStar("./conditions")}
|
|
2848
3140
|
${ctx.file.exportTypeStar("./pattern")}
|
|
@@ -2852,13 +3144,13 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2852
3144
|
${ctx.file.exportTypeStar("./style-props")}
|
|
2853
3145
|
|
|
2854
3146
|
`,
|
|
2855
|
-
helpers:
|
|
3147
|
+
helpers: import_outdent40.outdent`
|
|
2856
3148
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2857
3149
|
`
|
|
2858
3150
|
});
|
|
2859
3151
|
|
|
2860
3152
|
// src/artifacts/types/prop-types.ts
|
|
2861
|
-
var
|
|
3153
|
+
var import_outdent41 = require("outdent");
|
|
2862
3154
|
function generatePropTypes(ctx) {
|
|
2863
3155
|
const {
|
|
2864
3156
|
config: { strictTokens },
|
|
@@ -2866,7 +3158,7 @@ function generatePropTypes(ctx) {
|
|
|
2866
3158
|
} = ctx;
|
|
2867
3159
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2868
3160
|
const result = [
|
|
2869
|
-
|
|
3161
|
+
import_outdent41.outdent`
|
|
2870
3162
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
2871
3163
|
${ctx.file.importType("CssProperties", "./system-types")}
|
|
2872
3164
|
${ctx.file.importType("Tokens", "../tokens/index")}
|
|
@@ -2889,7 +3181,7 @@ function generatePropTypes(ctx) {
|
|
|
2889
3181
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2890
3182
|
});
|
|
2891
3183
|
result.push("}");
|
|
2892
|
-
return
|
|
3184
|
+
return import_outdent41.outdent`
|
|
2893
3185
|
${result.join("\n")}
|
|
2894
3186
|
|
|
2895
3187
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2902,10 +3194,10 @@ function generatePropTypes(ctx) {
|
|
|
2902
3194
|
|
|
2903
3195
|
// src/artifacts/types/style-props.ts
|
|
2904
3196
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
2905
|
-
var
|
|
3197
|
+
var import_outdent42 = __toESM(require("outdent"));
|
|
2906
3198
|
function generateStyleProps(ctx) {
|
|
2907
3199
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
2908
|
-
return
|
|
3200
|
+
return import_outdent42.default`
|
|
2909
3201
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
2910
3202
|
${ctx.file.importType("PropertyValue", "./prop-type")}
|
|
2911
3203
|
${ctx.file.importType("Token", "../tokens/index")}
|
|
@@ -2922,7 +3214,7 @@ function generateStyleProps(ctx) {
|
|
|
2922
3214
|
|
|
2923
3215
|
// src/artifacts/types/token-types.ts
|
|
2924
3216
|
var import_shared3 = require("@pandacss/shared");
|
|
2925
|
-
var
|
|
3217
|
+
var import_outdent43 = require("outdent");
|
|
2926
3218
|
var import_pluralize = __toESM(require("pluralize"));
|
|
2927
3219
|
var categories = [
|
|
2928
3220
|
"zIndex",
|
|
@@ -2973,7 +3265,7 @@ function generateTokenTypes(ctx) {
|
|
|
2973
3265
|
result.add("} & { [token: string]: never }");
|
|
2974
3266
|
set.add(Array.from(result).join("\n"));
|
|
2975
3267
|
set.add(`export type TokenCategory = ${(0, import_shared3.unionType)(categories)}`);
|
|
2976
|
-
return
|
|
3268
|
+
return import_outdent43.outdent.string(Array.from(set).join("\n\n"));
|
|
2977
3269
|
}
|
|
2978
3270
|
|
|
2979
3271
|
// src/artifacts/index.ts
|
|
@@ -3019,7 +3311,6 @@ function setupTypes(ctx) {
|
|
|
3019
3311
|
{ file: ctx.file.extDts("selectors"), code: gen.selectors },
|
|
3020
3312
|
{ file: ctx.file.extDts("composition"), code: gen.composition },
|
|
3021
3313
|
{ file: ctx.file.extDts("global"), code: entry.global },
|
|
3022
|
-
{ file: ctx.file.extDts("helpers"), code: entry.helpers },
|
|
3023
3314
|
{ file: ctx.file.extDts("recipe"), code: gen.recipe },
|
|
3024
3315
|
{ file: ctx.file.extDts("pattern"), code: gen.pattern },
|
|
3025
3316
|
{ file: ctx.file.extDts("parts"), code: gen.parts },
|
|
@@ -3082,8 +3373,8 @@ function setupRecipes(ctx) {
|
|
|
3082
3373
|
return;
|
|
3083
3374
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
3084
3375
|
const index = {
|
|
3085
|
-
js:
|
|
3086
|
-
dts:
|
|
3376
|
+
js: import_outdent44.default.string(indexFiles.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
|
|
3377
|
+
dts: import_outdent44.default.string(indexFiles.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
|
|
3087
3378
|
};
|
|
3088
3379
|
return {
|
|
3089
3380
|
dir: ctx.paths.recipe,
|
|
@@ -3102,8 +3393,8 @@ function setupPatterns(ctx) {
|
|
|
3102
3393
|
if (!files)
|
|
3103
3394
|
return;
|
|
3104
3395
|
const index = {
|
|
3105
|
-
js:
|
|
3106
|
-
dts:
|
|
3396
|
+
js: import_outdent44.default.string(files.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n")),
|
|
3397
|
+
dts: import_outdent44.default.string(files.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))
|
|
3107
3398
|
};
|
|
3108
3399
|
return {
|
|
3109
3400
|
dir: ctx.paths.pattern,
|
|
@@ -3122,18 +3413,19 @@ function setupJsx(ctx) {
|
|
|
3122
3413
|
const types = generateJsxTypes(ctx);
|
|
3123
3414
|
const factory = generateJsxFactory(ctx);
|
|
3124
3415
|
const patterns = generateJsxPatterns(ctx);
|
|
3416
|
+
const helpers3 = generatedJsxHelpers(ctx);
|
|
3125
3417
|
const index = {
|
|
3126
|
-
js:
|
|
3418
|
+
js: import_outdent44.default`
|
|
3127
3419
|
${ctx.file.exportStar("./factory")}
|
|
3128
3420
|
${isValidProp?.js ? ctx.file.exportStar("./is-valid-prop") : ""}
|
|
3129
|
-
${
|
|
3421
|
+
${import_outdent44.default.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
|
|
3130
3422
|
`,
|
|
3131
|
-
dts:
|
|
3423
|
+
dts: import_outdent44.default`
|
|
3132
3424
|
${ctx.file.exportTypeStar("./factory")}
|
|
3133
3425
|
|
|
3134
3426
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3135
3427
|
|
|
3136
|
-
${
|
|
3428
|
+
${import_outdent44.default.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3137
3429
|
|
|
3138
3430
|
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3139
3431
|
`
|
|
@@ -3145,6 +3437,7 @@ function setupJsx(ctx) {
|
|
|
3145
3437
|
...patterns.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
|
|
3146
3438
|
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
3147
3439
|
{ file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts },
|
|
3440
|
+
{ file: ctx.file.ext("factory-helper"), code: helpers3.js },
|
|
3148
3441
|
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
3149
3442
|
{ file: ctx.file.extDts("factory"), code: types.jsxFactory },
|
|
3150
3443
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
@@ -3154,13 +3447,13 @@ function setupJsx(ctx) {
|
|
|
3154
3447
|
}
|
|
3155
3448
|
function setupCssIndex(ctx) {
|
|
3156
3449
|
const index = {
|
|
3157
|
-
js:
|
|
3450
|
+
js: import_outdent44.default`
|
|
3158
3451
|
${ctx.file.exportStar("./css")}
|
|
3159
3452
|
${ctx.file.exportStar("./cx")}
|
|
3160
3453
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./cva")}
|
|
3161
3454
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./sva")}
|
|
3162
3455
|
`,
|
|
3163
|
-
dts:
|
|
3456
|
+
dts: import_outdent44.default`
|
|
3164
3457
|
${ctx.file.exportTypeStar("./css")}
|
|
3165
3458
|
${ctx.file.exportTypeStar("./cx")}
|
|
3166
3459
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./cva")}
|
|
@@ -3222,6 +3515,8 @@ var generateArtifacts = (ctx) => () => {
|
|
|
3222
3515
|
].filter(Boolean).map((artifact) => {
|
|
3223
3516
|
const files = artifact?.files ?? [];
|
|
3224
3517
|
files.forEach((file) => {
|
|
3518
|
+
if (!file)
|
|
3519
|
+
return;
|
|
3225
3520
|
if (ctx.file.isTypeFile(file.file)) {
|
|
3226
3521
|
file.code = `/* eslint-disable */
|
|
3227
3522
|
${file.code}`;
|
|
@@ -3261,7 +3556,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3261
3556
|
// src/artifacts/css/parser-css.ts
|
|
3262
3557
|
var import_logger2 = require("@pandacss/logger");
|
|
3263
3558
|
var import_func = require("lil-fp/func");
|
|
3264
|
-
var
|
|
3559
|
+
var import_ts_pattern10 = require("ts-pattern");
|
|
3265
3560
|
var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
3266
3561
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3267
3562
|
(0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3291,7 +3586,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3291
3586
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3292
3587
|
if (!recipeConfig)
|
|
3293
3588
|
continue;
|
|
3294
|
-
(0,
|
|
3589
|
+
(0, import_ts_pattern10.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3295
3590
|
recipe.data.forEach((data) => {
|
|
3296
3591
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3297
3592
|
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3310,7 +3605,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3310
3605
|
result2.pattern.forEach((patternSet, name) => {
|
|
3311
3606
|
try {
|
|
3312
3607
|
for (const pattern of patternSet) {
|
|
3313
|
-
(0,
|
|
3608
|
+
(0, import_ts_pattern10.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern10.P.string }, ({ name: jsxName }) => {
|
|
3314
3609
|
pattern.data.forEach((data) => {
|
|
3315
3610
|
const fnName = patterns.find(jsxName);
|
|
3316
3611
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -3463,6 +3758,7 @@ var getJsxEngine = (config) => {
|
|
|
3463
3758
|
factoryName: jsxFactory,
|
|
3464
3759
|
upperName: (0, import_shared6.capitalize)(jsxFactory),
|
|
3465
3760
|
typeName: `HTML${(0, import_shared6.capitalize)(jsxFactory)}Props`,
|
|
3761
|
+
variantName: `${(0, import_shared6.capitalize)(jsxFactory)}VariantProps`,
|
|
3466
3762
|
componentName: `${(0, import_shared6.capitalize)(jsxFactory)}Component`,
|
|
3467
3763
|
framework: jsxFramework,
|
|
3468
3764
|
styleProps: jsxStyleProps2 ?? "all"
|