@pandacss/generator 0.4.0 → 0.5.1
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 +270 -0
- package/dist/index.d.ts +80 -75
- package/dist/index.js +836 -175
- package/dist/index.mjs +828 -167
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -35,14 +35,14 @@ var artifactsGenerated = (ctx) => {
|
|
|
35
35
|
!tokens.isEmpty && outdent`
|
|
36
36
|
${tick} ${quote(outdir, "/tokens")}: the css variables and js function to query your tokens
|
|
37
37
|
`,
|
|
38
|
-
!patterns.isEmpty() && outdent`
|
|
38
|
+
!patterns.isEmpty() && !ctx.isTemplateLiteralSyntax && outdent`
|
|
39
39
|
${tick} ${quote(outdir, "/patterns")}: functions to implement apply common layout patterns
|
|
40
40
|
`,
|
|
41
41
|
!recipes.isEmpty() && outdent`
|
|
42
42
|
${tick} ${quote(outdir, "/recipes")}: functions to create multi-variant styles
|
|
43
43
|
`,
|
|
44
44
|
jsx.framework && outdent`
|
|
45
|
-
${tick} ${quote(outdir, "/jsx")}:
|
|
45
|
+
${tick} ${quote(outdir, "/jsx")}: styled jsx elements for ${jsx.framework}
|
|
46
46
|
`,
|
|
47
47
|
"\n"
|
|
48
48
|
].filter(Boolean).join("\n");
|
|
@@ -97,12 +97,9 @@ var getMessages = (ctx) => ({
|
|
|
97
97
|
configWatch
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
// src/generator.ts
|
|
101
|
-
import { Obj as Obj2, pipe as pipe3 } from "lil-fp";
|
|
102
|
-
|
|
103
100
|
// src/artifacts/index.ts
|
|
104
101
|
import { isObject } from "@pandacss/shared";
|
|
105
|
-
import
|
|
102
|
+
import outdent41 from "outdent";
|
|
106
103
|
|
|
107
104
|
// src/artifacts/css/global-css.ts
|
|
108
105
|
var generateGlobalCss = (ctx) => {
|
|
@@ -384,7 +381,7 @@ var generateStaticCss = (ctx) => {
|
|
|
384
381
|
const fn = getStaticCss(staticCss);
|
|
385
382
|
const results = fn({
|
|
386
383
|
breakpoints: Object.keys(theme.breakpoints ?? {}),
|
|
387
|
-
getPropertyKeys: utility.getPropertyKeys,
|
|
384
|
+
getPropertyKeys: (prop) => utility.getPropertyKeys(prop).filter((key) => !key.startsWith("type:") && !key.startsWith("CssProperties:")),
|
|
388
385
|
getRecipeKeys: (recipe) => recipes.details.find((detail) => detail.config.name === recipe)?.variantKeyMap ?? {}
|
|
389
386
|
});
|
|
390
387
|
results.css.forEach((css2) => {
|
|
@@ -546,8 +543,39 @@ function generateConditions(ctx) {
|
|
|
546
543
|
};
|
|
547
544
|
}
|
|
548
545
|
|
|
546
|
+
// src/artifacts/js/conditions.string-literal.ts
|
|
547
|
+
import outdent3 from "outdent";
|
|
548
|
+
function generateStringLiteralConditions(ctx) {
|
|
549
|
+
return {
|
|
550
|
+
js: outdent3`
|
|
551
|
+
${ctx.file.import("withoutSpace", "../helpers")}
|
|
552
|
+
|
|
553
|
+
export const isCondition = (val) => condRegex.test(val)
|
|
554
|
+
|
|
555
|
+
const condRegex = /^@|&|&$/
|
|
556
|
+
const selectorRegex = /&|@/
|
|
557
|
+
|
|
558
|
+
export const finalizeConditions = (paths) => {
|
|
559
|
+
return paths.map((path) => (selectorRegex.test(path) ? \`[\${withoutSpace(path.trim())}]\` : path))
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export function sortConditions(paths){
|
|
563
|
+
return paths.sort((a, b) => {
|
|
564
|
+
const aa = isCondition(a)
|
|
565
|
+
const bb = isCondition(b)
|
|
566
|
+
if (aa && !bb) return 1
|
|
567
|
+
if (!aa && bb) return -1
|
|
568
|
+
return 0
|
|
569
|
+
})
|
|
570
|
+
}
|
|
571
|
+
`,
|
|
572
|
+
dts: outdent3`
|
|
573
|
+
`
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
|
|
549
577
|
// src/artifacts/js/css-fn.ts
|
|
550
|
-
import { outdent as
|
|
578
|
+
import { outdent as outdent4 } from "outdent";
|
|
551
579
|
var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
|
|
552
580
|
function generateCssFn(ctx) {
|
|
553
581
|
const {
|
|
@@ -557,11 +585,11 @@ function generateCssFn(ctx) {
|
|
|
557
585
|
} = ctx;
|
|
558
586
|
const { separator } = utility;
|
|
559
587
|
return {
|
|
560
|
-
dts:
|
|
588
|
+
dts: outdent4`
|
|
561
589
|
import type { SystemStyleObject } from '../types'
|
|
562
590
|
export declare function css(styles: SystemStyleObject): string
|
|
563
591
|
`,
|
|
564
|
-
js:
|
|
592
|
+
js: outdent4`
|
|
565
593
|
${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
566
594
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
567
595
|
|
|
@@ -604,11 +632,58 @@ function generateCssFn(ctx) {
|
|
|
604
632
|
};
|
|
605
633
|
}
|
|
606
634
|
|
|
635
|
+
// src/artifacts/js/css-fn.string-literal.ts
|
|
636
|
+
import { outdent as outdent5 } from "outdent";
|
|
637
|
+
function generateStringLiteralCssFn(ctx) {
|
|
638
|
+
const {
|
|
639
|
+
utility,
|
|
640
|
+
config: { hash, prefix }
|
|
641
|
+
} = ctx;
|
|
642
|
+
const { separator } = utility;
|
|
643
|
+
return {
|
|
644
|
+
dts: outdent5`
|
|
645
|
+
export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
|
|
646
|
+
`,
|
|
647
|
+
js: outdent5`
|
|
648
|
+
${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
|
|
649
|
+
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
650
|
+
|
|
651
|
+
function transform(prop, value) {
|
|
652
|
+
const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
|
|
653
|
+
return { className }
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
const context = {
|
|
657
|
+
hash: ${hash ? "true" : "false"},
|
|
658
|
+
conditions: {
|
|
659
|
+
shift: sortConditions,
|
|
660
|
+
finalize: finalizeConditions,
|
|
661
|
+
breakpoints: { keys: [] },
|
|
662
|
+
},
|
|
663
|
+
utility: {
|
|
664
|
+
prefix: ${prefix ? JSON.stringify(prefix) : void 0},
|
|
665
|
+
transform,
|
|
666
|
+
hasShorthand: false,
|
|
667
|
+
resolveShorthand(prop) {
|
|
668
|
+
return prop
|
|
669
|
+
},
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const cssFn = createCss(context)
|
|
674
|
+
|
|
675
|
+
export const css = (str) => {
|
|
676
|
+
return cssFn(astish(str[0]))
|
|
677
|
+
}
|
|
678
|
+
`
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
607
682
|
// src/artifacts/js/cva.ts
|
|
608
|
-
import { outdent as
|
|
683
|
+
import { outdent as outdent6 } from "outdent";
|
|
609
684
|
function generateCvaFn(ctx) {
|
|
610
685
|
return {
|
|
611
|
-
js:
|
|
686
|
+
js: outdent6`
|
|
612
687
|
${ctx.file.import("compact, splitProps", "../helpers")}
|
|
613
688
|
${ctx.file.import("css, mergeCss", "./css")}
|
|
614
689
|
|
|
@@ -641,7 +716,7 @@ function generateCvaFn(ctx) {
|
|
|
641
716
|
|
|
642
717
|
return Object.assign(cvaFn, {
|
|
643
718
|
__cva__: true,
|
|
644
|
-
|
|
719
|
+
variantMap,
|
|
645
720
|
variantKeys,
|
|
646
721
|
resolve,
|
|
647
722
|
config,
|
|
@@ -674,7 +749,7 @@ function generateCvaFn(ctx) {
|
|
|
674
749
|
}
|
|
675
750
|
|
|
676
751
|
`,
|
|
677
|
-
dts:
|
|
752
|
+
dts: outdent6`
|
|
678
753
|
import type { RecipeCreatorFn } from '../types/recipe'
|
|
679
754
|
|
|
680
755
|
export declare const cva: RecipeCreatorFn
|
|
@@ -686,10 +761,10 @@ function generateCvaFn(ctx) {
|
|
|
686
761
|
}
|
|
687
762
|
|
|
688
763
|
// src/artifacts/js/cx.ts
|
|
689
|
-
import
|
|
764
|
+
import outdent7 from "outdent";
|
|
690
765
|
function generateCx() {
|
|
691
766
|
return {
|
|
692
|
-
js:
|
|
767
|
+
js: outdent7`
|
|
693
768
|
function cx() {
|
|
694
769
|
let str = '',
|
|
695
770
|
i = 0,
|
|
@@ -706,7 +781,7 @@ function generateCx() {
|
|
|
706
781
|
|
|
707
782
|
export { cx }
|
|
708
783
|
`,
|
|
709
|
-
dts:
|
|
784
|
+
dts: outdent7`
|
|
710
785
|
type Argument = string | boolean | null | undefined
|
|
711
786
|
|
|
712
787
|
/** Conditionally join classNames into a single string */
|
|
@@ -716,17 +791,17 @@ function generateCx() {
|
|
|
716
791
|
}
|
|
717
792
|
|
|
718
793
|
// src/artifacts/js/helpers.ts
|
|
719
|
-
import { outdent as
|
|
794
|
+
import { outdent as outdent8 } from "outdent";
|
|
720
795
|
|
|
721
796
|
// src/artifacts/generated/helpers.mjs.json
|
|
722
797
|
var helpers_mjs_default = {
|
|
723
|
-
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\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
|
|
798
|
+
content: '// src/assert.ts\nfunction isObject(value) {\n return typeof value === "object" && value != null && !Array.isArray(value);\n}\n\n// src/astish.ts\nvar newRule = /(?:([\\u0080-\\uFFFF\\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\\s*)/g;\nvar ruleClean = /\\/\\*[^]*?\\*\\/|\\s\\s+|\\n/g;\nvar astish = (val, tree = [{}]) => {\n const block = newRule.exec((val ?? "").replace(ruleClean, ""));\n if (!block)\n return tree[0];\n if (block[4])\n tree.shift();\n else if (block[3])\n tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});\n else\n tree[0][block[1]] = block[2];\n return astish(val, tree);\n};\n\n// src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));\n}\n\n// src/condition.ts\nvar isBaseCondition = (v) => v === "base";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n\n// src/css-important.ts\nvar importantRegex = /!(important)?$/;\nfunction isImportant(value) {\n return typeof value === "string" ? importantRegex.test(value) : false;\n}\nfunction withoutImportant(value) {\n return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;\n}\nfunction withoutSpace(str) {\n return typeof str === "string" ? str.replaceAll(" ", "_") : str;\n}\n\n// src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = "";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0)\n name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i)\n h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n\n// src/merge-props.ts\nfunction mergeProps(...sources) {\n const result = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isObject(value)) {\n result[key] = mergeProps(result[key] || {}, value);\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n// src/walk-object.ts\nvar isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObject(value) || Array.isArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) {\n return predicate(value, path);\n }\n const next = inner(child, childPath);\n if (isNotNullish(next)) {\n result[key] = next;\n }\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (!isObject(obj))\n return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n\n// src/normalize-style-object.ts\nfunction toResponsiveObject(values, breakpoints) {\n return values.reduce((acc, current, index) => {\n const key = breakpoints[index];\n if (current != null) {\n acc[key] = current;\n }\n return acc;\n }, {});\n}\nfunction normalizeShorthand(styles, context) {\n const { hasShorthand, resolveShorthand } = context.utility;\n return walkObject(styles, (v) => v, {\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n });\n}\nfunction normalizeStyleObject(styles, context) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n return walkObject(\n styles,\n (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n },\n {\n stop: (value) => Array.isArray(value),\n getKey: (prop) => {\n return hasShorthand ? resolveShorthand(prop) : prop;\n }\n }\n );\n}\n\n// src/classname.ts\nvar fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nvar sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\\n\\s]+/g, " ") : value;\nfunction createCss(context) {\n const { utility, hash, conditions: conds = fallbackCondition } = context;\n const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");\n const hashFn = (conditions, className) => {\n let result;\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n result = formatClassName(toHash(baseArray.join(":")));\n } else {\n const baseArray = [...conds.finalize(conditions), formatClassName(className)];\n result = baseArray.join(":");\n }\n return result;\n };\n return (styleObject = {}) => {\n const normalizedObject = normalizeStyleObject(styleObject, context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n const important = isImportant(value);\n if (value == null)\n return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const transformed = utility.transform(prop, withoutImportant(sanitize(value)));\n let className = hashFn(conditions, transformed.className);\n if (important)\n className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(" ");\n };\n}\nfunction compactStyles(...styles) {\n return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1)\n return allStyles;\n return allStyles.map((style) => normalizeShorthand(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n function assignCss(...styles) {\n return Object.assign({}, ...resolve(styles));\n }\n return { mergeCss, assignCss };\n}\n\n// src/memo.ts\nvar memo = (fn) => {\n const cache = /* @__PURE__ */ new Map();\n const get = (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n return get;\n};\n\n// src/hypenate.ts\nvar dashCaseRegex = /[A-Z]/g;\nvar hypenateProperty = memo((property) => {\n if (property.startsWith("--"))\n return property;\n return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);\n});\n\n// src/normalize-html.ts\nvar htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];\nfunction convert(key) {\n return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;\n}\nfunction normalizeHTMLProps(props) {\n return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));\n}\nnormalizeHTMLProps.keys = htmlProps;\n\n// src/split-props.ts\nfunction splitProps(props, ...keys) {\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const dKeys = Object.keys(descriptors);\n const split = (k) => {\n const clone = {};\n for (let i = 0; i < k.length; i++) {\n const key = k[i];\n if (descriptors[key]) {\n Object.defineProperty(clone, key, descriptors[key]);\n delete descriptors[key];\n }\n }\n return clone;\n };\n const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));\n return keys.map(fn).concat(split(dKeys));\n}\nexport {\n astish,\n compact,\n createCss,\n createMergeCss,\n filterBaseConditions,\n hypenateProperty,\n isBaseCondition,\n isObject,\n mapObject,\n mergeProps,\n normalizeHTMLProps,\n splitProps,\n toHash,\n walkObject,\n withoutSpace\n};\n'
|
|
724
799
|
};
|
|
725
800
|
|
|
726
801
|
// src/artifacts/js/helpers.ts
|
|
727
802
|
function generateHelpers() {
|
|
728
803
|
return {
|
|
729
|
-
js:
|
|
804
|
+
js: outdent8`
|
|
730
805
|
${helpers_mjs_default.content}
|
|
731
806
|
|
|
732
807
|
export function __spreadValues(a, b){
|
|
@@ -747,6 +822,8 @@ var is_valid_prop_mjs_default = {
|
|
|
747
822
|
|
|
748
823
|
// src/artifacts/js/is-valid-prop.ts
|
|
749
824
|
function generateisValidProp(ctx) {
|
|
825
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
826
|
+
return;
|
|
750
827
|
let content = is_valid_prop_mjs_default.content;
|
|
751
828
|
content = content.replace(
|
|
752
829
|
"var userGenerated = []",
|
|
@@ -760,7 +837,7 @@ function generateisValidProp(ctx) {
|
|
|
760
837
|
// src/artifacts/js/pattern.ts
|
|
761
838
|
import { unionType } from "@pandacss/shared";
|
|
762
839
|
import { stringify as stringify2 } from "javascript-stringify";
|
|
763
|
-
import { outdent as
|
|
840
|
+
import { outdent as outdent9 } from "outdent";
|
|
764
841
|
import { match } from "ts-pattern";
|
|
765
842
|
function generatePattern(ctx) {
|
|
766
843
|
if (ctx.patterns.isEmpty())
|
|
@@ -778,7 +855,7 @@ function generatePattern(ctx) {
|
|
|
778
855
|
}
|
|
779
856
|
return {
|
|
780
857
|
name: dashName,
|
|
781
|
-
dts:
|
|
858
|
+
dts: outdent9`
|
|
782
859
|
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
783
860
|
import type { PropertyValue } from '../types/prop-type'
|
|
784
861
|
import type { Properties } from '../types/csstype'
|
|
@@ -802,7 +879,7 @@ function generatePattern(ctx) {
|
|
|
802
879
|
}).join("\n ")}
|
|
803
880
|
}
|
|
804
881
|
|
|
805
|
-
${strict ?
|
|
882
|
+
${strict ? outdent9`export declare function ${name}(options: ${upperName}Properties): string` : outdent9`
|
|
806
883
|
|
|
807
884
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
808
885
|
|
|
@@ -811,7 +888,7 @@ function generatePattern(ctx) {
|
|
|
811
888
|
`}
|
|
812
889
|
|
|
813
890
|
`,
|
|
814
|
-
js:
|
|
891
|
+
js: outdent9`
|
|
815
892
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
816
893
|
${ctx.file.import("css", "../css/index")}
|
|
817
894
|
|
|
@@ -828,7 +905,7 @@ transform`)}
|
|
|
828
905
|
|
|
829
906
|
// src/artifacts/js/recipe.ts
|
|
830
907
|
import { unionType as unionType2 } from "@pandacss/shared";
|
|
831
|
-
import { outdent as
|
|
908
|
+
import { outdent as outdent10 } from "outdent";
|
|
832
909
|
var stringify3 = (value) => JSON.stringify(value, null, 2);
|
|
833
910
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
834
911
|
function generateRecipes(ctx) {
|
|
@@ -842,7 +919,7 @@ function generateRecipes(ctx) {
|
|
|
842
919
|
const createRecipeFn = {
|
|
843
920
|
name: "create-recipe",
|
|
844
921
|
dts: "",
|
|
845
|
-
js:
|
|
922
|
+
js: outdent10`
|
|
846
923
|
${ctx.file.import("css", "../css/css")}
|
|
847
924
|
${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
|
|
848
925
|
${ctx.file.import("cx", "../css/cx")}
|
|
@@ -889,7 +966,7 @@ function generateRecipes(ctx) {
|
|
|
889
966
|
const { name, description, defaultVariants, compoundVariants } = config;
|
|
890
967
|
return {
|
|
891
968
|
name: dashName,
|
|
892
|
-
js:
|
|
969
|
+
js: outdent10`
|
|
893
970
|
${ctx.file.import("splitProps", "../helpers")}
|
|
894
971
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
895
972
|
|
|
@@ -910,7 +987,7 @@ function generateRecipes(ctx) {
|
|
|
910
987
|
splitVariantProps,
|
|
911
988
|
})
|
|
912
989
|
`,
|
|
913
|
-
dts:
|
|
990
|
+
dts: outdent10`
|
|
914
991
|
import type { ConditionalValue } from '../types'
|
|
915
992
|
import type { Pretty } from '../types/helpers'
|
|
916
993
|
|
|
@@ -948,7 +1025,7 @@ function generateRecipes(ctx) {
|
|
|
948
1025
|
}
|
|
949
1026
|
|
|
950
1027
|
// src/artifacts/js/token.ts
|
|
951
|
-
import
|
|
1028
|
+
import outdent11 from "outdent";
|
|
952
1029
|
function generateTokenJs(ctx) {
|
|
953
1030
|
const { tokens } = ctx;
|
|
954
1031
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -959,7 +1036,7 @@ function generateTokenJs(ctx) {
|
|
|
959
1036
|
});
|
|
960
1037
|
const obj = Object.fromEntries(map);
|
|
961
1038
|
return {
|
|
962
|
-
js:
|
|
1039
|
+
js: outdent11`
|
|
963
1040
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
964
1041
|
|
|
965
1042
|
export function token(path, fallback) {
|
|
@@ -972,7 +1049,7 @@ function generateTokenJs(ctx) {
|
|
|
972
1049
|
|
|
973
1050
|
token.var = tokenVar
|
|
974
1051
|
`,
|
|
975
|
-
dts:
|
|
1052
|
+
dts: outdent11`
|
|
976
1053
|
import type { Token } from './tokens'
|
|
977
1054
|
|
|
978
1055
|
export declare const token: {
|
|
@@ -986,11 +1063,11 @@ function generateTokenJs(ctx) {
|
|
|
986
1063
|
}
|
|
987
1064
|
|
|
988
1065
|
// src/artifacts/preact-jsx/jsx.ts
|
|
989
|
-
import { outdent as
|
|
1066
|
+
import { outdent as outdent12 } from "outdent";
|
|
990
1067
|
function generatePreactJsxFactory(ctx) {
|
|
991
1068
|
const { factoryName, componentName } = ctx.jsx;
|
|
992
1069
|
return {
|
|
993
|
-
js:
|
|
1070
|
+
js: outdent12`
|
|
994
1071
|
import { h } from 'preact'
|
|
995
1072
|
import { forwardRef } from 'preact/compat'
|
|
996
1073
|
import { useMemo } from 'preact/hooks'
|
|
@@ -1057,7 +1134,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1057
1134
|
}
|
|
1058
1135
|
|
|
1059
1136
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1060
|
-
import { outdent as
|
|
1137
|
+
import { outdent as outdent13 } from "outdent";
|
|
1061
1138
|
import { match as match2 } from "ts-pattern";
|
|
1062
1139
|
function generatePreactJsxPattern(ctx) {
|
|
1063
1140
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1066,7 +1143,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1066
1143
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1067
1144
|
return {
|
|
1068
1145
|
name: dashName,
|
|
1069
|
-
js:
|
|
1146
|
+
js: outdent13`
|
|
1070
1147
|
import { h } from 'preact'
|
|
1071
1148
|
import { forwardRef } from 'preact/compat'
|
|
1072
1149
|
${ctx.file.import(factoryName, "./factory")}
|
|
@@ -1075,12 +1152,12 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1075
1152
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1076
1153
|
${match2(props.length).with(
|
|
1077
1154
|
0,
|
|
1078
|
-
() =>
|
|
1155
|
+
() => outdent13`
|
|
1079
1156
|
const styleProps = ${styleFnName}()
|
|
1080
1157
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1081
1158
|
`
|
|
1082
1159
|
).otherwise(
|
|
1083
|
-
() =>
|
|
1160
|
+
() => outdent13`
|
|
1084
1161
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1085
1162
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1086
1163
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1088,7 +1165,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1088
1165
|
)}
|
|
1089
1166
|
})
|
|
1090
1167
|
`,
|
|
1091
|
-
dts:
|
|
1168
|
+
dts: outdent13`
|
|
1092
1169
|
import type { FunctionComponent } from 'preact'
|
|
1093
1170
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1094
1171
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1103,15 +1180,15 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1103
1180
|
}
|
|
1104
1181
|
|
|
1105
1182
|
// src/artifacts/preact-jsx/types.ts
|
|
1106
|
-
import { outdent as
|
|
1183
|
+
import { outdent as outdent14 } from "outdent";
|
|
1107
1184
|
function generatePreactJsxTypes(ctx) {
|
|
1108
1185
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1109
1186
|
return {
|
|
1110
|
-
jsxFactory:
|
|
1187
|
+
jsxFactory: outdent14`
|
|
1111
1188
|
import type { ${upperName} } from '../types/jsx'
|
|
1112
1189
|
export declare const ${factoryName}: ${upperName}
|
|
1113
1190
|
`,
|
|
1114
|
-
jsxType:
|
|
1191
|
+
jsxType: outdent14`
|
|
1115
1192
|
import type { ComponentProps, JSX } from 'preact'
|
|
1116
1193
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1117
1194
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1145,12 +1222,96 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1145
1222
|
};
|
|
1146
1223
|
}
|
|
1147
1224
|
|
|
1225
|
+
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1226
|
+
import { outdent as outdent15 } from "outdent";
|
|
1227
|
+
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1228
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1229
|
+
return {
|
|
1230
|
+
js: outdent15`
|
|
1231
|
+
import { h } from 'preact'
|
|
1232
|
+
import { forwardRef } from 'preact/compat'
|
|
1233
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1234
|
+
|
|
1235
|
+
function createStyledFn(Dynamic) {
|
|
1236
|
+
return function styledFn(template) {
|
|
1237
|
+
const baseClassName = css(template)
|
|
1238
|
+
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1239
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1240
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1241
|
+
|
|
1242
|
+
return h(Element, {
|
|
1243
|
+
ref,
|
|
1244
|
+
...elementProps,
|
|
1245
|
+
className: classes(),
|
|
1246
|
+
})
|
|
1247
|
+
})
|
|
1248
|
+
|
|
1249
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1250
|
+
return ${componentName}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
function createJsxFactory() {
|
|
1255
|
+
const cache = new Map()
|
|
1256
|
+
|
|
1257
|
+
return new Proxy(createStyledFn, {
|
|
1258
|
+
apply(_, __, args) {
|
|
1259
|
+
return createStyledFn(...args)
|
|
1260
|
+
},
|
|
1261
|
+
get(_, el) {
|
|
1262
|
+
if (!cache.has(el)) {
|
|
1263
|
+
cache.set(el, createStyledFn(el))
|
|
1264
|
+
}
|
|
1265
|
+
return cache.get(el)
|
|
1266
|
+
},
|
|
1267
|
+
})
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
export const ${factoryName} = createJsxFactory()
|
|
1271
|
+
`
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1276
|
+
import { outdent as outdent16 } from "outdent";
|
|
1277
|
+
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1278
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1279
|
+
return {
|
|
1280
|
+
jsxFactory: outdent16`
|
|
1281
|
+
import type { ${upperName} } from '../types/jsx'
|
|
1282
|
+
export declare const ${factoryName}: ${upperName}
|
|
1283
|
+
`,
|
|
1284
|
+
jsxType: outdent16`
|
|
1285
|
+
import type { ComponentProps, JSX } from 'preact'
|
|
1286
|
+
|
|
1287
|
+
type ElementType = keyof JSX.IntrinsicElements
|
|
1288
|
+
|
|
1289
|
+
type Dict = Record<string, unknown>
|
|
1290
|
+
|
|
1291
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1292
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1293
|
+
displayName?: string
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
interface JsxFactory {
|
|
1297
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1301
|
+
|
|
1302
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1303
|
+
|
|
1304
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1305
|
+
`
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1148
1309
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1149
|
-
import { outdent as
|
|
1310
|
+
import { outdent as outdent17 } from "outdent";
|
|
1150
1311
|
function generateQwikJsxFactory(ctx) {
|
|
1151
1312
|
const { factoryName, componentName } = ctx.jsx;
|
|
1152
1313
|
return {
|
|
1153
|
-
js:
|
|
1314
|
+
js: outdent17`
|
|
1154
1315
|
import { h } from '@builder.io/qwik'
|
|
1155
1316
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1156
1317
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1214,7 +1375,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1214
1375
|
}
|
|
1215
1376
|
|
|
1216
1377
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1217
|
-
import { outdent as
|
|
1378
|
+
import { outdent as outdent18 } from "outdent";
|
|
1218
1379
|
import { match as match3 } from "ts-pattern";
|
|
1219
1380
|
function generateQwikJsxPattern(ctx) {
|
|
1220
1381
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1223,7 +1384,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1223
1384
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1224
1385
|
return {
|
|
1225
1386
|
name: dashName,
|
|
1226
|
-
js:
|
|
1387
|
+
js: outdent18`
|
|
1227
1388
|
import { h } from '@builder.io/qwik'
|
|
1228
1389
|
${ctx.file.import(factoryName, "./factory")}
|
|
1229
1390
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1231,12 +1392,12 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1231
1392
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1232
1393
|
${match3(props.length).with(
|
|
1233
1394
|
0,
|
|
1234
|
-
() =>
|
|
1395
|
+
() => outdent18`
|
|
1235
1396
|
const styleProps = ${styleFnName}()
|
|
1236
1397
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1237
1398
|
`
|
|
1238
1399
|
).otherwise(
|
|
1239
|
-
() =>
|
|
1400
|
+
() => outdent18`
|
|
1240
1401
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1241
1402
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1242
1403
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1244,7 +1405,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1244
1405
|
)}
|
|
1245
1406
|
}
|
|
1246
1407
|
`,
|
|
1247
|
-
dts:
|
|
1408
|
+
dts: outdent18`
|
|
1248
1409
|
import type { FunctionComponent } from '@builder.io/qwik'
|
|
1249
1410
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1250
1411
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1263,15 +1424,15 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1263
1424
|
}
|
|
1264
1425
|
|
|
1265
1426
|
// src/artifacts/qwik-jsx/types.ts
|
|
1266
|
-
import { outdent as
|
|
1427
|
+
import { outdent as outdent19 } from "outdent";
|
|
1267
1428
|
function generateQwikJsxTypes(ctx) {
|
|
1268
1429
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1269
1430
|
return {
|
|
1270
|
-
jsxFactory:
|
|
1431
|
+
jsxFactory: outdent19`
|
|
1271
1432
|
import { ${upperName} } from '../types/jsx'
|
|
1272
1433
|
export declare const ${factoryName}: ${upperName}
|
|
1273
1434
|
`,
|
|
1274
|
-
jsxType:
|
|
1435
|
+
jsxType: outdent19`
|
|
1275
1436
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1276
1437
|
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1277
1438
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1324,12 +1485,100 @@ export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxSt
|
|
|
1324
1485
|
};
|
|
1325
1486
|
}
|
|
1326
1487
|
|
|
1488
|
+
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1489
|
+
import { outdent as outdent20 } from "outdent";
|
|
1490
|
+
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1491
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1492
|
+
return {
|
|
1493
|
+
js: outdent20`
|
|
1494
|
+
import { h } from '@builder.io/qwik'
|
|
1495
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1496
|
+
|
|
1497
|
+
function createStyledFn(Dynamic) {
|
|
1498
|
+
return function styledFn(template) {
|
|
1499
|
+
const baseClassName = css(template)
|
|
1500
|
+
const ${componentName} = function ${componentName}(props) {
|
|
1501
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1502
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1503
|
+
|
|
1504
|
+
return h(Element, {
|
|
1505
|
+
...elementProps,
|
|
1506
|
+
className: classes(),
|
|
1507
|
+
})
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1511
|
+
return ${componentName}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
function createJsxFactory() {
|
|
1516
|
+
const cache = new Map()
|
|
1517
|
+
|
|
1518
|
+
return new Proxy(createStyledFn, {
|
|
1519
|
+
apply(_, __, args) {
|
|
1520
|
+
return createStyledFn(...args)
|
|
1521
|
+
},
|
|
1522
|
+
get(_, el) {
|
|
1523
|
+
if (!cache.has(el)) {
|
|
1524
|
+
cache.set(el, createStyledFn(el))
|
|
1525
|
+
}
|
|
1526
|
+
return cache.get(el)
|
|
1527
|
+
},
|
|
1528
|
+
})
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
export const ${factoryName} = createJsxFactory()
|
|
1532
|
+
|
|
1533
|
+
`
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1538
|
+
import { outdent as outdent21 } from "outdent";
|
|
1539
|
+
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1540
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1541
|
+
return {
|
|
1542
|
+
jsxFactory: outdent21`
|
|
1543
|
+
import { ${upperName} } from '../types/jsx'
|
|
1544
|
+
export declare const ${factoryName}: ${upperName}
|
|
1545
|
+
`,
|
|
1546
|
+
jsxType: outdent21`
|
|
1547
|
+
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1548
|
+
|
|
1549
|
+
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
1550
|
+
|
|
1551
|
+
type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1552
|
+
? QwikIntrinsicElements[T]
|
|
1553
|
+
: T extends FunctionComponent<infer P>
|
|
1554
|
+
? P
|
|
1555
|
+
: never
|
|
1556
|
+
|
|
1557
|
+
type Dict = Record<string, unknown>
|
|
1558
|
+
|
|
1559
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1560
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
interface JsxFactory {
|
|
1564
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1568
|
+
|
|
1569
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1570
|
+
|
|
1571
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1572
|
+
`
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1327
1576
|
// src/artifacts/react-jsx/jsx.ts
|
|
1328
|
-
import { outdent as
|
|
1577
|
+
import { outdent as outdent22 } from "outdent";
|
|
1329
1578
|
function generateReactJsxFactory(ctx) {
|
|
1330
1579
|
const { factoryName, componentName } = ctx.jsx;
|
|
1331
1580
|
return {
|
|
1332
|
-
js:
|
|
1581
|
+
js: outdent22`
|
|
1333
1582
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1334
1583
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1335
1584
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1395,7 +1644,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1395
1644
|
}
|
|
1396
1645
|
|
|
1397
1646
|
// src/artifacts/react-jsx/pattern.ts
|
|
1398
|
-
import { outdent as
|
|
1647
|
+
import { outdent as outdent23 } from "outdent";
|
|
1399
1648
|
import { match as match4 } from "ts-pattern";
|
|
1400
1649
|
function generateReactJsxPattern(ctx) {
|
|
1401
1650
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1404,7 +1653,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1404
1653
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1405
1654
|
return {
|
|
1406
1655
|
name: dashName,
|
|
1407
|
-
js:
|
|
1656
|
+
js: outdent23`
|
|
1408
1657
|
import { createElement, forwardRef } from 'react'
|
|
1409
1658
|
${ctx.file.import(factoryName, "./factory")}
|
|
1410
1659
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1412,12 +1661,12 @@ function generateReactJsxPattern(ctx) {
|
|
|
1412
1661
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1413
1662
|
${match4(props.length).with(
|
|
1414
1663
|
0,
|
|
1415
|
-
() =>
|
|
1664
|
+
() => outdent23`
|
|
1416
1665
|
const styleProps = ${styleFnName}()
|
|
1417
1666
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1418
1667
|
`
|
|
1419
1668
|
).otherwise(
|
|
1420
|
-
() =>
|
|
1669
|
+
() => outdent23`
|
|
1421
1670
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1422
1671
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1423
1672
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1425,7 +1674,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1425
1674
|
)}
|
|
1426
1675
|
})
|
|
1427
1676
|
`,
|
|
1428
|
-
dts:
|
|
1677
|
+
dts: outdent23`
|
|
1429
1678
|
import type { FunctionComponent } from 'react'
|
|
1430
1679
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1431
1680
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1440,15 +1689,15 @@ function generateReactJsxPattern(ctx) {
|
|
|
1440
1689
|
}
|
|
1441
1690
|
|
|
1442
1691
|
// src/artifacts/react-jsx/types.ts
|
|
1443
|
-
import { outdent as
|
|
1692
|
+
import { outdent as outdent24 } from "outdent";
|
|
1444
1693
|
function generateReactJsxTypes(ctx) {
|
|
1445
1694
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1446
1695
|
return {
|
|
1447
|
-
jsxFactory:
|
|
1696
|
+
jsxFactory: outdent24`
|
|
1448
1697
|
import { ${upperName} } from '../types/jsx'
|
|
1449
1698
|
export declare const ${factoryName}: ${upperName}
|
|
1450
1699
|
`,
|
|
1451
|
-
jsxType:
|
|
1700
|
+
jsxType: outdent24`
|
|
1452
1701
|
import type { ComponentProps, ElementType } from 'react'
|
|
1453
1702
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1454
1703
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1480,51 +1729,133 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1480
1729
|
};
|
|
1481
1730
|
}
|
|
1482
1731
|
|
|
1483
|
-
// src/artifacts/
|
|
1484
|
-
import { outdent as
|
|
1485
|
-
function
|
|
1486
|
-
const {
|
|
1732
|
+
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
1733
|
+
import { outdent as outdent25 } from "outdent";
|
|
1734
|
+
function generateReactJsxStringLiteralFactory(ctx) {
|
|
1735
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1487
1736
|
return {
|
|
1488
|
-
js:
|
|
1489
|
-
import {
|
|
1490
|
-
import
|
|
1491
|
-
import { createComponent } from 'solid-js/web'
|
|
1492
|
-
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1493
|
-
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
1494
|
-
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
1737
|
+
js: outdent25`
|
|
1738
|
+
import { createElement, forwardRef } from 'react'
|
|
1739
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1495
1740
|
|
|
1496
|
-
function
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
1503
|
-
mergedProps,
|
|
1504
|
-
['as', 'class'],
|
|
1505
|
-
cvaFn.variantKeys,
|
|
1506
|
-
allCssProperties,
|
|
1507
|
-
normalizeHTMLProps.keys
|
|
1508
|
-
)
|
|
1509
|
-
|
|
1510
|
-
function recipeClass() {
|
|
1511
|
-
const { css: cssStyles, ...propStyles } = styleProps
|
|
1512
|
-
const styles = assignCss(propStyles, cssStyles)
|
|
1513
|
-
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1514
|
-
}
|
|
1741
|
+
function createStyledFn(Dynamic) {
|
|
1742
|
+
return function styledFn(template) {
|
|
1743
|
+
const baseClassName = css(template)
|
|
1744
|
+
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1745
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1746
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1515
1747
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1748
|
+
return createElement(Element, {
|
|
1749
|
+
ref,
|
|
1750
|
+
...elementProps,
|
|
1751
|
+
className: classes(),
|
|
1752
|
+
})
|
|
1753
|
+
})
|
|
1524
1754
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1755
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1756
|
+
return ${componentName}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
function createJsxFactory() {
|
|
1761
|
+
const cache = new Map()
|
|
1762
|
+
|
|
1763
|
+
return new Proxy(createStyledFn, {
|
|
1764
|
+
apply(_, __, args) {
|
|
1765
|
+
return createStyledFn(...args)
|
|
1766
|
+
},
|
|
1767
|
+
get(_, el) {
|
|
1768
|
+
if (!cache.has(el)) {
|
|
1769
|
+
cache.set(el, createStyledFn(el))
|
|
1770
|
+
}
|
|
1771
|
+
return cache.get(el)
|
|
1772
|
+
},
|
|
1773
|
+
})
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
export const ${factoryName} = createJsxFactory()
|
|
1777
|
+
|
|
1778
|
+
`
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
// src/artifacts/react-jsx/types.string-literal.ts
|
|
1783
|
+
import { outdent as outdent26 } from "outdent";
|
|
1784
|
+
function generateReactJsxStringLiteralTypes(ctx) {
|
|
1785
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1786
|
+
return {
|
|
1787
|
+
jsxFactory: outdent26`
|
|
1788
|
+
import { ${upperName} } from '../types/jsx'
|
|
1789
|
+
export declare const ${factoryName}: ${upperName}
|
|
1790
|
+
`,
|
|
1791
|
+
jsxType: outdent26`
|
|
1792
|
+
import type { ComponentProps, ElementType } from 'react'
|
|
1793
|
+
|
|
1794
|
+
type Dict = Record<string, unknown>
|
|
1795
|
+
|
|
1796
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1797
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1798
|
+
displayName?: string
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
interface JsxFactory {
|
|
1802
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1806
|
+
|
|
1807
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1808
|
+
|
|
1809
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1810
|
+
`
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
// src/artifacts/solid-jsx/jsx.ts
|
|
1815
|
+
import { outdent as outdent27 } from "outdent";
|
|
1816
|
+
function generateSolidJsxFactory(ctx) {
|
|
1817
|
+
const { componentName, factoryName } = ctx.jsx;
|
|
1818
|
+
return {
|
|
1819
|
+
js: outdent27`
|
|
1820
|
+
import { Dynamic } from 'solid-js/web'
|
|
1821
|
+
import { mergeProps, splitProps } from 'solid-js'
|
|
1822
|
+
import { createComponent } from 'solid-js/web'
|
|
1823
|
+
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1824
|
+
${ctx.file.import("normalizeHTMLProps", "../helpers")}
|
|
1825
|
+
${ctx.file.import("allCssProperties", "./is-valid-prop")}
|
|
1826
|
+
|
|
1827
|
+
function styledFn(element, configOrCva = {}) {
|
|
1828
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
1829
|
+
|
|
1830
|
+
return function ${componentName}(props) {
|
|
1831
|
+
const mergedProps = mergeProps({ as: element }, props)
|
|
1832
|
+
|
|
1833
|
+
const [localProps, variantProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
1834
|
+
mergedProps,
|
|
1835
|
+
['as', 'class'],
|
|
1836
|
+
cvaFn.variantKeys,
|
|
1837
|
+
allCssProperties,
|
|
1838
|
+
normalizeHTMLProps.keys
|
|
1839
|
+
)
|
|
1840
|
+
|
|
1841
|
+
function recipeClass() {
|
|
1842
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1843
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
1844
|
+
return cx(cvaFn(variantProps), css(styles), localProps.class)
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
function cvaClass() {
|
|
1848
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
1849
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
1850
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
1851
|
+
return cx(css(styles), localProps.class)
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
1855
|
+
|
|
1856
|
+
return createComponent(
|
|
1857
|
+
Dynamic,
|
|
1858
|
+
mergeProps(
|
|
1528
1859
|
{
|
|
1529
1860
|
get component() {
|
|
1530
1861
|
return localProps.as
|
|
@@ -1562,7 +1893,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1562
1893
|
}
|
|
1563
1894
|
|
|
1564
1895
|
// src/artifacts/solid-jsx/pattern.ts
|
|
1565
|
-
import { outdent as
|
|
1896
|
+
import { outdent as outdent28 } from "outdent";
|
|
1566
1897
|
import { match as match5 } from "ts-pattern";
|
|
1567
1898
|
function generateSolidJsxPattern(ctx) {
|
|
1568
1899
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1571,7 +1902,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1571
1902
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1572
1903
|
return {
|
|
1573
1904
|
name: dashName,
|
|
1574
|
-
js:
|
|
1905
|
+
js: outdent28`
|
|
1575
1906
|
import { splitProps, mergeProps } from 'solid-js'
|
|
1576
1907
|
import { createComponent } from 'solid-js/web'
|
|
1577
1908
|
${ctx.file.import(factoryName, "./factory")}
|
|
@@ -1580,12 +1911,12 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1580
1911
|
export function ${jsxName}(props) {
|
|
1581
1912
|
${match5(props.length).with(
|
|
1582
1913
|
0,
|
|
1583
|
-
() =>
|
|
1914
|
+
() => outdent28`
|
|
1584
1915
|
const styleProps = ${styleFnName}()
|
|
1585
1916
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
1586
1917
|
`
|
|
1587
1918
|
).otherwise(
|
|
1588
|
-
() =>
|
|
1919
|
+
() => outdent28`
|
|
1589
1920
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
1590
1921
|
const styleProps = ${styleFnName}(patternProps)
|
|
1591
1922
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -1593,7 +1924,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1593
1924
|
)}
|
|
1594
1925
|
}
|
|
1595
1926
|
`,
|
|
1596
|
-
dts:
|
|
1927
|
+
dts: outdent28`
|
|
1597
1928
|
import { Component } from 'solid-js'
|
|
1598
1929
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1599
1930
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1608,15 +1939,15 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1608
1939
|
}
|
|
1609
1940
|
|
|
1610
1941
|
// src/artifacts/solid-jsx/types.ts
|
|
1611
|
-
import { outdent as
|
|
1942
|
+
import { outdent as outdent29 } from "outdent";
|
|
1612
1943
|
function generateSolidJsxTypes(ctx) {
|
|
1613
1944
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1614
1945
|
return {
|
|
1615
|
-
jsxFactory:
|
|
1946
|
+
jsxFactory: outdent29`
|
|
1616
1947
|
import type { ${upperName} } from '../types/jsx'
|
|
1617
1948
|
export declare const ${factoryName}: ${upperName}
|
|
1618
1949
|
`,
|
|
1619
|
-
jsxType:
|
|
1950
|
+
jsxType: outdent29`
|
|
1620
1951
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1621
1952
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1622
1953
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1650,12 +1981,102 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1650
1981
|
};
|
|
1651
1982
|
}
|
|
1652
1983
|
|
|
1984
|
+
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
1985
|
+
import { outdent as outdent30 } from "outdent";
|
|
1986
|
+
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
1987
|
+
const { componentName, factoryName } = ctx.jsx;
|
|
1988
|
+
return {
|
|
1989
|
+
js: outdent30`
|
|
1990
|
+
import { mergeProps, splitProps } from 'solid-js'
|
|
1991
|
+
import { Dynamic, createComponent } from 'solid-js/web'
|
|
1992
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1993
|
+
|
|
1994
|
+
function createStyled(element) {
|
|
1995
|
+
return function styledFn(template) {
|
|
1996
|
+
const baseClassName = css(template)
|
|
1997
|
+
return function ${componentName}(props) {
|
|
1998
|
+
const mergedProps = mergeProps({ as: element }, props)
|
|
1999
|
+
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2000
|
+
|
|
2001
|
+
return createComponent(
|
|
2002
|
+
Dynamic,
|
|
2003
|
+
mergeProps(
|
|
2004
|
+
{
|
|
2005
|
+
get component() {
|
|
2006
|
+
return localProps.as
|
|
2007
|
+
},
|
|
2008
|
+
get class() {
|
|
2009
|
+
return cx(baseClassName, localProps.class)
|
|
2010
|
+
},
|
|
2011
|
+
},
|
|
2012
|
+
elementProps,
|
|
2013
|
+
),
|
|
2014
|
+
)
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
function createJsxFactory() {
|
|
2020
|
+
const cache = new Map()
|
|
2021
|
+
|
|
2022
|
+
return new Proxy(createStyled, {
|
|
2023
|
+
apply(_, __, args) {
|
|
2024
|
+
return createStyled(...args)
|
|
2025
|
+
},
|
|
2026
|
+
get(_, el) {
|
|
2027
|
+
if (!cache.has(el)) {
|
|
2028
|
+
cache.set(el, createStyled(el))
|
|
2029
|
+
}
|
|
2030
|
+
return cache.get(el)
|
|
2031
|
+
},
|
|
2032
|
+
})
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
export const ${factoryName} = createJsxFactory()
|
|
2036
|
+
`
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2041
|
+
import { outdent as outdent31 } from "outdent";
|
|
2042
|
+
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2043
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2044
|
+
return {
|
|
2045
|
+
jsxFactory: outdent31`
|
|
2046
|
+
import type { ${upperName} } from '../types/jsx'
|
|
2047
|
+
export declare const ${factoryName}: ${upperName}
|
|
2048
|
+
`,
|
|
2049
|
+
jsxType: outdent31`
|
|
2050
|
+
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2051
|
+
|
|
2052
|
+
type Dict = Record<string, unknown>
|
|
2053
|
+
|
|
2054
|
+
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2055
|
+
|
|
2056
|
+
export type ${componentName}<T extends ElementType> = {
|
|
2057
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
2058
|
+
displayName?: string
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
interface JsxFactory {
|
|
2062
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2066
|
+
|
|
2067
|
+
export type Styled = JsxFactory & JsxElements
|
|
2068
|
+
|
|
2069
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2070
|
+
`
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
|
|
1653
2074
|
// src/artifacts/vue-jsx/jsx.ts
|
|
1654
|
-
import { outdent as
|
|
2075
|
+
import { outdent as outdent32 } from "outdent";
|
|
1655
2076
|
function generateVueJsxFactory(ctx) {
|
|
1656
2077
|
const { factoryName } = ctx.jsx;
|
|
1657
2078
|
return {
|
|
1658
|
-
js:
|
|
2079
|
+
js: outdent32`
|
|
1659
2080
|
import { defineComponent, h, computed } from 'vue'
|
|
1660
2081
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1661
2082
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1728,8 +2149,62 @@ function generateVueJsxFactory(ctx) {
|
|
|
1728
2149
|
};
|
|
1729
2150
|
}
|
|
1730
2151
|
|
|
2152
|
+
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2153
|
+
import { outdent as outdent33 } from "outdent";
|
|
2154
|
+
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2155
|
+
const { factoryName } = ctx.jsx;
|
|
2156
|
+
return {
|
|
2157
|
+
js: outdent33`
|
|
2158
|
+
import { defineComponent, h, computed } from 'vue'
|
|
2159
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
2160
|
+
|
|
2161
|
+
function createStyled(Dynamic) {
|
|
2162
|
+
function styledFn(template) {
|
|
2163
|
+
const baseClassName = css(template)
|
|
2164
|
+
return defineComponent({
|
|
2165
|
+
name: \`${factoryName}.\${Dynamic}\`,
|
|
2166
|
+
inheritAttrs: false,
|
|
2167
|
+
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2168
|
+
setup(props, { slots, attrs }) {
|
|
2169
|
+
const classes = computed(() => cx(baseClassName, elementProps.className))
|
|
2170
|
+
return () => {
|
|
2171
|
+
return h(
|
|
2172
|
+
props.as,
|
|
2173
|
+
{
|
|
2174
|
+
class: classes.value,
|
|
2175
|
+
...elementProps,
|
|
2176
|
+
},
|
|
2177
|
+
slots.default && slots.default(),
|
|
2178
|
+
)
|
|
2179
|
+
}
|
|
2180
|
+
},
|
|
2181
|
+
})
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
function createJsxFactory() {
|
|
2186
|
+
const cache = new Map()
|
|
2187
|
+
|
|
2188
|
+
return new Proxy(createStyled, {
|
|
2189
|
+
apply(_, __, args) {
|
|
2190
|
+
return createStyled(...args)
|
|
2191
|
+
},
|
|
2192
|
+
get(_, el) {
|
|
2193
|
+
if (!cache.has(el)) {
|
|
2194
|
+
cache.set(el, createStyled(el))
|
|
2195
|
+
}
|
|
2196
|
+
return cache.get(el)
|
|
2197
|
+
},
|
|
2198
|
+
})
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
export const ${factoryName} = createJsxFactory()
|
|
2202
|
+
`
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
|
|
1731
2206
|
// src/artifacts/vue-jsx/pattern.ts
|
|
1732
|
-
import { outdent as
|
|
2207
|
+
import { outdent as outdent34 } from "outdent";
|
|
1733
2208
|
function generateVueJsxPattern(ctx) {
|
|
1734
2209
|
const { typeName, factoryName } = ctx.jsx;
|
|
1735
2210
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1738,7 +2213,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
1738
2213
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
1739
2214
|
return {
|
|
1740
2215
|
name: dashName,
|
|
1741
|
-
js:
|
|
2216
|
+
js: outdent34`
|
|
1742
2217
|
import { defineComponent, h, computed } from 'vue'
|
|
1743
2218
|
${ctx.file.import(factoryName, "./factory")}
|
|
1744
2219
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1756,7 +2231,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
1756
2231
|
}
|
|
1757
2232
|
})
|
|
1758
2233
|
`,
|
|
1759
|
-
dts:
|
|
2234
|
+
dts: outdent34`
|
|
1760
2235
|
import { FunctionalComponent } from 'vue'
|
|
1761
2236
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1762
2237
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1771,15 +2246,15 @@ function generateVueJsxPattern(ctx) {
|
|
|
1771
2246
|
}
|
|
1772
2247
|
|
|
1773
2248
|
// src/artifacts/vue-jsx/types.ts
|
|
1774
|
-
import { outdent as
|
|
2249
|
+
import { outdent as outdent35 } from "outdent";
|
|
1775
2250
|
function generateVueJsxTypes(ctx) {
|
|
1776
2251
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1777
2252
|
return {
|
|
1778
|
-
jsxFactory:
|
|
2253
|
+
jsxFactory: outdent35`
|
|
1779
2254
|
import { ${upperName} } from '../types/jsx'
|
|
1780
2255
|
export declare const ${factoryName}: ${upperName}
|
|
1781
2256
|
`,
|
|
1782
|
-
jsxType:
|
|
2257
|
+
jsxType: outdent35`
|
|
1783
2258
|
import type { Component, FunctionalComponent } from 'vue'
|
|
1784
2259
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1785
2260
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1935,6 +2410,161 @@ type IntrinsicElement =
|
|
|
1935
2410
|
};
|
|
1936
2411
|
}
|
|
1937
2412
|
|
|
2413
|
+
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2414
|
+
import { outdent as outdent36 } from "outdent";
|
|
2415
|
+
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2416
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2417
|
+
return {
|
|
2418
|
+
jsxFactory: outdent36`
|
|
2419
|
+
import { ${upperName} } from '../types/jsx'
|
|
2420
|
+
export declare const ${factoryName}: ${upperName}
|
|
2421
|
+
`,
|
|
2422
|
+
jsxType: outdent36`
|
|
2423
|
+
import type { Component, FunctionalComponent } from 'vue'
|
|
2424
|
+
|
|
2425
|
+
type IntrinsicElement =
|
|
2426
|
+
| 'a'
|
|
2427
|
+
| 'abbr'
|
|
2428
|
+
| 'address'
|
|
2429
|
+
| 'area'
|
|
2430
|
+
| 'article'
|
|
2431
|
+
| 'aside'
|
|
2432
|
+
| 'audio'
|
|
2433
|
+
| 'b'
|
|
2434
|
+
| 'base'
|
|
2435
|
+
| 'bdi'
|
|
2436
|
+
| 'bdo'
|
|
2437
|
+
| 'blockquote'
|
|
2438
|
+
| 'body'
|
|
2439
|
+
| 'br'
|
|
2440
|
+
| 'button'
|
|
2441
|
+
| 'canvas'
|
|
2442
|
+
| 'caption'
|
|
2443
|
+
| 'cite'
|
|
2444
|
+
| 'code'
|
|
2445
|
+
| 'col'
|
|
2446
|
+
| 'colgroup'
|
|
2447
|
+
| 'data'
|
|
2448
|
+
| 'datalist'
|
|
2449
|
+
| 'dd'
|
|
2450
|
+
| 'del'
|
|
2451
|
+
| 'details'
|
|
2452
|
+
| 'dfn'
|
|
2453
|
+
| 'dialog'
|
|
2454
|
+
| 'div'
|
|
2455
|
+
| 'dl'
|
|
2456
|
+
| 'dt'
|
|
2457
|
+
| 'em'
|
|
2458
|
+
| 'embed'
|
|
2459
|
+
| 'fieldset'
|
|
2460
|
+
| 'figcaption'
|
|
2461
|
+
| 'figure'
|
|
2462
|
+
| 'footer'
|
|
2463
|
+
| 'form'
|
|
2464
|
+
| 'h1'
|
|
2465
|
+
| 'h2'
|
|
2466
|
+
| 'h3'
|
|
2467
|
+
| 'h4'
|
|
2468
|
+
| 'h5'
|
|
2469
|
+
| 'h6'
|
|
2470
|
+
| 'head'
|
|
2471
|
+
| 'header'
|
|
2472
|
+
| 'hgroup'
|
|
2473
|
+
| 'hr'
|
|
2474
|
+
| 'html'
|
|
2475
|
+
| 'i'
|
|
2476
|
+
| 'iframe'
|
|
2477
|
+
| 'img'
|
|
2478
|
+
| 'input'
|
|
2479
|
+
| 'ins'
|
|
2480
|
+
| 'kbd'
|
|
2481
|
+
| 'label'
|
|
2482
|
+
| 'legend'
|
|
2483
|
+
| 'li'
|
|
2484
|
+
| 'link'
|
|
2485
|
+
| 'main'
|
|
2486
|
+
| 'map'
|
|
2487
|
+
| 'mark'
|
|
2488
|
+
| 'math'
|
|
2489
|
+
| 'menu'
|
|
2490
|
+
| 'menuitem'
|
|
2491
|
+
| 'meta'
|
|
2492
|
+
| 'meter'
|
|
2493
|
+
| 'nav'
|
|
2494
|
+
| 'noscript'
|
|
2495
|
+
| 'object'
|
|
2496
|
+
| 'ol'
|
|
2497
|
+
| 'optgroup'
|
|
2498
|
+
| 'option'
|
|
2499
|
+
| 'output'
|
|
2500
|
+
| 'p'
|
|
2501
|
+
| 'param'
|
|
2502
|
+
| 'picture'
|
|
2503
|
+
| 'pre'
|
|
2504
|
+
| 'progress'
|
|
2505
|
+
| 'q'
|
|
2506
|
+
| 'rb'
|
|
2507
|
+
| 'rp'
|
|
2508
|
+
| 'rt'
|
|
2509
|
+
| 'rtc'
|
|
2510
|
+
| 'ruby'
|
|
2511
|
+
| 's'
|
|
2512
|
+
| 'samp'
|
|
2513
|
+
| 'script'
|
|
2514
|
+
| 'section'
|
|
2515
|
+
| 'select'
|
|
2516
|
+
| 'slot'
|
|
2517
|
+
| 'small'
|
|
2518
|
+
| 'source'
|
|
2519
|
+
| 'span'
|
|
2520
|
+
| 'strong'
|
|
2521
|
+
| 'style'
|
|
2522
|
+
| 'sub'
|
|
2523
|
+
| 'summary'
|
|
2524
|
+
| 'sup'
|
|
2525
|
+
| 'svg'
|
|
2526
|
+
| 'table'
|
|
2527
|
+
| 'tbody'
|
|
2528
|
+
| 'td'
|
|
2529
|
+
| 'template'
|
|
2530
|
+
| 'textarea'
|
|
2531
|
+
| 'tfoot'
|
|
2532
|
+
| 'th'
|
|
2533
|
+
| 'thead'
|
|
2534
|
+
| 'time'
|
|
2535
|
+
| 'title'
|
|
2536
|
+
| 'tr'
|
|
2537
|
+
| 'track'
|
|
2538
|
+
| 'u'
|
|
2539
|
+
| 'ul'
|
|
2540
|
+
| 'var'
|
|
2541
|
+
| 'video'
|
|
2542
|
+
| 'wbr'
|
|
2543
|
+
|
|
2544
|
+
type ElementType = IntrinsicElement | Component
|
|
2545
|
+
|
|
2546
|
+
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2547
|
+
? JSX.IntrinsicElements[T]
|
|
2548
|
+
: T extends Component<infer Props>
|
|
2549
|
+
? Props
|
|
2550
|
+
: never
|
|
2551
|
+
|
|
2552
|
+
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2553
|
+
>
|
|
2554
|
+
|
|
2555
|
+
interface JsxFactory {
|
|
2556
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2560
|
+
|
|
2561
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2562
|
+
|
|
2563
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2564
|
+
`
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
|
|
1938
2568
|
// src/artifacts/jsx.ts
|
|
1939
2569
|
var typesMap = {
|
|
1940
2570
|
react: generateReactJsxTypes,
|
|
@@ -1943,10 +2573,18 @@ var typesMap = {
|
|
|
1943
2573
|
vue: generateVueJsxTypes,
|
|
1944
2574
|
qwik: generateQwikJsxTypes
|
|
1945
2575
|
};
|
|
2576
|
+
var typesStringLiteralMap = {
|
|
2577
|
+
react: generateSolidJsxStringLiteralTypes,
|
|
2578
|
+
solid: generateReactJsxStringLiteralTypes,
|
|
2579
|
+
qwik: generateQwikJsxStringLiteralTypes,
|
|
2580
|
+
preact: generatePreactJsxStringLiteralTypes,
|
|
2581
|
+
vue: generateVueJsxStringLiteralTypes
|
|
2582
|
+
};
|
|
1946
2583
|
function generateJsxTypes(ctx) {
|
|
1947
2584
|
if (!ctx.jsx.framework)
|
|
1948
2585
|
return;
|
|
1949
|
-
|
|
2586
|
+
const type = ctx.isTemplateLiteralSyntax ? typesStringLiteralMap[ctx.jsx.framework] : typesMap[ctx.jsx.framework];
|
|
2587
|
+
return type?.(ctx);
|
|
1950
2588
|
}
|
|
1951
2589
|
var factoryMap = {
|
|
1952
2590
|
react: generateReactJsxFactory,
|
|
@@ -1955,10 +2593,18 @@ var factoryMap = {
|
|
|
1955
2593
|
vue: generateVueJsxFactory,
|
|
1956
2594
|
qwik: generateQwikJsxFactory
|
|
1957
2595
|
};
|
|
2596
|
+
var factoryStringLiteralMap = {
|
|
2597
|
+
react: generateReactJsxStringLiteralFactory,
|
|
2598
|
+
solid: generateSolidJsxStringLiteralFactory,
|
|
2599
|
+
qwik: generateQwikJsxStringLiteralFactory,
|
|
2600
|
+
preact: generatePreactJsxStringLiteralFactory,
|
|
2601
|
+
vue: generateVueJsxStringLiteralFactory
|
|
2602
|
+
};
|
|
1958
2603
|
function generateJsxFactory(ctx) {
|
|
1959
2604
|
if (!ctx.jsx.framework)
|
|
1960
2605
|
return;
|
|
1961
|
-
|
|
2606
|
+
const factory = ctx.isTemplateLiteralSyntax ? factoryStringLiteralMap[ctx.jsx.framework] : factoryMap[ctx.jsx.framework];
|
|
2607
|
+
return factory?.(ctx);
|
|
1962
2608
|
}
|
|
1963
2609
|
var patternMap = {
|
|
1964
2610
|
react: generateReactJsxPattern,
|
|
@@ -1968,6 +2614,8 @@ var patternMap = {
|
|
|
1968
2614
|
qwik: generateQwikJsxPattern
|
|
1969
2615
|
};
|
|
1970
2616
|
function generateJsxPatterns(ctx) {
|
|
2617
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2618
|
+
return [];
|
|
1971
2619
|
if (ctx.patterns.isEmpty() && !ctx.jsx.framework)
|
|
1972
2620
|
return [];
|
|
1973
2621
|
return patternMap[ctx.jsx.framework](ctx);
|
|
@@ -2035,7 +2683,7 @@ var recipe_d_ts_default = {
|
|
|
2035
2683
|
|
|
2036
2684
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2037
2685
|
var pattern_d_ts_default = {
|
|
2038
|
-
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\ntype PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties
|
|
2686
|
+
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport type PatternHelpers = {\n map: (value: any, fn: (value: string) => string | undefined) => any\n}\n\ntype PatternProperties = Record<string, PatternProperty>\n\ntype Props<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternConfig<T extends PatternProperties = PatternProperties> = {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * The jsx element name this pattern will generate.\n */\n jsx?: string\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
2039
2687
|
};
|
|
2040
2688
|
|
|
2041
2689
|
// src/artifacts/generated/parts.d.ts.json
|
|
@@ -2062,9 +2710,9 @@ function getGeneratedTypes() {
|
|
|
2062
2710
|
}
|
|
2063
2711
|
|
|
2064
2712
|
// src/artifacts/types/main.ts
|
|
2065
|
-
import { outdent as
|
|
2713
|
+
import { outdent as outdent37 } from "outdent";
|
|
2066
2714
|
var generateTypesEntry = () => ({
|
|
2067
|
-
global:
|
|
2715
|
+
global: outdent37`
|
|
2068
2716
|
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2069
2717
|
import type { Parts } from './parts'
|
|
2070
2718
|
import type { PatternConfig } from './pattern'
|
|
@@ -2081,19 +2729,19 @@ var generateTypesEntry = () => ({
|
|
|
2081
2729
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>;
|
|
2082
2730
|
}
|
|
2083
2731
|
`,
|
|
2084
|
-
index:
|
|
2732
|
+
index: outdent37`
|
|
2085
2733
|
import './global'
|
|
2086
2734
|
export type { ConditionalValue } from './conditions'
|
|
2087
2735
|
export type { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
2088
2736
|
|
|
2089
2737
|
`,
|
|
2090
|
-
helpers:
|
|
2738
|
+
helpers: outdent37`
|
|
2091
2739
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2092
2740
|
`
|
|
2093
2741
|
});
|
|
2094
2742
|
|
|
2095
2743
|
// src/artifacts/types/prop-types.ts
|
|
2096
|
-
import { outdent as
|
|
2744
|
+
import { outdent as outdent38 } from "outdent";
|
|
2097
2745
|
function generatePropTypes(ctx) {
|
|
2098
2746
|
const {
|
|
2099
2747
|
config: { strictTokens },
|
|
@@ -2101,7 +2749,7 @@ function generatePropTypes(ctx) {
|
|
|
2101
2749
|
} = ctx;
|
|
2102
2750
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2103
2751
|
const result = [
|
|
2104
|
-
|
|
2752
|
+
outdent38`
|
|
2105
2753
|
import type { ConditionalValue } from './conditions';
|
|
2106
2754
|
import type { CssProperties } from './system-types'
|
|
2107
2755
|
import type { Tokens } from '../tokens'
|
|
@@ -2124,7 +2772,7 @@ function generatePropTypes(ctx) {
|
|
|
2124
2772
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2125
2773
|
});
|
|
2126
2774
|
result.push("}");
|
|
2127
|
-
return
|
|
2775
|
+
return outdent38`
|
|
2128
2776
|
${result.join("\n")}
|
|
2129
2777
|
|
|
2130
2778
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2137,10 +2785,10 @@ function generatePropTypes(ctx) {
|
|
|
2137
2785
|
|
|
2138
2786
|
// src/artifacts/types/style-props.ts
|
|
2139
2787
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
2140
|
-
import
|
|
2788
|
+
import outdent39 from "outdent";
|
|
2141
2789
|
function generateStyleProps(ctx) {
|
|
2142
2790
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
2143
|
-
return
|
|
2791
|
+
return outdent39`
|
|
2144
2792
|
import type { ConditionalValue } from './conditions'
|
|
2145
2793
|
import type { PropertyValue } from './prop-type'
|
|
2146
2794
|
import type { Token } from '../tokens'
|
|
@@ -2157,7 +2805,7 @@ function generateStyleProps(ctx) {
|
|
|
2157
2805
|
|
|
2158
2806
|
// src/artifacts/types/token-types.ts
|
|
2159
2807
|
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
2160
|
-
import { outdent as
|
|
2808
|
+
import { outdent as outdent40 } from "outdent";
|
|
2161
2809
|
import pluralize from "pluralize";
|
|
2162
2810
|
var categories = [
|
|
2163
2811
|
"zIndex",
|
|
@@ -2202,7 +2850,7 @@ function generateTokenTypes(ctx) {
|
|
|
2202
2850
|
result.add("} & { [token: string]: never }");
|
|
2203
2851
|
set.add(Array.from(result).join("\n"));
|
|
2204
2852
|
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
2205
|
-
return
|
|
2853
|
+
return outdent40.string(Array.from(set).join("\n\n"));
|
|
2206
2854
|
}
|
|
2207
2855
|
|
|
2208
2856
|
// src/artifacts/index.ts
|
|
@@ -2260,8 +2908,8 @@ function setupTypes(ctx) {
|
|
|
2260
2908
|
};
|
|
2261
2909
|
}
|
|
2262
2910
|
function setupCss(ctx) {
|
|
2263
|
-
const code = generateCssFn(ctx);
|
|
2264
|
-
const conditions = generateConditions(ctx);
|
|
2911
|
+
const code = ctx.isTemplateLiteralSyntax ? generateStringLiteralCssFn(ctx) : generateCssFn(ctx);
|
|
2912
|
+
const conditions = ctx.isTemplateLiteralSyntax ? generateStringLiteralConditions(ctx) : generateConditions(ctx);
|
|
2265
2913
|
return {
|
|
2266
2914
|
dir: ctx.paths.css,
|
|
2267
2915
|
files: [
|
|
@@ -2272,6 +2920,8 @@ function setupCss(ctx) {
|
|
|
2272
2920
|
};
|
|
2273
2921
|
}
|
|
2274
2922
|
function setupCva(ctx) {
|
|
2923
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2924
|
+
return;
|
|
2275
2925
|
const code = generateCvaFn(ctx);
|
|
2276
2926
|
return {
|
|
2277
2927
|
dir: ctx.paths.css,
|
|
@@ -2297,8 +2947,8 @@ function setupRecipes(ctx) {
|
|
|
2297
2947
|
return;
|
|
2298
2948
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2299
2949
|
const index = {
|
|
2300
|
-
js:
|
|
2301
|
-
dts:
|
|
2950
|
+
js: outdent41.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2951
|
+
dts: outdent41.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2302
2952
|
};
|
|
2303
2953
|
return {
|
|
2304
2954
|
dir: ctx.paths.recipe,
|
|
@@ -2311,12 +2961,14 @@ function setupRecipes(ctx) {
|
|
|
2311
2961
|
};
|
|
2312
2962
|
}
|
|
2313
2963
|
function setupPatterns(ctx) {
|
|
2964
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2965
|
+
return;
|
|
2314
2966
|
const files = generatePattern(ctx);
|
|
2315
2967
|
if (!files)
|
|
2316
2968
|
return;
|
|
2317
2969
|
const index = {
|
|
2318
|
-
js:
|
|
2319
|
-
dts:
|
|
2970
|
+
js: outdent41.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2971
|
+
dts: outdent41.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2320
2972
|
};
|
|
2321
2973
|
return {
|
|
2322
2974
|
dir: ctx.paths.pattern,
|
|
@@ -2336,13 +2988,13 @@ function setupJsx(ctx) {
|
|
|
2336
2988
|
const factory = generateJsxFactory(ctx);
|
|
2337
2989
|
const patterns = generateJsxPatterns(ctx);
|
|
2338
2990
|
const index = {
|
|
2339
|
-
js:
|
|
2991
|
+
js: outdent41`
|
|
2340
2992
|
${ctx.file.export("./factory")}
|
|
2341
|
-
${
|
|
2993
|
+
${outdent41.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
2342
2994
|
`,
|
|
2343
|
-
dts:
|
|
2995
|
+
dts: outdent41`
|
|
2344
2996
|
export * from './factory'
|
|
2345
|
-
${
|
|
2997
|
+
${outdent41.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
2346
2998
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
2347
2999
|
`
|
|
2348
3000
|
};
|
|
@@ -2351,7 +3003,7 @@ function setupJsx(ctx) {
|
|
|
2351
3003
|
files: [
|
|
2352
3004
|
...patterns.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
|
|
2353
3005
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
2354
|
-
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp
|
|
3006
|
+
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
2355
3007
|
{ file: "factory.d.ts", code: types.jsxFactory },
|
|
2356
3008
|
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
2357
3009
|
{ file: "index.d.ts", code: index.dts },
|
|
@@ -2361,15 +3013,15 @@ function setupJsx(ctx) {
|
|
|
2361
3013
|
}
|
|
2362
3014
|
function setupCssIndex(ctx) {
|
|
2363
3015
|
const index = {
|
|
2364
|
-
js:
|
|
3016
|
+
js: outdent41`
|
|
2365
3017
|
${ctx.file.export("./css")}
|
|
2366
3018
|
${ctx.file.export("./cx")}
|
|
2367
|
-
${ctx.file.export("./cva")}
|
|
3019
|
+
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./cva")}
|
|
2368
3020
|
`,
|
|
2369
|
-
dts:
|
|
3021
|
+
dts: outdent41`
|
|
2370
3022
|
export * from './css'
|
|
2371
3023
|
export * from './cx'
|
|
2372
|
-
export * from './cva'
|
|
3024
|
+
${ctx.isTemplateLiteralSyntax ? "" : `export * from './cva'`}
|
|
2373
3025
|
`
|
|
2374
3026
|
};
|
|
2375
3027
|
return {
|
|
@@ -2441,9 +3093,9 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
2441
3093
|
const { theme: { keyframes } = {}, preflight, minify, staticCss } = ctx.config;
|
|
2442
3094
|
const unresolved = [
|
|
2443
3095
|
"@layer reset, base, tokens, recipes, utilities;",
|
|
3096
|
+
preflight && "@import './reset.css';",
|
|
2444
3097
|
"@import './global.css';",
|
|
2445
3098
|
staticCss && "@import './static.css';",
|
|
2446
|
-
preflight && "@import './reset.css';",
|
|
2447
3099
|
!ctx.tokens.isEmpty && "@import './tokens/index.css';",
|
|
2448
3100
|
keyframes && "@import './tokens/keyframes.css';"
|
|
2449
3101
|
].filter(Boolean).join("\n\n");
|
|
@@ -2557,6 +3209,7 @@ var helpers = {
|
|
|
2557
3209
|
var getBaseEngine = (conf) => {
|
|
2558
3210
|
const { config } = conf;
|
|
2559
3211
|
const theme = config.theme ?? {};
|
|
3212
|
+
const isTemplateLiteralSyntax = config.syntax === "template-literal";
|
|
2560
3213
|
const hash = {
|
|
2561
3214
|
tokens: isBool(config.hash) ? config.hash : config.hash?.cssVar,
|
|
2562
3215
|
className: isBool(config.hash) ? config.hash : config.hash?.className
|
|
@@ -2575,12 +3228,12 @@ var getBaseEngine = (conf) => {
|
|
|
2575
3228
|
const utility = new Utility({
|
|
2576
3229
|
prefix: prefix.className,
|
|
2577
3230
|
tokens,
|
|
2578
|
-
config: config.utilities,
|
|
3231
|
+
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
2579
3232
|
separator: config.separator,
|
|
2580
3233
|
shorthands: config.shorthands
|
|
2581
3234
|
});
|
|
2582
3235
|
const conditions = new Conditions({
|
|
2583
|
-
conditions: config.conditions,
|
|
3236
|
+
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
|
2584
3237
|
breakpoints: config.theme?.breakpoints
|
|
2585
3238
|
});
|
|
2586
3239
|
const { textStyles, layerStyles } = theme;
|
|
@@ -2618,6 +3271,7 @@ var getBaseEngine = (conf) => {
|
|
|
2618
3271
|
};
|
|
2619
3272
|
return {
|
|
2620
3273
|
...conf,
|
|
3274
|
+
isTemplateLiteralSyntax,
|
|
2621
3275
|
studio,
|
|
2622
3276
|
hash,
|
|
2623
3277
|
prefix,
|
|
@@ -2699,7 +3353,7 @@ var getPatternEngine = (config) => {
|
|
|
2699
3353
|
return Object.entries(patterns).map(([name, pattern]) => ({
|
|
2700
3354
|
type: "pattern",
|
|
2701
3355
|
name: pattern.jsx ?? capitalize3(name),
|
|
2702
|
-
props: Object.keys(pattern
|
|
3356
|
+
props: Object.keys(pattern?.properties ?? {}),
|
|
2703
3357
|
baseName: name
|
|
2704
3358
|
}));
|
|
2705
3359
|
}),
|
|
@@ -2739,6 +3393,7 @@ var defaults = (conf) => ({
|
|
|
2739
3393
|
jsxFactory: "styled",
|
|
2740
3394
|
outExtension: "mjs",
|
|
2741
3395
|
shorthands: true,
|
|
3396
|
+
syntax: "object-literal",
|
|
2742
3397
|
...conf.config
|
|
2743
3398
|
}
|
|
2744
3399
|
});
|
|
@@ -2748,25 +3403,31 @@ var getImportMap = (outdir) => ({
|
|
|
2748
3403
|
pattern: `${outdir}/patterns`,
|
|
2749
3404
|
jsx: `${outdir}/jsx`
|
|
2750
3405
|
});
|
|
2751
|
-
var createGenerator = (conf) =>
|
|
2752
|
-
getEngine(defaults(conf))
|
|
2753
|
-
|
|
3406
|
+
var createGenerator = (conf) => {
|
|
3407
|
+
const ctx = getEngine(defaults(conf));
|
|
3408
|
+
const { config, jsx, isValidProperty, patterns, recipes } = ctx;
|
|
3409
|
+
const compilerOptions = conf.tsconfig?.compilerOptions ?? {};
|
|
3410
|
+
const baseUrl = compilerOptions.baseUrl ?? "";
|
|
3411
|
+
const cwd = conf.config.cwd;
|
|
3412
|
+
const relativeBaseUrl = baseUrl ? baseUrl.replace(cwd, "").slice(1) + "/" : cwd;
|
|
3413
|
+
return {
|
|
3414
|
+
...ctx,
|
|
2754
3415
|
getArtifacts: generateArtifacts(ctx),
|
|
2755
3416
|
getCss: generateFlattenedCss(ctx),
|
|
2756
3417
|
getParserCss: generateParserCss(ctx),
|
|
2757
|
-
messages: getMessages(ctx)
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
}
|
|
2769
|
-
|
|
3418
|
+
messages: getMessages(ctx),
|
|
3419
|
+
parserOptions: {
|
|
3420
|
+
importMap: getImportMap(config.outdir.replace(relativeBaseUrl, "")),
|
|
3421
|
+
jsx: {
|
|
3422
|
+
factory: jsx.factoryName,
|
|
3423
|
+
isStyleProp: isValidProperty,
|
|
3424
|
+
nodes: [...patterns.nodes, ...recipes.nodes]
|
|
3425
|
+
},
|
|
3426
|
+
getRecipeName: recipes.getFnName,
|
|
3427
|
+
getRecipeByName: recipes.getConfig
|
|
3428
|
+
}
|
|
3429
|
+
};
|
|
3430
|
+
};
|
|
2770
3431
|
export {
|
|
2771
3432
|
createGenerator,
|
|
2772
3433
|
messages_exports as messages
|