@pandacss/generator 0.0.0-dev-20231020132218 → 0.0.0-dev-20231020173315
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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +591 -308
- package/dist/index.mjs +591 -308
- package/package.json +8 -8
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) => {
|
|
@@ -650,11 +650,7 @@ function generateStringLiteralConditions(ctx) {
|
|
|
650
650
|
// src/artifacts/js/css-fn.ts
|
|
651
651
|
var import_outdent4 = require("outdent");
|
|
652
652
|
function generateCssFn(ctx) {
|
|
653
|
-
const {
|
|
654
|
-
utility,
|
|
655
|
-
config: { hash, prefix },
|
|
656
|
-
conditions
|
|
657
|
-
} = ctx;
|
|
653
|
+
const { utility, hash, prefix, conditions } = ctx;
|
|
658
654
|
const { separator, getPropShorthands } = utility;
|
|
659
655
|
return {
|
|
660
656
|
dts: import_outdent4.outdent`
|
|
@@ -709,14 +705,14 @@ function generateCssFn(ctx) {
|
|
|
709
705
|
`}
|
|
710
706
|
|
|
711
707
|
const context = {
|
|
712
|
-
${hash ? "hash: true," : ""}
|
|
708
|
+
${hash.className ? "hash: true," : ""}
|
|
713
709
|
conditions: {
|
|
714
710
|
shift: sortConditions,
|
|
715
711
|
finalize: finalizeConditions,
|
|
716
712
|
breakpoints: { keys: ${JSON.stringify(conditions.breakpoints.keys)} }
|
|
717
713
|
},
|
|
718
714
|
utility: {
|
|
719
|
-
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
715
|
+
${prefix.className ? "prefix: " + JSON.stringify(prefix.className) + "," : ""}
|
|
720
716
|
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
721
717
|
const key = resolveShorthand(prop)
|
|
722
718
|
const propKey = classNameByProp.get(key) || hypenateProperty(key)
|
|
@@ -739,18 +735,15 @@ function generateCssFn(ctx) {
|
|
|
739
735
|
// src/artifacts/js/css-fn.string-literal.ts
|
|
740
736
|
var import_outdent5 = require("outdent");
|
|
741
737
|
function generateStringLiteralCssFn(ctx) {
|
|
742
|
-
const {
|
|
743
|
-
utility,
|
|
744
|
-
config: { hash, prefix }
|
|
745
|
-
} = ctx;
|
|
738
|
+
const { utility, hash, prefix } = ctx;
|
|
746
739
|
const { separator } = utility;
|
|
747
740
|
return {
|
|
748
741
|
dts: import_outdent5.outdent`
|
|
749
742
|
export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
|
|
750
743
|
`,
|
|
751
744
|
js: import_outdent5.outdent`
|
|
752
|
-
${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
|
|
753
|
-
${ctx.file.import("
|
|
745
|
+
${ctx.file.import("astish, createCss, isObject, mergeProps, withoutSpace", "../helpers")}
|
|
746
|
+
${ctx.file.import("finalizeConditions, sortConditions", "./conditions")}
|
|
754
747
|
|
|
755
748
|
function transform(prop, value) {
|
|
756
749
|
const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
|
|
@@ -758,14 +751,14 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
758
751
|
}
|
|
759
752
|
|
|
760
753
|
const context = {
|
|
761
|
-
hash: ${hash ? "true" : "false"},
|
|
754
|
+
hash: ${hash.className ? "true" : "false"},
|
|
762
755
|
conditions: {
|
|
763
756
|
shift: sortConditions,
|
|
764
757
|
finalize: finalizeConditions,
|
|
765
758
|
breakpoints: { keys: [] },
|
|
766
759
|
},
|
|
767
760
|
utility: {
|
|
768
|
-
prefix: ${prefix ? JSON.stringify(prefix) : void 0},
|
|
761
|
+
prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
|
|
769
762
|
transform,
|
|
770
763
|
hasShorthand: false,
|
|
771
764
|
resolveShorthand(prop) {
|
|
@@ -776,9 +769,9 @@ function generateStringLiteralCssFn(ctx) {
|
|
|
776
769
|
|
|
777
770
|
const cssFn = createCss(context)
|
|
778
771
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
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))
|
|
782
775
|
`
|
|
783
776
|
};
|
|
784
777
|
}
|
|
@@ -788,11 +781,19 @@ var import_outdent6 = require("outdent");
|
|
|
788
781
|
function generateCvaFn(ctx) {
|
|
789
782
|
return {
|
|
790
783
|
js: import_outdent6.outdent`
|
|
791
|
-
${ctx.file.import("compact, splitProps", "../helpers")}
|
|
784
|
+
${ctx.file.import("compact, mergeProps, splitProps, uniq", "../helpers")}
|
|
792
785
|
${ctx.file.import("css, mergeCss", "./css")}
|
|
793
786
|
|
|
787
|
+
const defaults = (conf) => ({
|
|
788
|
+
base: {},
|
|
789
|
+
variants: {},
|
|
790
|
+
defaultVariants: {},
|
|
791
|
+
compoundVariants: [],
|
|
792
|
+
...conf,
|
|
793
|
+
})
|
|
794
|
+
|
|
794
795
|
export function cva(config) {
|
|
795
|
-
const { base
|
|
796
|
+
const { base, variants, defaultVariants, compoundVariants } = defaults(config)
|
|
796
797
|
|
|
797
798
|
function resolve(props = {}) {
|
|
798
799
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
@@ -806,6 +807,19 @@ function generateCvaFn(ctx) {
|
|
|
806
807
|
return mergeCss(variantCss, compoundVariantCss)
|
|
807
808
|
}
|
|
808
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
|
+
|
|
809
823
|
function cvaFn(props) {
|
|
810
824
|
return css(resolve(props))
|
|
811
825
|
}
|
|
@@ -824,6 +838,7 @@ function generateCvaFn(ctx) {
|
|
|
824
838
|
variantKeys,
|
|
825
839
|
raw: resolve,
|
|
826
840
|
config,
|
|
841
|
+
merge,
|
|
827
842
|
splitVariantProps,
|
|
828
843
|
})
|
|
829
844
|
}
|
|
@@ -898,7 +913,7 @@ var import_outdent8 = require("outdent");
|
|
|
898
913
|
|
|
899
914
|
// src/artifacts/generated/helpers.mjs.json
|
|
900
915
|
var helpers_mjs_default = {
|
|
901
|
-
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'
|
|
902
917
|
};
|
|
903
918
|
|
|
904
919
|
// src/artifacts/generated/astish.mjs.json
|
|
@@ -966,11 +981,52 @@ function generateIsValidProp(ctx) {
|
|
|
966
981
|
};
|
|
967
982
|
}
|
|
968
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
|
+
|
|
969
1025
|
// src/artifacts/js/pattern.ts
|
|
970
1026
|
var import_shared = require("@pandacss/shared");
|
|
971
1027
|
var import_javascript_stringify = require("javascript-stringify");
|
|
972
|
-
var
|
|
973
|
-
var
|
|
1028
|
+
var import_outdent11 = require("outdent");
|
|
1029
|
+
var import_ts_pattern3 = require("ts-pattern");
|
|
974
1030
|
function generatePattern(ctx) {
|
|
975
1031
|
if (ctx.patterns.isEmpty())
|
|
976
1032
|
return;
|
|
@@ -987,7 +1043,7 @@ function generatePattern(ctx) {
|
|
|
987
1043
|
}
|
|
988
1044
|
return {
|
|
989
1045
|
name: dashName,
|
|
990
|
-
dts:
|
|
1046
|
+
dts: import_outdent11.outdent`
|
|
991
1047
|
${ctx.file.importType("SystemStyleObject, ConditionalValue", "../types/index")}
|
|
992
1048
|
${ctx.file.importType("Properties", "../types/csstype")}
|
|
993
1049
|
${ctx.file.importType("PropertyValue", "../types/prop-type")}
|
|
@@ -997,7 +1053,7 @@ function generatePattern(ctx) {
|
|
|
997
1053
|
export interface ${upperName}Properties {
|
|
998
1054
|
${Object.keys(properties ?? {}).map((key) => {
|
|
999
1055
|
const value = properties[key];
|
|
1000
|
-
return (0,
|
|
1056
|
+
return (0, import_ts_pattern3.match)(value).with({ type: "property" }, (value2) => {
|
|
1001
1057
|
return `${key}?: PropertyValue<'${value2.value}'>`;
|
|
1002
1058
|
}).with({ type: "token" }, (value2) => {
|
|
1003
1059
|
if (value2.property) {
|
|
@@ -1012,7 +1068,7 @@ function generatePattern(ctx) {
|
|
|
1012
1068
|
}).join("\n ")}
|
|
1013
1069
|
}
|
|
1014
1070
|
|
|
1015
|
-
${strict ?
|
|
1071
|
+
${strict ? import_outdent11.outdent`export declare function ${baseName}(styles: ${upperName}Properties): string` : import_outdent11.outdent`
|
|
1016
1072
|
|
|
1017
1073
|
interface ${upperName}Styles extends ${upperName}Properties, DistributiveOmit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}> {}
|
|
1018
1074
|
|
|
@@ -1026,7 +1082,7 @@ function generatePattern(ctx) {
|
|
|
1026
1082
|
`}
|
|
1027
1083
|
|
|
1028
1084
|
`,
|
|
1029
|
-
js:
|
|
1085
|
+
js: import_outdent11.outdent`
|
|
1030
1086
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
1031
1087
|
${ctx.file.import("css", "../css/index")}
|
|
1032
1088
|
|
|
@@ -1045,8 +1101,8 @@ transform`)}
|
|
|
1045
1101
|
// src/artifacts/js/recipe.ts
|
|
1046
1102
|
var import_core4 = require("@pandacss/core");
|
|
1047
1103
|
var import_shared2 = require("@pandacss/shared");
|
|
1048
|
-
var
|
|
1049
|
-
var
|
|
1104
|
+
var import_outdent12 = require("outdent");
|
|
1105
|
+
var import_ts_pattern4 = require("ts-pattern");
|
|
1050
1106
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
1051
1107
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
1052
1108
|
function generateRecipes(ctx) {
|
|
@@ -1060,11 +1116,11 @@ function generateRecipes(ctx) {
|
|
|
1060
1116
|
const createRecipeFn = {
|
|
1061
1117
|
name: "create-recipe",
|
|
1062
1118
|
dts: "",
|
|
1063
|
-
js:
|
|
1119
|
+
js: import_outdent12.outdent`
|
|
1064
1120
|
${ctx.file.import("css", "../css/css")}
|
|
1065
1121
|
${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
|
|
1066
1122
|
${ctx.file.import("cx", "../css/cx")}
|
|
1067
|
-
${ctx.file.import("compact, createCss, withoutSpace", "../helpers")}
|
|
1123
|
+
${ctx.file.import("compact, createCss, splitProps, uniq, withoutSpace", "../helpers")}
|
|
1068
1124
|
|
|
1069
1125
|
export const createRecipe = (name, defaultVariants, compoundVariants) => {
|
|
1070
1126
|
const getRecipeStyles = (variants) => {
|
|
@@ -1111,6 +1167,30 @@ function generateRecipes(ctx) {
|
|
|
1111
1167
|
},
|
|
1112
1168
|
})
|
|
1113
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
|
+
}
|
|
1114
1194
|
`
|
|
1115
1195
|
};
|
|
1116
1196
|
return [
|
|
@@ -1118,9 +1198,9 @@ function generateRecipes(ctx) {
|
|
|
1118
1198
|
...ctx.recipes.details.map((recipe) => {
|
|
1119
1199
|
const { baseName, config, upperName, variantKeyMap, dashName } = recipe;
|
|
1120
1200
|
const { description, defaultVariants, compoundVariants } = config;
|
|
1121
|
-
const jsCode = (0,
|
|
1201
|
+
const jsCode = (0, import_ts_pattern4.match)(config).when(
|
|
1122
1202
|
import_core4.isSlotRecipe,
|
|
1123
|
-
(config2) =>
|
|
1203
|
+
(config2) => import_outdent12.outdent`
|
|
1124
1204
|
${ctx.file.import("splitProps, getSlotCompoundVariant", "../helpers")}
|
|
1125
1205
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1126
1206
|
|
|
@@ -1148,9 +1228,9 @@ function generateRecipes(ctx) {
|
|
|
1148
1228
|
})
|
|
1149
1229
|
`
|
|
1150
1230
|
).otherwise(
|
|
1151
|
-
(config2) =>
|
|
1231
|
+
(config2) => import_outdent12.outdent`
|
|
1152
1232
|
${ctx.file.import("splitProps", "../helpers")}
|
|
1153
|
-
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
1233
|
+
${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
|
|
1154
1234
|
|
|
1155
1235
|
const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config2.className}', ${stringify2(
|
|
1156
1236
|
defaultVariants ?? {}
|
|
@@ -1166,6 +1246,9 @@ function generateRecipes(ctx) {
|
|
|
1166
1246
|
raw: (props) => props,
|
|
1167
1247
|
variantKeys: ${baseName}VariantKeys,
|
|
1168
1248
|
variantMap: ${baseName}VariantMap,
|
|
1249
|
+
merge(recipe) {
|
|
1250
|
+
return mergeRecipes(this, recipe)
|
|
1251
|
+
},
|
|
1169
1252
|
splitVariantProps(props) {
|
|
1170
1253
|
return splitProps(props, ${baseName}VariantKeys)
|
|
1171
1254
|
},
|
|
@@ -1175,10 +1258,9 @@ function generateRecipes(ctx) {
|
|
|
1175
1258
|
return {
|
|
1176
1259
|
name: dashName,
|
|
1177
1260
|
js: jsCode,
|
|
1178
|
-
dts:
|
|
1261
|
+
dts: import_outdent12.outdent`
|
|
1179
1262
|
${ctx.file.importType("ConditionalValue", "../types/index")}
|
|
1180
|
-
${ctx.file.importType("Pretty", "../types/
|
|
1181
|
-
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
1263
|
+
${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
|
|
1182
1264
|
|
|
1183
1265
|
interface ${upperName}Variant {
|
|
1184
1266
|
${Object.keys(variantKeyMap).map((key) => {
|
|
@@ -1215,10 +1297,10 @@ function generateRecipes(ctx) {
|
|
|
1215
1297
|
}
|
|
1216
1298
|
|
|
1217
1299
|
// src/artifacts/js/sva.ts
|
|
1218
|
-
var
|
|
1300
|
+
var import_outdent13 = require("outdent");
|
|
1219
1301
|
function generateSvaFn(ctx) {
|
|
1220
1302
|
return {
|
|
1221
|
-
js:
|
|
1303
|
+
js: import_outdent13.outdent`
|
|
1222
1304
|
${ctx.file.import("getSlotRecipes, splitProps", "../helpers")}
|
|
1223
1305
|
${ctx.file.import("cva", "./cva")}
|
|
1224
1306
|
|
|
@@ -1255,7 +1337,7 @@ function generateSvaFn(ctx) {
|
|
|
1255
1337
|
})
|
|
1256
1338
|
}
|
|
1257
1339
|
`,
|
|
1258
|
-
dts:
|
|
1340
|
+
dts: import_outdent13.outdent`
|
|
1259
1341
|
${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
|
|
1260
1342
|
|
|
1261
1343
|
export declare const sva: SlotRecipeCreatorFn
|
|
@@ -1264,7 +1346,7 @@ function generateSvaFn(ctx) {
|
|
|
1264
1346
|
}
|
|
1265
1347
|
|
|
1266
1348
|
// src/artifacts/js/token.ts
|
|
1267
|
-
var
|
|
1349
|
+
var import_outdent14 = __toESM(require("outdent"));
|
|
1268
1350
|
function generateTokenJs(ctx) {
|
|
1269
1351
|
const { tokens } = ctx;
|
|
1270
1352
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1275,7 +1357,7 @@ function generateTokenJs(ctx) {
|
|
|
1275
1357
|
});
|
|
1276
1358
|
const obj = Object.fromEntries(map);
|
|
1277
1359
|
return {
|
|
1278
|
-
js:
|
|
1360
|
+
js: import_outdent14.default`
|
|
1279
1361
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
1280
1362
|
|
|
1281
1363
|
export function token(path, fallback) {
|
|
@@ -1288,7 +1370,7 @@ function generateTokenJs(ctx) {
|
|
|
1288
1370
|
|
|
1289
1371
|
token.var = tokenVar
|
|
1290
1372
|
`,
|
|
1291
|
-
dts:
|
|
1373
|
+
dts: import_outdent14.default`
|
|
1292
1374
|
${ctx.file.importType("Token", "./tokens")}
|
|
1293
1375
|
|
|
1294
1376
|
export declare const token: {
|
|
@@ -1302,19 +1384,21 @@ function generateTokenJs(ctx) {
|
|
|
1302
1384
|
}
|
|
1303
1385
|
|
|
1304
1386
|
// src/artifacts/preact-jsx/jsx.ts
|
|
1305
|
-
var
|
|
1387
|
+
var import_outdent15 = require("outdent");
|
|
1306
1388
|
function generatePreactJsxFactory(ctx) {
|
|
1307
1389
|
const { factoryName, componentName } = ctx.jsx;
|
|
1308
1390
|
return {
|
|
1309
|
-
js:
|
|
1391
|
+
js: import_outdent15.outdent`
|
|
1310
1392
|
import { h } from 'preact'
|
|
1311
1393
|
import { forwardRef } from 'preact/compat'
|
|
1312
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")}
|
|
1313
1400
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1314
1401
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1315
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1316
|
-
|
|
1317
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1318
1402
|
|
|
1319
1403
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1320
1404
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
@@ -1328,23 +1412,26 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1328
1412
|
)
|
|
1329
1413
|
|
|
1330
1414
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1331
|
-
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)
|
|
1332
1419
|
|
|
1333
1420
|
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1334
1421
|
|
|
1335
1422
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1336
|
-
return splitProps(combinedProps,
|
|
1423
|
+
return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1337
1424
|
}, [combinedProps])
|
|
1338
1425
|
|
|
1339
1426
|
function recipeClass() {
|
|
1340
1427
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1341
|
-
const compoundVariantStyles =
|
|
1342
|
-
return cx(
|
|
1428
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
|
|
1429
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1343
1430
|
}
|
|
1344
1431
|
|
|
1345
1432
|
function cvaClass() {
|
|
1346
1433
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1347
|
-
const cvaStyles =
|
|
1434
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1348
1435
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
|
|
1349
1436
|
}
|
|
1350
1437
|
|
|
@@ -1360,8 +1447,13 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1360
1447
|
})
|
|
1361
1448
|
})
|
|
1362
1449
|
|
|
1363
|
-
const name = (
|
|
1450
|
+
const name = getDisplayName(Dynamic)
|
|
1451
|
+
|
|
1364
1452
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1453
|
+
${componentName}.__cva__ = cvaFn
|
|
1454
|
+
${componentName}.__base__ = Dynamic
|
|
1455
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
1456
|
+
|
|
1365
1457
|
return ${componentName}
|
|
1366
1458
|
}
|
|
1367
1459
|
|
|
@@ -1387,8 +1479,8 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1387
1479
|
}
|
|
1388
1480
|
|
|
1389
1481
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1390
|
-
var
|
|
1391
|
-
var
|
|
1482
|
+
var import_outdent16 = require("outdent");
|
|
1483
|
+
var import_ts_pattern5 = require("ts-pattern");
|
|
1392
1484
|
function generatePreactJsxPattern(ctx) {
|
|
1393
1485
|
const { typeName, factoryName } = ctx.jsx;
|
|
1394
1486
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1396,21 +1488,21 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1396
1488
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1397
1489
|
return {
|
|
1398
1490
|
name: dashName,
|
|
1399
|
-
js:
|
|
1491
|
+
js: import_outdent16.outdent`
|
|
1400
1492
|
import { h } from 'preact'
|
|
1401
1493
|
import { forwardRef } from 'preact/compat'
|
|
1402
1494
|
${ctx.file.import(factoryName, "./factory")}
|
|
1403
1495
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1404
1496
|
|
|
1405
1497
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1406
|
-
${(0,
|
|
1498
|
+
${(0, import_ts_pattern5.match)(props.length).with(
|
|
1407
1499
|
0,
|
|
1408
|
-
() =>
|
|
1500
|
+
() => import_outdent16.outdent`
|
|
1409
1501
|
const styleProps = ${styleFnName}()
|
|
1410
1502
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1411
1503
|
`
|
|
1412
1504
|
).otherwise(
|
|
1413
|
-
() =>
|
|
1505
|
+
() => import_outdent16.outdent`
|
|
1414
1506
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1415
1507
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1416
1508
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1418,7 +1510,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1418
1510
|
)}
|
|
1419
1511
|
})
|
|
1420
1512
|
`,
|
|
1421
|
-
dts:
|
|
1513
|
+
dts: import_outdent16.outdent`
|
|
1422
1514
|
import type { FunctionComponent } from 'preact'
|
|
1423
1515
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1424
1516
|
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
@@ -1434,72 +1526,92 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1434
1526
|
}
|
|
1435
1527
|
|
|
1436
1528
|
// src/artifacts/preact-jsx/types.ts
|
|
1437
|
-
var
|
|
1529
|
+
var import_outdent17 = require("outdent");
|
|
1438
1530
|
function generatePreactJsxTypes(ctx) {
|
|
1439
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1531
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1440
1532
|
return {
|
|
1441
|
-
jsxFactory:
|
|
1533
|
+
jsxFactory: import_outdent17.outdent`
|
|
1442
1534
|
import type { ${upperName} } from '../types/jsx'
|
|
1443
1535
|
export declare const ${factoryName}: ${upperName}
|
|
1444
1536
|
`,
|
|
1445
|
-
jsxType:
|
|
1537
|
+
jsxType: import_outdent17.outdent`
|
|
1446
1538
|
import type { ComponentProps, JSX } from 'preact'
|
|
1447
|
-
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
1448
1539
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
1540
|
+
${ctx.file.importType(
|
|
1541
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
1542
|
+
"./system-types"
|
|
1543
|
+
)}
|
|
1449
1544
|
|
|
1450
|
-
type ElementType =
|
|
1545
|
+
export type ElementType = JSX.ElementType
|
|
1451
1546
|
|
|
1452
|
-
|
|
1547
|
+
interface Dict {
|
|
1548
|
+
[k: string]: unknown
|
|
1549
|
+
}
|
|
1453
1550
|
|
|
1454
1551
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
1455
1552
|
(props: JsxHTMLProps<ComponentProps<T>, P> & JsxStyleProps): JSX.Element
|
|
1456
1553
|
displayName?: string
|
|
1457
1554
|
}
|
|
1458
1555
|
|
|
1459
|
-
interface RecipeFn {
|
|
1556
|
+
interface RecipeFn {
|
|
1557
|
+
__type: any
|
|
1558
|
+
}
|
|
1460
1559
|
|
|
1461
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1560
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
1462
1561
|
dataAttr?: boolean
|
|
1463
1562
|
defaultProps?: TProps
|
|
1464
1563
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
1465
1564
|
}
|
|
1466
1565
|
|
|
1467
|
-
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>
|
|
1468
1571
|
|
|
1469
|
-
interface JsxFactory {
|
|
1572
|
+
export interface JsxFactory {
|
|
1470
1573
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1471
|
-
<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<
|
|
1472
1575
|
T,
|
|
1473
1576
|
RecipeSelection<P>
|
|
1474
1577
|
>
|
|
1475
|
-
<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']>
|
|
1476
1579
|
}
|
|
1477
1580
|
|
|
1478
|
-
type JsxElements = {
|
|
1581
|
+
export type JsxElements = {
|
|
1582
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
1583
|
+
}
|
|
1479
1584
|
|
|
1480
1585
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1481
1586
|
|
|
1482
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
|
|
1483
1590
|
`
|
|
1484
1591
|
};
|
|
1485
1592
|
}
|
|
1486
1593
|
|
|
1487
1594
|
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1488
|
-
var
|
|
1595
|
+
var import_outdent18 = require("outdent");
|
|
1489
1596
|
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1490
1597
|
const { factoryName, componentName } = ctx.jsx;
|
|
1491
1598
|
return {
|
|
1492
|
-
js:
|
|
1599
|
+
js: import_outdent18.outdent`
|
|
1493
1600
|
import { h } from 'preact'
|
|
1494
1601
|
import { forwardRef } from 'preact/compat'
|
|
1602
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
1495
1603
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1496
1604
|
|
|
1497
1605
|
function createStyledFn(Dynamic) {
|
|
1498
1606
|
return function styledFn(template) {
|
|
1499
|
-
const
|
|
1607
|
+
const styles = css.raw(template)
|
|
1608
|
+
|
|
1500
1609
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1501
|
-
const { as: Element = Dynamic, ...elementProps } = props
|
|
1502
|
-
|
|
1610
|
+
const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
|
|
1611
|
+
|
|
1612
|
+
function classes() {
|
|
1613
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
1614
|
+
}
|
|
1503
1615
|
|
|
1504
1616
|
return h(Element, {
|
|
1505
1617
|
ref,
|
|
@@ -1508,8 +1620,12 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1508
1620
|
})
|
|
1509
1621
|
})
|
|
1510
1622
|
|
|
1511
|
-
const name = (
|
|
1623
|
+
const name = getDisplayName(Dynamic)
|
|
1624
|
+
|
|
1512
1625
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1626
|
+
${componentName}.__styles__ = styles
|
|
1627
|
+
${componentName}.__base__ = Dynamic
|
|
1628
|
+
|
|
1513
1629
|
return ${componentName}
|
|
1514
1630
|
}
|
|
1515
1631
|
}
|
|
@@ -1536,31 +1652,35 @@ function generatePreactJsxStringLiteralFactory(ctx) {
|
|
|
1536
1652
|
}
|
|
1537
1653
|
|
|
1538
1654
|
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1539
|
-
var
|
|
1655
|
+
var import_outdent19 = require("outdent");
|
|
1540
1656
|
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1541
1657
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1542
1658
|
return {
|
|
1543
|
-
jsxFactory:
|
|
1659
|
+
jsxFactory: import_outdent19.outdent`
|
|
1544
1660
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1545
1661
|
export declare const ${factoryName}: ${upperName}
|
|
1546
1662
|
`,
|
|
1547
|
-
jsxType:
|
|
1663
|
+
jsxType: import_outdent19.outdent`
|
|
1548
1664
|
import type { ComponentProps, JSX } from 'preact'
|
|
1549
1665
|
|
|
1550
|
-
type ElementType =
|
|
1666
|
+
export type ElementType = JSX.ElementType
|
|
1551
1667
|
|
|
1552
|
-
|
|
1668
|
+
interface Dict {
|
|
1669
|
+
[k: string]: unknown
|
|
1670
|
+
}
|
|
1553
1671
|
|
|
1554
1672
|
export type ${componentName}<T extends ElementType> = {
|
|
1555
1673
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1556
1674
|
displayName?: string
|
|
1557
1675
|
}
|
|
1558
1676
|
|
|
1559
|
-
interface JsxFactory {
|
|
1677
|
+
export interface JsxFactory {
|
|
1560
1678
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1561
1679
|
}
|
|
1562
1680
|
|
|
1563
|
-
type JsxElements = {
|
|
1681
|
+
export type JsxElements = {
|
|
1682
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
1683
|
+
}
|
|
1564
1684
|
|
|
1565
1685
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1566
1686
|
|
|
@@ -1570,18 +1690,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1570
1690
|
}
|
|
1571
1691
|
|
|
1572
1692
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1573
|
-
var
|
|
1693
|
+
var import_outdent20 = require("outdent");
|
|
1574
1694
|
function generateQwikJsxFactory(ctx) {
|
|
1575
1695
|
const { factoryName, componentName } = ctx.jsx;
|
|
1576
1696
|
return {
|
|
1577
|
-
js:
|
|
1697
|
+
js: import_outdent20.outdent`
|
|
1578
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")}
|
|
1579
1704
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
1580
1705
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1581
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1582
1706
|
|
|
1583
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1584
|
-
|
|
1585
1707
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1586
1708
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1587
1709
|
|
|
@@ -1594,22 +1716,25 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1594
1716
|
)
|
|
1595
1717
|
|
|
1596
1718
|
const ${componentName} = function ${componentName}(props) {
|
|
1597
|
-
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)
|
|
1598
1723
|
|
|
1599
1724
|
const combinedProps = Object.assign({}, defaultProps, restProps)
|
|
1600
1725
|
|
|
1601
1726
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] =
|
|
1602
|
-
splitProps(combinedProps,
|
|
1603
|
-
|
|
1604
|
-
const { css: cssStyles, ...propStyles } = styleProps
|
|
1727
|
+
splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1605
1728
|
|
|
1606
1729
|
function recipeClass() {
|
|
1607
|
-
const
|
|
1608
|
-
|
|
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)
|
|
1609
1733
|
}
|
|
1610
|
-
|
|
1734
|
+
|
|
1611
1735
|
function cvaClass() {
|
|
1612
|
-
const
|
|
1736
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1737
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1613
1738
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
|
|
1614
1739
|
}
|
|
1615
1740
|
|
|
@@ -1624,8 +1749,13 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1624
1749
|
})
|
|
1625
1750
|
}
|
|
1626
1751
|
|
|
1627
|
-
const name = (
|
|
1752
|
+
const name = getDisplayName(Dynamic)
|
|
1753
|
+
|
|
1628
1754
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1755
|
+
${componentName}.__cva__ = cvaFn
|
|
1756
|
+
${componentName}.__base__ = Dynamic
|
|
1757
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
1758
|
+
|
|
1629
1759
|
return ${componentName}
|
|
1630
1760
|
}
|
|
1631
1761
|
|
|
@@ -1652,8 +1782,8 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1652
1782
|
}
|
|
1653
1783
|
|
|
1654
1784
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1655
|
-
var
|
|
1656
|
-
var
|
|
1785
|
+
var import_outdent21 = require("outdent");
|
|
1786
|
+
var import_ts_pattern6 = require("ts-pattern");
|
|
1657
1787
|
function generateQwikJsxPattern(ctx) {
|
|
1658
1788
|
const { typeName, factoryName } = ctx.jsx;
|
|
1659
1789
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1661,20 +1791,20 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1661
1791
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1662
1792
|
return {
|
|
1663
1793
|
name: dashName,
|
|
1664
|
-
js:
|
|
1794
|
+
js: import_outdent21.outdent`
|
|
1665
1795
|
import { h } from '@builder.io/qwik'
|
|
1666
1796
|
${ctx.file.import(factoryName, "./factory")}
|
|
1667
1797
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1668
1798
|
|
|
1669
1799
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1670
|
-
${(0,
|
|
1800
|
+
${(0, import_ts_pattern6.match)(props.length).with(
|
|
1671
1801
|
0,
|
|
1672
|
-
() =>
|
|
1802
|
+
() => import_outdent21.outdent`
|
|
1673
1803
|
const styleProps = ${styleFnName}()
|
|
1674
1804
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1675
1805
|
`
|
|
1676
1806
|
).otherwise(
|
|
1677
|
-
() =>
|
|
1807
|
+
() => import_outdent21.outdent`
|
|
1678
1808
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1679
1809
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1680
1810
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1682,7 +1812,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1682
1812
|
)}
|
|
1683
1813
|
}
|
|
1684
1814
|
`,
|
|
1685
|
-
dts:
|
|
1815
|
+
dts: import_outdent21.outdent`
|
|
1686
1816
|
import type { Component } from '@builder.io/qwik'
|
|
1687
1817
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1688
1818
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -1698,20 +1828,23 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1698
1828
|
}
|
|
1699
1829
|
|
|
1700
1830
|
// src/artifacts/qwik-jsx/types.ts
|
|
1701
|
-
var
|
|
1831
|
+
var import_outdent22 = require("outdent");
|
|
1702
1832
|
function generateQwikJsxTypes(ctx) {
|
|
1703
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1833
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1704
1834
|
return {
|
|
1705
|
-
jsxFactory:
|
|
1835
|
+
jsxFactory: import_outdent22.outdent`
|
|
1706
1836
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1707
1837
|
export declare const ${factoryName}: ${upperName}
|
|
1708
1838
|
`,
|
|
1709
|
-
jsxType:
|
|
1839
|
+
jsxType: import_outdent22.outdent`
|
|
1710
1840
|
import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1711
|
-
|
|
1712
|
-
|
|
1841
|
+
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
1842
|
+
${ctx.file.importType(
|
|
1843
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxStyleProps, PatchedHTMLProps, Pretty",
|
|
1844
|
+
"./system-types"
|
|
1845
|
+
)}
|
|
1713
1846
|
|
|
1714
|
-
type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1847
|
+
export type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1715
1848
|
|
|
1716
1849
|
export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1717
1850
|
? QwikIntrinsicElements[T]
|
|
@@ -1719,13 +1852,17 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
|
|
|
1719
1852
|
? P
|
|
1720
1853
|
: never
|
|
1721
1854
|
|
|
1722
|
-
|
|
1855
|
+
interface Dict {
|
|
1856
|
+
[k: string]: unknown
|
|
1857
|
+
}
|
|
1723
1858
|
|
|
1724
1859
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T>, Assign<PatchedHTMLProps, Assign<JsxStyleProps, P>>>> {}
|
|
1725
1860
|
|
|
1726
|
-
interface RecipeFn {
|
|
1861
|
+
interface RecipeFn {
|
|
1862
|
+
__type: any
|
|
1863
|
+
}
|
|
1727
1864
|
|
|
1728
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
1865
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
1729
1866
|
dataAttr?: boolean
|
|
1730
1867
|
defaultProps?: TProps
|
|
1731
1868
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -1733,48 +1870,65 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
1733
1870
|
|
|
1734
1871
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
1735
1872
|
|
|
1736
|
-
|
|
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 {
|
|
1737
1878
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
1738
|
-
<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<
|
|
1739
1880
|
T,
|
|
1740
1881
|
RecipeSelection<P>
|
|
1741
1882
|
>
|
|
1742
|
-
<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']>
|
|
1743
1884
|
}
|
|
1744
1885
|
|
|
1745
|
-
type JsxElements = {
|
|
1886
|
+
export type JsxElements = {
|
|
1887
|
+
[K in keyof QwikIntrinsicElements]: ${componentName}<K, {}>
|
|
1888
|
+
}
|
|
1746
1889
|
|
|
1747
1890
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1748
1891
|
|
|
1749
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
|
|
1750
1895
|
`
|
|
1751
1896
|
};
|
|
1752
1897
|
}
|
|
1753
1898
|
|
|
1754
1899
|
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1755
|
-
var
|
|
1900
|
+
var import_outdent23 = require("outdent");
|
|
1756
1901
|
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1757
1902
|
const { factoryName, componentName } = ctx.jsx;
|
|
1758
1903
|
return {
|
|
1759
|
-
js:
|
|
1904
|
+
js: import_outdent23.outdent`
|
|
1760
1905
|
import { h } from '@builder.io/qwik'
|
|
1906
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
1761
1907
|
${ctx.file.import("css, cx", "../css/index")}
|
|
1762
1908
|
|
|
1763
1909
|
function createStyledFn(Dynamic) {
|
|
1764
1910
|
return function styledFn(template) {
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
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
|
+
})
|
|
1774
1924
|
}
|
|
1775
1925
|
|
|
1776
|
-
const name = (
|
|
1926
|
+
const name = getDisplayName(Dynamic)
|
|
1927
|
+
|
|
1777
1928
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
1929
|
+
${componentName}.__styles__ = styles
|
|
1930
|
+
${componentName}.__base__ = Dynamic
|
|
1931
|
+
|
|
1778
1932
|
return ${componentName}
|
|
1779
1933
|
}
|
|
1780
1934
|
}
|
|
@@ -1802,18 +1956,18 @@ function generateQwikJsxStringLiteralFactory(ctx) {
|
|
|
1802
1956
|
}
|
|
1803
1957
|
|
|
1804
1958
|
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1805
|
-
var
|
|
1959
|
+
var import_outdent24 = require("outdent");
|
|
1806
1960
|
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1807
1961
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1808
1962
|
return {
|
|
1809
|
-
jsxFactory:
|
|
1963
|
+
jsxFactory: import_outdent24.outdent`
|
|
1810
1964
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1811
1965
|
export declare const ${factoryName}: ${upperName}
|
|
1812
1966
|
`,
|
|
1813
|
-
jsxType:
|
|
1967
|
+
jsxType: import_outdent24.outdent`
|
|
1814
1968
|
import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1815
1969
|
|
|
1816
|
-
type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1970
|
+
export type ElementType = keyof QwikIntrinsicElements | Component<any>
|
|
1817
1971
|
|
|
1818
1972
|
export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1819
1973
|
? QwikIntrinsicElements[T]
|
|
@@ -1821,17 +1975,21 @@ export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsi
|
|
|
1821
1975
|
? P
|
|
1822
1976
|
: never
|
|
1823
1977
|
|
|
1824
|
-
|
|
1978
|
+
interface Dict {
|
|
1979
|
+
[k: string]: unknown
|
|
1980
|
+
}
|
|
1825
1981
|
|
|
1826
1982
|
export type ${componentName}<T extends ElementType> = {
|
|
1827
1983
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1828
1984
|
}
|
|
1829
1985
|
|
|
1830
|
-
interface JsxFactory {
|
|
1986
|
+
export interface JsxFactory {
|
|
1831
1987
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1832
1988
|
}
|
|
1833
1989
|
|
|
1834
|
-
type JsxElements = {
|
|
1990
|
+
export type JsxElements = {
|
|
1991
|
+
[K in keyof QwikIntrinsicElements]: ${componentName}<K>
|
|
1992
|
+
}
|
|
1835
1993
|
|
|
1836
1994
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1837
1995
|
|
|
@@ -1841,18 +1999,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
1841
1999
|
}
|
|
1842
2000
|
|
|
1843
2001
|
// src/artifacts/react-jsx/jsx.ts
|
|
1844
|
-
var
|
|
2002
|
+
var import_outdent25 = require("outdent");
|
|
1845
2003
|
function generateReactJsxFactory(ctx) {
|
|
1846
2004
|
const { factoryName, componentName } = ctx.jsx;
|
|
1847
2005
|
return {
|
|
1848
|
-
js:
|
|
2006
|
+
js: import_outdent25.outdent`
|
|
1849
2007
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1850
2008
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2009
|
+
${ctx.file.import(
|
|
2010
|
+
"defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName",
|
|
2011
|
+
"./factory-helper"
|
|
2012
|
+
)}
|
|
1851
2013
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
1852
2014
|
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
1853
2015
|
|
|
1854
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
1855
|
-
|
|
1856
2016
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
1857
2017
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
1858
2018
|
|
|
@@ -1865,23 +2025,26 @@ function generateReactJsxFactory(ctx) {
|
|
|
1865
2025
|
)
|
|
1866
2026
|
|
|
1867
2027
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
1868
|
-
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)
|
|
1869
2032
|
|
|
1870
2033
|
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
1871
2034
|
|
|
1872
2035
|
const [forwardedProps, variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
1873
|
-
return splitProps(combinedProps,
|
|
2036
|
+
return splitProps(combinedProps, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
1874
2037
|
}, [combinedProps])
|
|
1875
2038
|
|
|
1876
2039
|
function recipeClass() {
|
|
1877
2040
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1878
|
-
const compoundVariantStyles =
|
|
1879
|
-
return cx(
|
|
2041
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
|
|
2042
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
|
|
1880
2043
|
}
|
|
1881
2044
|
|
|
1882
2045
|
function cvaClass() {
|
|
1883
2046
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
1884
|
-
const cvaStyles =
|
|
2047
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
1885
2048
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
|
|
1886
2049
|
}
|
|
1887
2050
|
|
|
@@ -1897,8 +2060,13 @@ function generateReactJsxFactory(ctx) {
|
|
|
1897
2060
|
})
|
|
1898
2061
|
})
|
|
1899
2062
|
|
|
1900
|
-
const name = (
|
|
2063
|
+
const name = getDisplayName(Dynamic)
|
|
2064
|
+
|
|
1901
2065
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2066
|
+
${componentName}.__cva__ = cvaFn
|
|
2067
|
+
${componentName}.__base__ = Dynamic
|
|
2068
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
2069
|
+
|
|
1902
2070
|
return ${componentName}
|
|
1903
2071
|
}
|
|
1904
2072
|
|
|
@@ -1925,8 +2093,8 @@ function generateReactJsxFactory(ctx) {
|
|
|
1925
2093
|
}
|
|
1926
2094
|
|
|
1927
2095
|
// src/artifacts/react-jsx/pattern.ts
|
|
1928
|
-
var
|
|
1929
|
-
var
|
|
2096
|
+
var import_outdent26 = require("outdent");
|
|
2097
|
+
var import_ts_pattern7 = require("ts-pattern");
|
|
1930
2098
|
function generateReactJsxPattern(ctx) {
|
|
1931
2099
|
const { typeName, factoryName } = ctx.jsx;
|
|
1932
2100
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1934,20 +2102,20 @@ function generateReactJsxPattern(ctx) {
|
|
|
1934
2102
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1935
2103
|
return {
|
|
1936
2104
|
name: dashName,
|
|
1937
|
-
js:
|
|
2105
|
+
js: import_outdent26.outdent`
|
|
1938
2106
|
import { createElement, forwardRef } from 'react'
|
|
1939
2107
|
${ctx.file.import(factoryName, "./factory")}
|
|
1940
2108
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
1941
2109
|
|
|
1942
2110
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1943
|
-
${(0,
|
|
2111
|
+
${(0, import_ts_pattern7.match)(props.length).with(
|
|
1944
2112
|
0,
|
|
1945
|
-
() =>
|
|
2113
|
+
() => import_outdent26.outdent`
|
|
1946
2114
|
const styleProps = ${styleFnName}()
|
|
1947
2115
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1948
2116
|
`
|
|
1949
2117
|
).otherwise(
|
|
1950
|
-
() =>
|
|
2118
|
+
() => import_outdent26.outdent`
|
|
1951
2119
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1952
2120
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1953
2121
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1955,7 +2123,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1955
2123
|
)}
|
|
1956
2124
|
})
|
|
1957
2125
|
`,
|
|
1958
|
-
dts:
|
|
2126
|
+
dts: import_outdent26.outdent`
|
|
1959
2127
|
import type { FunctionComponent } from 'react'
|
|
1960
2128
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
1961
2129
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -1971,20 +2139,25 @@ function generateReactJsxPattern(ctx) {
|
|
|
1971
2139
|
}
|
|
1972
2140
|
|
|
1973
2141
|
// src/artifacts/react-jsx/types.ts
|
|
1974
|
-
var
|
|
2142
|
+
var import_outdent27 = require("outdent");
|
|
1975
2143
|
function generateReactJsxTypes(ctx) {
|
|
1976
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2144
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
1977
2145
|
return {
|
|
1978
|
-
jsxFactory:
|
|
2146
|
+
jsxFactory: import_outdent27.outdent`
|
|
1979
2147
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
1980
2148
|
export declare const ${factoryName}: ${upperName}
|
|
1981
2149
|
`,
|
|
1982
|
-
jsxType:
|
|
2150
|
+
jsxType: import_outdent27.outdent`
|
|
1983
2151
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
1984
|
-
${ctx.file.importType("Assign, DistributiveOmit, JsxHTMLProps, JsxStyleProps", "./system-types")}
|
|
1985
2152
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2153
|
+
${ctx.file.importType(
|
|
2154
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
2155
|
+
"./system-types"
|
|
2156
|
+
)}
|
|
1986
2157
|
|
|
1987
|
-
|
|
2158
|
+
interface Dict {
|
|
2159
|
+
[k: string]: unknown
|
|
2160
|
+
}
|
|
1988
2161
|
|
|
1989
2162
|
export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
|
|
1990
2163
|
ref?: Ref<ElementRef<T>>
|
|
@@ -1995,7 +2168,9 @@ export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
|
1995
2168
|
displayName?: string
|
|
1996
2169
|
}
|
|
1997
2170
|
|
|
1998
|
-
interface RecipeFn {
|
|
2171
|
+
interface RecipeFn {
|
|
2172
|
+
__type: any
|
|
2173
|
+
}
|
|
1999
2174
|
|
|
2000
2175
|
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2001
2176
|
dataAttr?: boolean
|
|
@@ -2005,49 +2180,66 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
2005
2180
|
|
|
2006
2181
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
2007
2182
|
|
|
2008
|
-
|
|
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 {
|
|
2009
2188
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2010
|
-
<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<
|
|
2011
2190
|
T,
|
|
2012
2191
|
RecipeSelection<P>
|
|
2013
2192
|
>
|
|
2014
|
-
<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']>
|
|
2015
2194
|
}
|
|
2016
2195
|
|
|
2017
|
-
type JsxElements = {
|
|
2196
|
+
export type JsxElements = {
|
|
2197
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
2198
|
+
}
|
|
2018
2199
|
|
|
2019
2200
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2020
2201
|
|
|
2021
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
|
|
2022
2205
|
`
|
|
2023
2206
|
};
|
|
2024
2207
|
}
|
|
2025
2208
|
|
|
2026
2209
|
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
2027
|
-
var
|
|
2210
|
+
var import_outdent28 = require("outdent");
|
|
2028
2211
|
function generateReactJsxStringLiteralFactory(ctx) {
|
|
2029
2212
|
const { factoryName, componentName } = ctx.jsx;
|
|
2030
2213
|
return {
|
|
2031
|
-
js:
|
|
2214
|
+
js: import_outdent28.outdent`
|
|
2032
2215
|
import { createElement, forwardRef } from 'react'
|
|
2216
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2033
2217
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2034
2218
|
|
|
2035
2219
|
function createStyledFn(Dynamic) {
|
|
2036
2220
|
return function styledFn(template) {
|
|
2037
|
-
const
|
|
2221
|
+
const styles = css.raw(template)
|
|
2222
|
+
|
|
2038
2223
|
const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
|
|
2039
|
-
|
|
2040
|
-
|
|
2224
|
+
const { as: Element = Dynamic.__base__ || Dynamic, ...elementProps } = props
|
|
2225
|
+
|
|
2226
|
+
function classes() {
|
|
2227
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
2228
|
+
}
|
|
2041
2229
|
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2230
|
+
return createElement(Element, {
|
|
2231
|
+
ref,
|
|
2232
|
+
...elementProps,
|
|
2233
|
+
className: classes(),
|
|
2234
|
+
})
|
|
2047
2235
|
})
|
|
2048
2236
|
|
|
2049
|
-
const name = (
|
|
2237
|
+
const name = getDisplayName(Dynamic)
|
|
2238
|
+
|
|
2050
2239
|
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2240
|
+
${componentName}.__styles__ = styles
|
|
2241
|
+
${componentName}.__base__ = Dynamic
|
|
2242
|
+
|
|
2051
2243
|
return ${componentName}
|
|
2052
2244
|
}
|
|
2053
2245
|
}
|
|
@@ -2075,19 +2267,21 @@ function generateReactJsxStringLiteralFactory(ctx) {
|
|
|
2075
2267
|
}
|
|
2076
2268
|
|
|
2077
2269
|
// src/artifacts/react-jsx/types.string-literal.ts
|
|
2078
|
-
var
|
|
2270
|
+
var import_outdent29 = require("outdent");
|
|
2079
2271
|
function generateReactJsxStringLiteralTypes(ctx) {
|
|
2080
2272
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2081
2273
|
return {
|
|
2082
|
-
jsxFactory:
|
|
2274
|
+
jsxFactory: import_outdent29.outdent`
|
|
2083
2275
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2084
2276
|
export declare const ${factoryName}: ${upperName}
|
|
2085
2277
|
`,
|
|
2086
|
-
jsxType:
|
|
2278
|
+
jsxType: import_outdent29.outdent`
|
|
2087
2279
|
import type { ComponentPropsWithoutRef, ElementType, ElementRef, Ref } from 'react'
|
|
2088
2280
|
${ctx.file.importType("DistributiveOmit", "../types/system-types")}
|
|
2089
2281
|
|
|
2090
|
-
|
|
2282
|
+
interface Dict {
|
|
2283
|
+
[k: string]: unknown
|
|
2284
|
+
}
|
|
2091
2285
|
|
|
2092
2286
|
export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
|
|
2093
2287
|
ref?: Ref<ElementRef<T>>
|
|
@@ -2098,11 +2292,13 @@ export type ${componentName}<T extends ElementType> = {
|
|
|
2098
2292
|
displayName?: string
|
|
2099
2293
|
}
|
|
2100
2294
|
|
|
2101
|
-
interface JsxFactory {
|
|
2295
|
+
export interface JsxFactory {
|
|
2102
2296
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2103
2297
|
}
|
|
2104
2298
|
|
|
2105
|
-
type JsxElements = {
|
|
2299
|
+
export type JsxElements = {
|
|
2300
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
2301
|
+
}
|
|
2106
2302
|
|
|
2107
2303
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2108
2304
|
|
|
@@ -2112,19 +2308,21 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2112
2308
|
}
|
|
2113
2309
|
|
|
2114
2310
|
// src/artifacts/solid-jsx/jsx.ts
|
|
2115
|
-
var
|
|
2311
|
+
var import_outdent30 = require("outdent");
|
|
2116
2312
|
function generateSolidJsxFactory(ctx) {
|
|
2117
2313
|
const { componentName, factoryName } = ctx.jsx;
|
|
2118
2314
|
return {
|
|
2119
|
-
js:
|
|
2315
|
+
js: import_outdent30.outdent`
|
|
2120
2316
|
import { Dynamic } from 'solid-js/web'
|
|
2121
2317
|
import { createMemo, mergeProps, splitProps } from 'solid-js'
|
|
2122
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")}
|
|
2123
2324
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2124
2325
|
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
2125
|
-
${ctx.file.import("isCssProperty, allCssProperties", "./is-valid-prop")}
|
|
2126
|
-
|
|
2127
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2128
2326
|
|
|
2129
2327
|
function styledFn(element, configOrCva = {}, options = {}) {
|
|
2130
2328
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
@@ -2137,28 +2335,32 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2137
2335
|
options.defaultProps,
|
|
2138
2336
|
)
|
|
2139
2337
|
|
|
2140
|
-
|
|
2141
|
-
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
|
+
|
|
2142
2344
|
const forwardedKeys = createMemo(() => Object.keys(props).filter(shouldForwardProp))
|
|
2143
2345
|
|
|
2144
2346
|
const [localProps, forwardedProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
2145
2347
|
mergedProps,
|
|
2146
2348
|
['as', 'class', 'className'],
|
|
2147
2349
|
forwardedKeys(),
|
|
2148
|
-
|
|
2350
|
+
__cvaFn__.variantKeys,
|
|
2149
2351
|
allCssProperties,
|
|
2150
2352
|
normalizeHTMLProps.keys
|
|
2151
2353
|
)
|
|
2152
2354
|
|
|
2153
2355
|
function recipeClass() {
|
|
2154
2356
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2155
|
-
const compoundVariantStyles =
|
|
2156
|
-
return cx(
|
|
2357
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
2358
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2157
2359
|
}
|
|
2158
2360
|
|
|
2159
2361
|
function cvaClass() {
|
|
2160
2362
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2161
|
-
const cvaStyles =
|
|
2363
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
2162
2364
|
return cx(css(cvaStyles, propStyles, cssStyles), localProps.class, localProps.className)
|
|
2163
2365
|
}
|
|
2164
2366
|
|
|
@@ -2185,6 +2387,15 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2185
2387
|
)
|
|
2186
2388
|
)
|
|
2187
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}
|
|
2188
2399
|
}
|
|
2189
2400
|
|
|
2190
2401
|
function createJsxFactory() {
|
|
@@ -2209,8 +2420,8 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2209
2420
|
}
|
|
2210
2421
|
|
|
2211
2422
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2212
|
-
var
|
|
2213
|
-
var
|
|
2423
|
+
var import_outdent31 = require("outdent");
|
|
2424
|
+
var import_ts_pattern8 = require("ts-pattern");
|
|
2214
2425
|
function generateSolidJsxPattern(ctx) {
|
|
2215
2426
|
const { typeName, factoryName } = ctx.jsx;
|
|
2216
2427
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2218,21 +2429,21 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2218
2429
|
const { description, jsxElement = "div" } = pattern.config;
|
|
2219
2430
|
return {
|
|
2220
2431
|
name: dashName,
|
|
2221
|
-
js:
|
|
2432
|
+
js: import_outdent31.outdent`
|
|
2222
2433
|
import { splitProps, mergeProps } from 'solid-js'
|
|
2223
2434
|
import { createComponent } from 'solid-js/web'
|
|
2224
2435
|
${ctx.file.import(factoryName, "./factory")}
|
|
2225
2436
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
2226
2437
|
|
|
2227
2438
|
export function ${jsxName}(props) {
|
|
2228
|
-
${(0,
|
|
2439
|
+
${(0, import_ts_pattern8.match)(props.length).with(
|
|
2229
2440
|
0,
|
|
2230
|
-
() =>
|
|
2441
|
+
() => import_outdent31.outdent`
|
|
2231
2442
|
const styleProps = ${styleFnName}()
|
|
2232
2443
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
2233
2444
|
`
|
|
2234
2445
|
).otherwise(
|
|
2235
|
-
() =>
|
|
2446
|
+
() => import_outdent31.outdent`
|
|
2236
2447
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
2237
2448
|
const styleProps = ${styleFnName}(patternProps)
|
|
2238
2449
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -2240,7 +2451,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2240
2451
|
)}
|
|
2241
2452
|
}
|
|
2242
2453
|
`,
|
|
2243
|
-
dts:
|
|
2454
|
+
dts: import_outdent31.outdent`
|
|
2244
2455
|
import type { Component } from 'solid-js'
|
|
2245
2456
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
2246
2457
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -2256,31 +2467,38 @@ function generateSolidJsxPattern(ctx) {
|
|
|
2256
2467
|
}
|
|
2257
2468
|
|
|
2258
2469
|
// src/artifacts/solid-jsx/types.ts
|
|
2259
|
-
var
|
|
2470
|
+
var import_outdent32 = require("outdent");
|
|
2260
2471
|
function generateSolidJsxTypes(ctx) {
|
|
2261
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2472
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
2262
2473
|
return {
|
|
2263
|
-
jsxFactory:
|
|
2474
|
+
jsxFactory: import_outdent32.outdent`
|
|
2264
2475
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2265
2476
|
export declare const ${factoryName}: ${upperName}
|
|
2266
2477
|
`,
|
|
2267
|
-
jsxType:
|
|
2478
|
+
jsxType: import_outdent32.outdent`
|
|
2268
2479
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
2269
|
-
${ctx.file.importType("Assign, JsxStyleProps, JsxHTMLProps", "./system-types")}
|
|
2270
2480
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2481
|
+
${ctx.file.importType(
|
|
2482
|
+
"Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty",
|
|
2483
|
+
"./system-types"
|
|
2484
|
+
)}
|
|
2271
2485
|
|
|
2272
|
-
|
|
2486
|
+
interface Dict {
|
|
2487
|
+
[k: string]: unknown
|
|
2488
|
+
}
|
|
2273
2489
|
|
|
2274
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2490
|
+
export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2275
2491
|
|
|
2276
2492
|
export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
|
|
2277
2493
|
(props: JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P>>): JSX.Element
|
|
2278
2494
|
displayName?: string
|
|
2279
2495
|
}
|
|
2280
2496
|
|
|
2281
|
-
interface RecipeFn {
|
|
2497
|
+
interface RecipeFn {
|
|
2498
|
+
__type: any
|
|
2499
|
+
}
|
|
2282
2500
|
|
|
2283
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2501
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
2284
2502
|
dataAttr?: boolean
|
|
2285
2503
|
defaultProps?: TProps
|
|
2286
2504
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -2288,41 +2506,51 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
2288
2506
|
|
|
2289
2507
|
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T>, P>;
|
|
2290
2508
|
|
|
2291
|
-
|
|
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 {
|
|
2292
2514
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2293
|
-
<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<
|
|
2294
2516
|
T,
|
|
2295
2517
|
RecipeSelection<P>
|
|
2296
2518
|
>
|
|
2297
|
-
<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']>
|
|
2298
2520
|
}
|
|
2299
2521
|
|
|
2300
|
-
type JsxElements = {
|
|
2522
|
+
export type JsxElements = {
|
|
2523
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
|
|
2524
|
+
}
|
|
2301
2525
|
|
|
2302
2526
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2303
2527
|
|
|
2304
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
|
|
2305
2531
|
`
|
|
2306
2532
|
};
|
|
2307
2533
|
}
|
|
2308
2534
|
|
|
2309
2535
|
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
2310
|
-
var
|
|
2536
|
+
var import_outdent33 = require("outdent");
|
|
2311
2537
|
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
2312
2538
|
const { componentName, factoryName } = ctx.jsx;
|
|
2313
2539
|
return {
|
|
2314
|
-
js:
|
|
2540
|
+
js: import_outdent33.outdent`
|
|
2315
2541
|
import { mergeProps, splitProps } from 'solid-js'
|
|
2316
2542
|
import { Dynamic, createComponent } from 'solid-js/web'
|
|
2543
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2317
2544
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2318
2545
|
|
|
2319
2546
|
function createStyled(element) {
|
|
2320
2547
|
return function styledFn(template) {
|
|
2321
|
-
const
|
|
2322
|
-
return function ${componentName}(props) {
|
|
2323
|
-
const mergedProps = mergeProps({ as: element }, props)
|
|
2324
|
-
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2548
|
+
const styles = css.raw(template)
|
|
2325
2549
|
|
|
2550
|
+
const ${componentName} = (props) => {
|
|
2551
|
+
const mergedProps = mergeProps({ as: element.__base__ || element }, props)
|
|
2552
|
+
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2553
|
+
|
|
2326
2554
|
return createComponent(
|
|
2327
2555
|
Dynamic,
|
|
2328
2556
|
mergeProps(
|
|
@@ -2331,13 +2559,21 @@ function createStyled(element) {
|
|
|
2331
2559
|
return localProps.as
|
|
2332
2560
|
},
|
|
2333
2561
|
get class() {
|
|
2334
|
-
return cx(
|
|
2562
|
+
return cx(css(element.__styles__, styles), localProps.class)
|
|
2335
2563
|
},
|
|
2336
2564
|
},
|
|
2337
2565
|
elementProps,
|
|
2338
2566
|
),
|
|
2339
2567
|
)
|
|
2340
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}
|
|
2341
2577
|
}
|
|
2342
2578
|
}
|
|
2343
2579
|
|
|
@@ -2363,31 +2599,35 @@ export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
|
|
|
2363
2599
|
}
|
|
2364
2600
|
|
|
2365
2601
|
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2366
|
-
var
|
|
2602
|
+
var import_outdent34 = require("outdent");
|
|
2367
2603
|
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2368
2604
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2369
2605
|
return {
|
|
2370
|
-
jsxFactory:
|
|
2606
|
+
jsxFactory: import_outdent34.outdent`
|
|
2371
2607
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2372
2608
|
export declare const ${factoryName}: ${upperName}
|
|
2373
2609
|
`,
|
|
2374
|
-
jsxType:
|
|
2610
|
+
jsxType: import_outdent34.outdent`
|
|
2375
2611
|
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2376
2612
|
|
|
2377
|
-
|
|
2613
|
+
interface Dict {
|
|
2614
|
+
[k: string]: unknown
|
|
2615
|
+
}
|
|
2378
2616
|
|
|
2379
|
-
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2617
|
+
export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2380
2618
|
|
|
2381
2619
|
export type ${componentName}<T extends ElementType> = {
|
|
2382
2620
|
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
2383
2621
|
displayName?: string
|
|
2384
2622
|
}
|
|
2385
2623
|
|
|
2386
|
-
interface JsxFactory {
|
|
2624
|
+
export interface JsxFactory {
|
|
2387
2625
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2388
2626
|
}
|
|
2389
2627
|
|
|
2390
|
-
type JsxElements = {
|
|
2628
|
+
export type JsxElements = {
|
|
2629
|
+
[K in keyof JSX.IntrinsicElements]: ${componentName}<K>
|
|
2630
|
+
}
|
|
2391
2631
|
|
|
2392
2632
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2393
2633
|
|
|
@@ -2397,18 +2637,20 @@ export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
|
2397
2637
|
}
|
|
2398
2638
|
|
|
2399
2639
|
// src/artifacts/vue-jsx/jsx.ts
|
|
2400
|
-
var
|
|
2640
|
+
var import_outdent35 = require("outdent");
|
|
2401
2641
|
function generateVueJsxFactory(ctx) {
|
|
2402
|
-
const { factoryName } = ctx.jsx;
|
|
2642
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
2403
2643
|
return {
|
|
2404
|
-
js:
|
|
2644
|
+
js: import_outdent35.outdent`
|
|
2405
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")}
|
|
2406
2651
|
${ctx.file.import("css, cx, cva", "../css/index")}
|
|
2407
2652
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
2408
|
-
${ctx.file.import("isCssProperty", "./is-valid-prop")}
|
|
2409
2653
|
|
|
2410
|
-
const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
2411
|
-
|
|
2412
2654
|
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
2413
2655
|
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
2414
2656
|
|
|
@@ -2420,30 +2662,33 @@ function generateVueJsxFactory(ctx) {
|
|
|
2420
2662
|
options.defaultProps,
|
|
2421
2663
|
)
|
|
2422
2664
|
|
|
2423
|
-
const name = (
|
|
2665
|
+
const name = getDisplayName(Dynamic)
|
|
2424
2666
|
|
|
2425
|
-
|
|
2667
|
+
const ${componentName} = defineComponent({
|
|
2426
2668
|
name: \`${factoryName}.\${name}\`,
|
|
2427
2669
|
inheritAttrs: false,
|
|
2428
|
-
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2670
|
+
props: { as: { type: [String, Object], default: Dynamic.__base__ || Dynamic } },
|
|
2429
2671
|
setup(props, { slots, attrs }) {
|
|
2672
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
2673
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
2674
|
+
|
|
2430
2675
|
const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
|
|
2431
2676
|
|
|
2432
2677
|
const splittedProps = computed(() => {
|
|
2433
|
-
return splitProps(combinedProps.value, shouldForwardProp,
|
|
2678
|
+
return splitProps(combinedProps.value, shouldForwardProp, __cvaFn__.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
2434
2679
|
})
|
|
2435
2680
|
|
|
2436
2681
|
const recipeClass = computed(() => {
|
|
2437
2682
|
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2438
2683
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2439
|
-
const compoundVariantStyles =
|
|
2440
|
-
return cx(
|
|
2684
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
|
|
2685
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2441
2686
|
})
|
|
2442
2687
|
|
|
2443
2688
|
const cvaClass = computed(() => {
|
|
2444
2689
|
const [_forwardedProps, variantProps, styleProps, _htmlProps, _elementProps] = splittedProps.value
|
|
2445
2690
|
const { css: cssStyles, ...propStyles } = styleProps
|
|
2446
|
-
const cvaStyles =
|
|
2691
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
2447
2692
|
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className)
|
|
2448
2693
|
})
|
|
2449
2694
|
|
|
@@ -2464,6 +2709,13 @@ function generateVueJsxFactory(ctx) {
|
|
|
2464
2709
|
}
|
|
2465
2710
|
},
|
|
2466
2711
|
})
|
|
2712
|
+
|
|
2713
|
+
${componentName}.displayName = \`${factoryName}.\${name}\`
|
|
2714
|
+
${componentName}.__cva__ = cvaFn
|
|
2715
|
+
${componentName}.__base__ = Dynamic
|
|
2716
|
+
${componentName}.__shouldForwardProps__ = shouldForwardProp
|
|
2717
|
+
|
|
2718
|
+
return ${componentName}
|
|
2467
2719
|
}
|
|
2468
2720
|
|
|
2469
2721
|
function createJsxFactory() {
|
|
@@ -2484,25 +2736,30 @@ function generateVueJsxFactory(ctx) {
|
|
|
2484
2736
|
}
|
|
2485
2737
|
|
|
2486
2738
|
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2487
|
-
var
|
|
2739
|
+
var import_outdent36 = require("outdent");
|
|
2488
2740
|
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2489
|
-
const { factoryName } = ctx.jsx;
|
|
2741
|
+
const { componentName, factoryName } = ctx.jsx;
|
|
2490
2742
|
return {
|
|
2491
|
-
js:
|
|
2743
|
+
js: import_outdent36.outdent`
|
|
2492
2744
|
import { defineComponent, h, computed } from 'vue'
|
|
2745
|
+
${ctx.file.import("getDisplayName", "./factory-helper")}
|
|
2493
2746
|
${ctx.file.import("css, cx", "../css/index")}
|
|
2494
2747
|
|
|
2495
2748
|
function createStyled(Dynamic) {
|
|
2496
|
-
const name = (
|
|
2749
|
+
const name = getDisplayName(Dynamic)
|
|
2497
2750
|
|
|
2498
2751
|
function styledFn(template) {
|
|
2499
|
-
const
|
|
2500
|
-
|
|
2752
|
+
const styles = css.raw(template)
|
|
2753
|
+
|
|
2754
|
+
const ${componentName} = defineComponent({
|
|
2501
2755
|
name: \`${factoryName}.\${name}\`,
|
|
2502
2756
|
inheritAttrs: false,
|
|
2503
2757
|
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2504
2758
|
setup(props, { slots, attrs }) {
|
|
2505
|
-
const classes = computed(() =>
|
|
2759
|
+
const classes = computed(() => {
|
|
2760
|
+
return cx(css(Dynamic.__styles__, styles), elementProps.className)
|
|
2761
|
+
})
|
|
2762
|
+
|
|
2506
2763
|
return () => {
|
|
2507
2764
|
return h(
|
|
2508
2765
|
props.as,
|
|
@@ -2515,6 +2772,11 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2515
2772
|
}
|
|
2516
2773
|
},
|
|
2517
2774
|
})
|
|
2775
|
+
|
|
2776
|
+
${componentName}.__styles__ = styles
|
|
2777
|
+
${componentName}.__base__ = element
|
|
2778
|
+
|
|
2779
|
+
return ${componentName}
|
|
2518
2780
|
}
|
|
2519
2781
|
}
|
|
2520
2782
|
|
|
@@ -2540,7 +2802,7 @@ function generateVueJsxStringLiteralFactory(ctx) {
|
|
|
2540
2802
|
}
|
|
2541
2803
|
|
|
2542
2804
|
// src/artifacts/vue-jsx/pattern.ts
|
|
2543
|
-
var
|
|
2805
|
+
var import_outdent37 = require("outdent");
|
|
2544
2806
|
function generateVueJsxPattern(ctx) {
|
|
2545
2807
|
const { typeName, factoryName } = ctx.jsx;
|
|
2546
2808
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -2549,7 +2811,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2549
2811
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
2550
2812
|
return {
|
|
2551
2813
|
name: dashName,
|
|
2552
|
-
js:
|
|
2814
|
+
js: import_outdent37.outdent`
|
|
2553
2815
|
import { defineComponent, h, computed } from 'vue'
|
|
2554
2816
|
${ctx.file.import(factoryName, "./factory")}
|
|
2555
2817
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -2567,7 +2829,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
2567
2829
|
}
|
|
2568
2830
|
})
|
|
2569
2831
|
`,
|
|
2570
|
-
dts:
|
|
2832
|
+
dts: import_outdent37.outdent`
|
|
2571
2833
|
import type { FunctionalComponent } from 'vue'
|
|
2572
2834
|
${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
|
|
2573
2835
|
${ctx.file.importType(typeName, "../types/jsx")}
|
|
@@ -2583,23 +2845,27 @@ function generateVueJsxPattern(ctx) {
|
|
|
2583
2845
|
}
|
|
2584
2846
|
|
|
2585
2847
|
// src/artifacts/vue-jsx/types.ts
|
|
2586
|
-
var
|
|
2848
|
+
var import_outdent38 = require("outdent");
|
|
2587
2849
|
function generateVueJsxTypes(ctx) {
|
|
2588
|
-
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2850
|
+
const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
|
|
2589
2851
|
return {
|
|
2590
|
-
jsxFactory:
|
|
2852
|
+
jsxFactory: import_outdent38.outdent`
|
|
2591
2853
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2592
2854
|
|
|
2593
2855
|
export declare const ${factoryName}: ${upperName}
|
|
2594
2856
|
`,
|
|
2595
|
-
jsxType:
|
|
2857
|
+
jsxType: import_outdent38.outdent`
|
|
2596
2858
|
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2597
2859
|
|
|
2598
2860
|
${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
|
|
2599
|
-
${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
|
|
2600
2867
|
|
|
2601
|
-
type
|
|
2602
|
-
type ElementType = IntrinsicElement | Component
|
|
2868
|
+
export type ElementType = IntrinsicElement | Component
|
|
2603
2869
|
|
|
2604
2870
|
export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2605
2871
|
? NativeElements[T]
|
|
@@ -2607,13 +2873,15 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
|
2607
2873
|
? Props
|
|
2608
2874
|
: never
|
|
2609
2875
|
|
|
2610
|
-
|
|
2611
|
-
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>>
|
|
2612
2878
|
> {}
|
|
2613
2879
|
|
|
2614
|
-
interface RecipeFn {
|
|
2880
|
+
interface RecipeFn {
|
|
2881
|
+
__type: any
|
|
2882
|
+
}
|
|
2615
2883
|
|
|
2616
|
-
interface JsxFactoryOptions<TProps extends Dict> {
|
|
2884
|
+
export interface JsxFactoryOptions<TProps extends Dict> {
|
|
2617
2885
|
dataAttr?: boolean
|
|
2618
2886
|
defaultProps?: TProps
|
|
2619
2887
|
shouldForwardProp?(prop: string, variantKeys: string[]): boolean
|
|
@@ -2621,39 +2889,48 @@ interface JsxFactoryOptions<TProps extends Dict> {
|
|
|
2621
2889
|
|
|
2622
2890
|
export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T>, Assign<JsxStyleProps, P['__type']>>;
|
|
2623
2891
|
|
|
2624
|
-
|
|
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 {
|
|
2625
2897
|
<T extends ElementType>(component: T): ${componentName}<T, {}>
|
|
2626
|
-
<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<
|
|
2627
2899
|
T,
|
|
2628
2900
|
RecipeSelection<P>
|
|
2629
2901
|
>
|
|
2630
|
-
<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']>
|
|
2631
2903
|
}
|
|
2632
2904
|
|
|
2633
|
-
type JsxElements = {
|
|
2905
|
+
export type JsxElements = {
|
|
2906
|
+
[K in IntrinsicElement]: ${componentName}<K, {}>
|
|
2907
|
+
}
|
|
2634
2908
|
|
|
2635
2909
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2636
2910
|
|
|
2637
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
|
|
2638
2914
|
`
|
|
2639
2915
|
};
|
|
2640
2916
|
}
|
|
2641
2917
|
|
|
2642
2918
|
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2643
|
-
var
|
|
2919
|
+
var import_outdent39 = require("outdent");
|
|
2644
2920
|
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2645
2921
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2646
2922
|
return {
|
|
2647
|
-
jsxFactory:
|
|
2923
|
+
jsxFactory: import_outdent39.outdent`
|
|
2648
2924
|
${ctx.file.importType(upperName, "../types/jsx")}
|
|
2649
2925
|
|
|
2650
2926
|
export declare const ${factoryName}: ${upperName}
|
|
2651
2927
|
`,
|
|
2652
|
-
jsxType:
|
|
2928
|
+
jsxType: import_outdent39.outdent`
|
|
2653
2929
|
import type { Component, FunctionalComponent, NativeElements } from 'vue'
|
|
2654
2930
|
|
|
2655
|
-
type IntrinsicElement = keyof NativeElements
|
|
2656
|
-
|
|
2931
|
+
export type IntrinsicElement = keyof NativeElements
|
|
2932
|
+
|
|
2933
|
+
export type ElementType = IntrinsicElement | Component
|
|
2657
2934
|
|
|
2658
2935
|
export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
2659
2936
|
? NativeElements[T]
|
|
@@ -2661,14 +2938,16 @@ export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
|
|
|
2661
2938
|
? Props
|
|
2662
2939
|
: never
|
|
2663
2940
|
|
|
2664
|
-
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2941
|
+
export type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2665
2942
|
>
|
|
2666
2943
|
|
|
2667
|
-
interface JsxFactory {
|
|
2944
|
+
export interface JsxFactory {
|
|
2668
2945
|
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2669
2946
|
}
|
|
2670
2947
|
|
|
2671
|
-
type JsxElements = {
|
|
2948
|
+
export type JsxElements = {
|
|
2949
|
+
[K in IntrinsicElement]: ${componentName}<K>
|
|
2950
|
+
}
|
|
2672
2951
|
|
|
2673
2952
|
export type ${upperName} = JsxFactory & JsxElements
|
|
2674
2953
|
|
|
@@ -2785,7 +3064,7 @@ var csstype_d_ts_default = {
|
|
|
2785
3064
|
|
|
2786
3065
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2787
3066
|
var system_types_d_ts_default = {
|
|
2788
|
-
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"
|
|
2789
3068
|
};
|
|
2790
3069
|
|
|
2791
3070
|
// src/artifacts/generated/composition.d.ts.json
|
|
@@ -2814,7 +3093,7 @@ var selectors_d_ts_default = {
|
|
|
2814
3093
|
};
|
|
2815
3094
|
|
|
2816
3095
|
// src/artifacts/types/generated.ts
|
|
2817
|
-
var
|
|
3096
|
+
var import_ts_pattern9 = require("ts-pattern");
|
|
2818
3097
|
var jsxStyleProps = "export type JsxStyleProps = StyleProps & WithCss";
|
|
2819
3098
|
function getGeneratedTypes(ctx) {
|
|
2820
3099
|
const rewriteImports = (code) => code.replace(/import\s+type\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g, ctx.file.importType("$1", "$2"));
|
|
@@ -2826,15 +3105,15 @@ function getGeneratedTypes(ctx) {
|
|
|
2826
3105
|
composition: rewriteImports(composition_d_ts_default.content),
|
|
2827
3106
|
selectors: rewriteImports(selectors_d_ts_default.content),
|
|
2828
3107
|
system: rewriteImports(
|
|
2829
|
-
(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()
|
|
2830
3109
|
)
|
|
2831
3110
|
};
|
|
2832
3111
|
}
|
|
2833
3112
|
|
|
2834
3113
|
// src/artifacts/types/main.ts
|
|
2835
|
-
var
|
|
3114
|
+
var import_outdent40 = require("outdent");
|
|
2836
3115
|
var generateTypesEntry = (ctx) => ({
|
|
2837
|
-
global:
|
|
3116
|
+
global: import_outdent40.outdent`
|
|
2838
3117
|
// @ts-nocheck
|
|
2839
3118
|
import type * as Panda from '@pandacss/dev'
|
|
2840
3119
|
${ctx.file.importType("RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig", "./recipe")}
|
|
@@ -2855,7 +3134,7 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2855
3134
|
}
|
|
2856
3135
|
`,
|
|
2857
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'`
|
|
2858
|
-
index:
|
|
3137
|
+
index: import_outdent40.outdent`
|
|
2859
3138
|
import '${ctx.file.extDts("./global")}'
|
|
2860
3139
|
${ctx.file.exportTypeStar("./conditions")}
|
|
2861
3140
|
${ctx.file.exportTypeStar("./pattern")}
|
|
@@ -2865,13 +3144,13 @@ var generateTypesEntry = (ctx) => ({
|
|
|
2865
3144
|
${ctx.file.exportTypeStar("./style-props")}
|
|
2866
3145
|
|
|
2867
3146
|
`,
|
|
2868
|
-
helpers:
|
|
3147
|
+
helpers: import_outdent40.outdent`
|
|
2869
3148
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2870
3149
|
`
|
|
2871
3150
|
});
|
|
2872
3151
|
|
|
2873
3152
|
// src/artifacts/types/prop-types.ts
|
|
2874
|
-
var
|
|
3153
|
+
var import_outdent41 = require("outdent");
|
|
2875
3154
|
function generatePropTypes(ctx) {
|
|
2876
3155
|
const {
|
|
2877
3156
|
config: { strictTokens },
|
|
@@ -2879,7 +3158,7 @@ function generatePropTypes(ctx) {
|
|
|
2879
3158
|
} = ctx;
|
|
2880
3159
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2881
3160
|
const result = [
|
|
2882
|
-
|
|
3161
|
+
import_outdent41.outdent`
|
|
2883
3162
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
2884
3163
|
${ctx.file.importType("CssProperties", "./system-types")}
|
|
2885
3164
|
${ctx.file.importType("Tokens", "../tokens/index")}
|
|
@@ -2902,7 +3181,7 @@ function generatePropTypes(ctx) {
|
|
|
2902
3181
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2903
3182
|
});
|
|
2904
3183
|
result.push("}");
|
|
2905
|
-
return
|
|
3184
|
+
return import_outdent41.outdent`
|
|
2906
3185
|
${result.join("\n")}
|
|
2907
3186
|
|
|
2908
3187
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2915,10 +3194,10 @@ function generatePropTypes(ctx) {
|
|
|
2915
3194
|
|
|
2916
3195
|
// src/artifacts/types/style-props.ts
|
|
2917
3196
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
2918
|
-
var
|
|
3197
|
+
var import_outdent42 = __toESM(require("outdent"));
|
|
2919
3198
|
function generateStyleProps(ctx) {
|
|
2920
3199
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
2921
|
-
return
|
|
3200
|
+
return import_outdent42.default`
|
|
2922
3201
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
2923
3202
|
${ctx.file.importType("PropertyValue", "./prop-type")}
|
|
2924
3203
|
${ctx.file.importType("Token", "../tokens/index")}
|
|
@@ -2935,7 +3214,7 @@ function generateStyleProps(ctx) {
|
|
|
2935
3214
|
|
|
2936
3215
|
// src/artifacts/types/token-types.ts
|
|
2937
3216
|
var import_shared3 = require("@pandacss/shared");
|
|
2938
|
-
var
|
|
3217
|
+
var import_outdent43 = require("outdent");
|
|
2939
3218
|
var import_pluralize = __toESM(require("pluralize"));
|
|
2940
3219
|
var categories = [
|
|
2941
3220
|
"zIndex",
|
|
@@ -2986,7 +3265,7 @@ function generateTokenTypes(ctx) {
|
|
|
2986
3265
|
result.add("} & { [token: string]: never }");
|
|
2987
3266
|
set.add(Array.from(result).join("\n"));
|
|
2988
3267
|
set.add(`export type TokenCategory = ${(0, import_shared3.unionType)(categories)}`);
|
|
2989
|
-
return
|
|
3268
|
+
return import_outdent43.outdent.string(Array.from(set).join("\n\n"));
|
|
2990
3269
|
}
|
|
2991
3270
|
|
|
2992
3271
|
// src/artifacts/index.ts
|
|
@@ -3032,7 +3311,6 @@ function setupTypes(ctx) {
|
|
|
3032
3311
|
{ file: ctx.file.extDts("selectors"), code: gen.selectors },
|
|
3033
3312
|
{ file: ctx.file.extDts("composition"), code: gen.composition },
|
|
3034
3313
|
{ file: ctx.file.extDts("global"), code: entry.global },
|
|
3035
|
-
{ file: ctx.file.extDts("helpers"), code: entry.helpers },
|
|
3036
3314
|
{ file: ctx.file.extDts("recipe"), code: gen.recipe },
|
|
3037
3315
|
{ file: ctx.file.extDts("pattern"), code: gen.pattern },
|
|
3038
3316
|
{ file: ctx.file.extDts("parts"), code: gen.parts },
|
|
@@ -3095,8 +3373,8 @@ function setupRecipes(ctx) {
|
|
|
3095
3373
|
return;
|
|
3096
3374
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
3097
3375
|
const index = {
|
|
3098
|
-
js:
|
|
3099
|
-
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"))
|
|
3100
3378
|
};
|
|
3101
3379
|
return {
|
|
3102
3380
|
dir: ctx.paths.recipe,
|
|
@@ -3115,8 +3393,8 @@ function setupPatterns(ctx) {
|
|
|
3115
3393
|
if (!files)
|
|
3116
3394
|
return;
|
|
3117
3395
|
const index = {
|
|
3118
|
-
js:
|
|
3119
|
-
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"))
|
|
3120
3398
|
};
|
|
3121
3399
|
return {
|
|
3122
3400
|
dir: ctx.paths.pattern,
|
|
@@ -3135,18 +3413,19 @@ function setupJsx(ctx) {
|
|
|
3135
3413
|
const types = generateJsxTypes(ctx);
|
|
3136
3414
|
const factory = generateJsxFactory(ctx);
|
|
3137
3415
|
const patterns = generateJsxPatterns(ctx);
|
|
3416
|
+
const helpers3 = generatedJsxHelpers(ctx);
|
|
3138
3417
|
const index = {
|
|
3139
|
-
js:
|
|
3418
|
+
js: import_outdent44.default`
|
|
3140
3419
|
${ctx.file.exportStar("./factory")}
|
|
3141
3420
|
${isValidProp?.js ? ctx.file.exportStar("./is-valid-prop") : ""}
|
|
3142
|
-
${
|
|
3421
|
+
${import_outdent44.default.string(patterns.map((file) => ctx.file.exportStar(`./${file.name}`)).join("\n"))}
|
|
3143
3422
|
`,
|
|
3144
|
-
dts:
|
|
3423
|
+
dts: import_outdent44.default`
|
|
3145
3424
|
${ctx.file.exportTypeStar("./factory")}
|
|
3146
3425
|
|
|
3147
3426
|
${isValidProp?.dts ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
|
|
3148
3427
|
|
|
3149
|
-
${
|
|
3428
|
+
${import_outdent44.default.string(patterns.map((file) => ctx.file.exportTypeStar(`./${file.name}`)).join("\n"))}
|
|
3150
3429
|
|
|
3151
3430
|
${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
|
|
3152
3431
|
`
|
|
@@ -3158,6 +3437,7 @@ function setupJsx(ctx) {
|
|
|
3158
3437
|
...patterns.map((file) => ({ file: ctx.file.extDts(file.name), code: file.dts })),
|
|
3159
3438
|
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
3160
3439
|
{ file: ctx.file.extDts("is-valid-prop"), code: isValidProp?.dts },
|
|
3440
|
+
{ file: ctx.file.ext("factory-helper"), code: helpers3.js },
|
|
3161
3441
|
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
3162
3442
|
{ file: ctx.file.extDts("factory"), code: types.jsxFactory },
|
|
3163
3443
|
{ file: ctx.file.ext("index"), code: index.js },
|
|
@@ -3167,13 +3447,13 @@ function setupJsx(ctx) {
|
|
|
3167
3447
|
}
|
|
3168
3448
|
function setupCssIndex(ctx) {
|
|
3169
3449
|
const index = {
|
|
3170
|
-
js:
|
|
3450
|
+
js: import_outdent44.default`
|
|
3171
3451
|
${ctx.file.exportStar("./css")}
|
|
3172
3452
|
${ctx.file.exportStar("./cx")}
|
|
3173
3453
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./cva")}
|
|
3174
3454
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./sva")}
|
|
3175
3455
|
`,
|
|
3176
|
-
dts:
|
|
3456
|
+
dts: import_outdent44.default`
|
|
3177
3457
|
${ctx.file.exportTypeStar("./css")}
|
|
3178
3458
|
${ctx.file.exportTypeStar("./cx")}
|
|
3179
3459
|
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./cva")}
|
|
@@ -3235,6 +3515,8 @@ var generateArtifacts = (ctx) => () => {
|
|
|
3235
3515
|
].filter(Boolean).map((artifact) => {
|
|
3236
3516
|
const files = artifact?.files ?? [];
|
|
3237
3517
|
files.forEach((file) => {
|
|
3518
|
+
if (!file)
|
|
3519
|
+
return;
|
|
3238
3520
|
if (ctx.file.isTypeFile(file.file)) {
|
|
3239
3521
|
file.code = `/* eslint-disable */
|
|
3240
3522
|
${file.code}`;
|
|
@@ -3274,7 +3556,7 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3274
3556
|
// src/artifacts/css/parser-css.ts
|
|
3275
3557
|
var import_logger2 = require("@pandacss/logger");
|
|
3276
3558
|
var import_func = require("lil-fp/func");
|
|
3277
|
-
var
|
|
3559
|
+
var import_ts_pattern10 = require("ts-pattern");
|
|
3278
3560
|
var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
3279
3561
|
{ ...ctx, sheet: ctx.createSheet(), result },
|
|
3280
3562
|
(0, import_func.tap)(({ sheet, result: result2, patterns, recipes }) => {
|
|
@@ -3304,7 +3586,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3304
3586
|
const recipeConfig = recipes.getConfig(recipeName);
|
|
3305
3587
|
if (!recipeConfig)
|
|
3306
3588
|
continue;
|
|
3307
|
-
(0,
|
|
3589
|
+
(0, import_ts_pattern10.match)(recipe).with({ type: "jsx-recipe" }, () => {
|
|
3308
3590
|
recipe.data.forEach((data) => {
|
|
3309
3591
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
3310
3592
|
sheet.processStyleProps(filterProps(ctx, styleProps));
|
|
@@ -3323,7 +3605,7 @@ var generateParserCss = (ctx) => (result) => (0, import_func.pipe)(
|
|
|
3323
3605
|
result2.pattern.forEach((patternSet, name) => {
|
|
3324
3606
|
try {
|
|
3325
3607
|
for (const pattern of patternSet) {
|
|
3326
|
-
(0,
|
|
3608
|
+
(0, import_ts_pattern10.match)(pattern).with({ type: "jsx-pattern", name: import_ts_pattern10.P.string }, ({ name: jsxName }) => {
|
|
3327
3609
|
pattern.data.forEach((data) => {
|
|
3328
3610
|
const fnName = patterns.find(jsxName);
|
|
3329
3611
|
const styleProps = patterns.transform(fnName, data);
|
|
@@ -3476,6 +3758,7 @@ var getJsxEngine = (config) => {
|
|
|
3476
3758
|
factoryName: jsxFactory,
|
|
3477
3759
|
upperName: (0, import_shared6.capitalize)(jsxFactory),
|
|
3478
3760
|
typeName: `HTML${(0, import_shared6.capitalize)(jsxFactory)}Props`,
|
|
3761
|
+
variantName: `${(0, import_shared6.capitalize)(jsxFactory)}VariantProps`,
|
|
3479
3762
|
componentName: `${(0, import_shared6.capitalize)(jsxFactory)}Component`,
|
|
3480
3763
|
framework: jsxFramework,
|
|
3481
3764
|
styleProps: jsxStyleProps2 ?? "all"
|