@pandacss/generator 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +267 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +763 -105
- package/dist/index.mjs +765 -107
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ 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`
|
|
@@ -102,7 +102,7 @@ import { Obj as Obj2, pipe as pipe3 } from "lil-fp";
|
|
|
102
102
|
|
|
103
103
|
// src/artifacts/index.ts
|
|
104
104
|
import { isObject } from "@pandacss/shared";
|
|
105
|
-
import
|
|
105
|
+
import outdent41 from "outdent";
|
|
106
106
|
|
|
107
107
|
// src/artifacts/css/global-css.ts
|
|
108
108
|
var generateGlobalCss = (ctx) => {
|
|
@@ -546,8 +546,39 @@ function generateConditions(ctx) {
|
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
// src/artifacts/js/conditions.string-literal.ts
|
|
550
|
+
import outdent3 from "outdent";
|
|
551
|
+
function generateStringLiteralConditions(ctx) {
|
|
552
|
+
return {
|
|
553
|
+
js: outdent3`
|
|
554
|
+
${ctx.file.import("withoutSpace", "../helpers")}
|
|
555
|
+
|
|
556
|
+
export const isCondition = (val) => condRegex.test(val)
|
|
557
|
+
|
|
558
|
+
const condRegex = /^@|&|&$/
|
|
559
|
+
const selectorRegex = /&|@/
|
|
560
|
+
|
|
561
|
+
export const finalizeConditions = (paths) => {
|
|
562
|
+
return paths.map((path) => (selectorRegex.test(path) ? \`[\${withoutSpace(path.trim())}]\` : path))
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function sortConditions(paths){
|
|
566
|
+
return paths.sort((a, b) => {
|
|
567
|
+
const aa = isCondition(a)
|
|
568
|
+
const bb = isCondition(b)
|
|
569
|
+
if (aa && !bb) return 1
|
|
570
|
+
if (!aa && bb) return -1
|
|
571
|
+
return 0
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
`,
|
|
575
|
+
dts: outdent3`
|
|
576
|
+
`
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
549
580
|
// src/artifacts/js/css-fn.ts
|
|
550
|
-
import { outdent as
|
|
581
|
+
import { outdent as outdent4 } from "outdent";
|
|
551
582
|
var stringify = (v) => JSON.stringify(Object.fromEntries(v), null, 2);
|
|
552
583
|
function generateCssFn(ctx) {
|
|
553
584
|
const {
|
|
@@ -557,11 +588,11 @@ function generateCssFn(ctx) {
|
|
|
557
588
|
} = ctx;
|
|
558
589
|
const { separator } = utility;
|
|
559
590
|
return {
|
|
560
|
-
dts:
|
|
591
|
+
dts: outdent4`
|
|
561
592
|
import type { SystemStyleObject } from '../types'
|
|
562
593
|
export declare function css(styles: SystemStyleObject): string
|
|
563
594
|
`,
|
|
564
|
-
js:
|
|
595
|
+
js: outdent4`
|
|
565
596
|
${ctx.file.import("createCss, createMergeCss, hypenateProperty, withoutSpace", "../helpers")}
|
|
566
597
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
567
598
|
|
|
@@ -604,11 +635,58 @@ function generateCssFn(ctx) {
|
|
|
604
635
|
};
|
|
605
636
|
}
|
|
606
637
|
|
|
638
|
+
// src/artifacts/js/css-fn.string-literal.ts
|
|
639
|
+
import { outdent as outdent5 } from "outdent";
|
|
640
|
+
function generateStringLiteralCssFn(ctx) {
|
|
641
|
+
const {
|
|
642
|
+
utility,
|
|
643
|
+
config: { hash, prefix }
|
|
644
|
+
} = ctx;
|
|
645
|
+
const { separator } = utility;
|
|
646
|
+
return {
|
|
647
|
+
dts: outdent5`
|
|
648
|
+
export declare function css(template: { raw: readonly string[] | ArrayLike<string> }): string
|
|
649
|
+
`,
|
|
650
|
+
js: outdent5`
|
|
651
|
+
${ctx.file.import("astish, createCss, withoutSpace", "../helpers")}
|
|
652
|
+
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
653
|
+
|
|
654
|
+
function transform(prop, value) {
|
|
655
|
+
const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
|
|
656
|
+
return { className }
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const context = {
|
|
660
|
+
hash: ${hash ? "true" : "false"},
|
|
661
|
+
conditions: {
|
|
662
|
+
shift: sortConditions,
|
|
663
|
+
finalize: finalizeConditions,
|
|
664
|
+
breakpoints: { keys: [] },
|
|
665
|
+
},
|
|
666
|
+
utility: {
|
|
667
|
+
prefix: ${prefix ? JSON.stringify(prefix) : void 0},
|
|
668
|
+
transform,
|
|
669
|
+
hasShorthand: false,
|
|
670
|
+
resolveShorthand(prop) {
|
|
671
|
+
return prop
|
|
672
|
+
},
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const cssFn = createCss(context)
|
|
677
|
+
|
|
678
|
+
export const css = (str) => {
|
|
679
|
+
return cssFn(astish(str[0]))
|
|
680
|
+
}
|
|
681
|
+
`
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
607
685
|
// src/artifacts/js/cva.ts
|
|
608
|
-
import { outdent as
|
|
686
|
+
import { outdent as outdent6 } from "outdent";
|
|
609
687
|
function generateCvaFn(ctx) {
|
|
610
688
|
return {
|
|
611
|
-
js:
|
|
689
|
+
js: outdent6`
|
|
612
690
|
${ctx.file.import("compact, splitProps", "../helpers")}
|
|
613
691
|
${ctx.file.import("css, mergeCss", "./css")}
|
|
614
692
|
|
|
@@ -674,7 +752,7 @@ function generateCvaFn(ctx) {
|
|
|
674
752
|
}
|
|
675
753
|
|
|
676
754
|
`,
|
|
677
|
-
dts:
|
|
755
|
+
dts: outdent6`
|
|
678
756
|
import type { RecipeCreatorFn } from '../types/recipe'
|
|
679
757
|
|
|
680
758
|
export declare const cva: RecipeCreatorFn
|
|
@@ -686,10 +764,10 @@ function generateCvaFn(ctx) {
|
|
|
686
764
|
}
|
|
687
765
|
|
|
688
766
|
// src/artifacts/js/cx.ts
|
|
689
|
-
import
|
|
767
|
+
import outdent7 from "outdent";
|
|
690
768
|
function generateCx() {
|
|
691
769
|
return {
|
|
692
|
-
js:
|
|
770
|
+
js: outdent7`
|
|
693
771
|
function cx() {
|
|
694
772
|
let str = '',
|
|
695
773
|
i = 0,
|
|
@@ -706,7 +784,7 @@ function generateCx() {
|
|
|
706
784
|
|
|
707
785
|
export { cx }
|
|
708
786
|
`,
|
|
709
|
-
dts:
|
|
787
|
+
dts: outdent7`
|
|
710
788
|
type Argument = string | boolean | null | undefined
|
|
711
789
|
|
|
712
790
|
/** Conditionally join classNames into a single string */
|
|
@@ -716,17 +794,17 @@ function generateCx() {
|
|
|
716
794
|
}
|
|
717
795
|
|
|
718
796
|
// src/artifacts/js/helpers.ts
|
|
719
|
-
import { outdent as
|
|
797
|
+
import { outdent as outdent8 } from "outdent";
|
|
720
798
|
|
|
721
799
|
// src/artifacts/generated/helpers.mjs.json
|
|
722
800
|
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 result[key] = inner(child, childPath);\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/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}\
|
|
801
|
+
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\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 result[key] = inner(child, childPath);\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
802
|
};
|
|
725
803
|
|
|
726
804
|
// src/artifacts/js/helpers.ts
|
|
727
805
|
function generateHelpers() {
|
|
728
806
|
return {
|
|
729
|
-
js:
|
|
807
|
+
js: outdent8`
|
|
730
808
|
${helpers_mjs_default.content}
|
|
731
809
|
|
|
732
810
|
export function __spreadValues(a, b){
|
|
@@ -747,6 +825,8 @@ var is_valid_prop_mjs_default = {
|
|
|
747
825
|
|
|
748
826
|
// src/artifacts/js/is-valid-prop.ts
|
|
749
827
|
function generateisValidProp(ctx) {
|
|
828
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
829
|
+
return;
|
|
750
830
|
let content = is_valid_prop_mjs_default.content;
|
|
751
831
|
content = content.replace(
|
|
752
832
|
"var userGenerated = []",
|
|
@@ -760,7 +840,7 @@ function generateisValidProp(ctx) {
|
|
|
760
840
|
// src/artifacts/js/pattern.ts
|
|
761
841
|
import { unionType } from "@pandacss/shared";
|
|
762
842
|
import { stringify as stringify2 } from "javascript-stringify";
|
|
763
|
-
import { outdent as
|
|
843
|
+
import { outdent as outdent9 } from "outdent";
|
|
764
844
|
import { match } from "ts-pattern";
|
|
765
845
|
function generatePattern(ctx) {
|
|
766
846
|
if (ctx.patterns.isEmpty())
|
|
@@ -778,7 +858,7 @@ function generatePattern(ctx) {
|
|
|
778
858
|
}
|
|
779
859
|
return {
|
|
780
860
|
name: dashName,
|
|
781
|
-
dts:
|
|
861
|
+
dts: outdent9`
|
|
782
862
|
import type { SystemStyleObject, ConditionalValue } from '../types'
|
|
783
863
|
import type { PropertyValue } from '../types/prop-type'
|
|
784
864
|
import type { Properties } from '../types/csstype'
|
|
@@ -802,7 +882,7 @@ function generatePattern(ctx) {
|
|
|
802
882
|
}).join("\n ")}
|
|
803
883
|
}
|
|
804
884
|
|
|
805
|
-
${strict ?
|
|
885
|
+
${strict ? outdent9`export declare function ${name}(options: ${upperName}Properties): string` : outdent9`
|
|
806
886
|
|
|
807
887
|
type ${upperName}Options = ${upperName}Properties & Omit<SystemStyleObject, keyof ${upperName}Properties ${blocklistType}>
|
|
808
888
|
|
|
@@ -811,7 +891,7 @@ function generatePattern(ctx) {
|
|
|
811
891
|
`}
|
|
812
892
|
|
|
813
893
|
`,
|
|
814
|
-
js:
|
|
894
|
+
js: outdent9`
|
|
815
895
|
${ctx.file.import(helperImports.join(", "), "../helpers")}
|
|
816
896
|
${ctx.file.import("css", "../css/index")}
|
|
817
897
|
|
|
@@ -828,7 +908,7 @@ transform`)}
|
|
|
828
908
|
|
|
829
909
|
// src/artifacts/js/recipe.ts
|
|
830
910
|
import { unionType as unionType2 } from "@pandacss/shared";
|
|
831
|
-
import { outdent as
|
|
911
|
+
import { outdent as outdent10 } from "outdent";
|
|
832
912
|
var stringify3 = (value) => JSON.stringify(value, null, 2);
|
|
833
913
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
834
914
|
function generateRecipes(ctx) {
|
|
@@ -842,7 +922,7 @@ function generateRecipes(ctx) {
|
|
|
842
922
|
const createRecipeFn = {
|
|
843
923
|
name: "create-recipe",
|
|
844
924
|
dts: "",
|
|
845
|
-
js:
|
|
925
|
+
js: outdent10`
|
|
846
926
|
${ctx.file.import("css", "../css/css")}
|
|
847
927
|
${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
|
|
848
928
|
${ctx.file.import("cx", "../css/cx")}
|
|
@@ -889,7 +969,7 @@ function generateRecipes(ctx) {
|
|
|
889
969
|
const { name, description, defaultVariants, compoundVariants } = config;
|
|
890
970
|
return {
|
|
891
971
|
name: dashName,
|
|
892
|
-
js:
|
|
972
|
+
js: outdent10`
|
|
893
973
|
${ctx.file.import("splitProps", "../helpers")}
|
|
894
974
|
${ctx.file.import("createRecipe", "./create-recipe")}
|
|
895
975
|
|
|
@@ -910,7 +990,7 @@ function generateRecipes(ctx) {
|
|
|
910
990
|
splitVariantProps,
|
|
911
991
|
})
|
|
912
992
|
`,
|
|
913
|
-
dts:
|
|
993
|
+
dts: outdent10`
|
|
914
994
|
import type { ConditionalValue } from '../types'
|
|
915
995
|
import type { Pretty } from '../types/helpers'
|
|
916
996
|
|
|
@@ -948,7 +1028,7 @@ function generateRecipes(ctx) {
|
|
|
948
1028
|
}
|
|
949
1029
|
|
|
950
1030
|
// src/artifacts/js/token.ts
|
|
951
|
-
import
|
|
1031
|
+
import outdent11 from "outdent";
|
|
952
1032
|
function generateTokenJs(ctx) {
|
|
953
1033
|
const { tokens } = ctx;
|
|
954
1034
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -959,7 +1039,7 @@ function generateTokenJs(ctx) {
|
|
|
959
1039
|
});
|
|
960
1040
|
const obj = Object.fromEntries(map);
|
|
961
1041
|
return {
|
|
962
|
-
js:
|
|
1042
|
+
js: outdent11`
|
|
963
1043
|
const tokens = ${JSON.stringify(obj, null, 2)}
|
|
964
1044
|
|
|
965
1045
|
export function token(path, fallback) {
|
|
@@ -972,7 +1052,7 @@ function generateTokenJs(ctx) {
|
|
|
972
1052
|
|
|
973
1053
|
token.var = tokenVar
|
|
974
1054
|
`,
|
|
975
|
-
dts:
|
|
1055
|
+
dts: outdent11`
|
|
976
1056
|
import type { Token } from './tokens'
|
|
977
1057
|
|
|
978
1058
|
export declare const token: {
|
|
@@ -986,11 +1066,11 @@ function generateTokenJs(ctx) {
|
|
|
986
1066
|
}
|
|
987
1067
|
|
|
988
1068
|
// src/artifacts/preact-jsx/jsx.ts
|
|
989
|
-
import { outdent as
|
|
1069
|
+
import { outdent as outdent12 } from "outdent";
|
|
990
1070
|
function generatePreactJsxFactory(ctx) {
|
|
991
1071
|
const { factoryName, componentName } = ctx.jsx;
|
|
992
1072
|
return {
|
|
993
|
-
js:
|
|
1073
|
+
js: outdent12`
|
|
994
1074
|
import { h } from 'preact'
|
|
995
1075
|
import { forwardRef } from 'preact/compat'
|
|
996
1076
|
import { useMemo } from 'preact/hooks'
|
|
@@ -1057,7 +1137,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1057
1137
|
}
|
|
1058
1138
|
|
|
1059
1139
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1060
|
-
import { outdent as
|
|
1140
|
+
import { outdent as outdent13 } from "outdent";
|
|
1061
1141
|
import { match as match2 } from "ts-pattern";
|
|
1062
1142
|
function generatePreactJsxPattern(ctx) {
|
|
1063
1143
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1066,7 +1146,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1066
1146
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1067
1147
|
return {
|
|
1068
1148
|
name: dashName,
|
|
1069
|
-
js:
|
|
1149
|
+
js: outdent13`
|
|
1070
1150
|
import { h } from 'preact'
|
|
1071
1151
|
import { forwardRef } from 'preact/compat'
|
|
1072
1152
|
${ctx.file.import(factoryName, "./factory")}
|
|
@@ -1075,12 +1155,12 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1075
1155
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1076
1156
|
${match2(props.length).with(
|
|
1077
1157
|
0,
|
|
1078
|
-
() =>
|
|
1158
|
+
() => outdent13`
|
|
1079
1159
|
const styleProps = ${styleFnName}()
|
|
1080
1160
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1081
1161
|
`
|
|
1082
1162
|
).otherwise(
|
|
1083
|
-
() =>
|
|
1163
|
+
() => outdent13`
|
|
1084
1164
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1085
1165
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1086
1166
|
return h(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1088,7 +1168,7 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1088
1168
|
)}
|
|
1089
1169
|
})
|
|
1090
1170
|
`,
|
|
1091
|
-
dts:
|
|
1171
|
+
dts: outdent13`
|
|
1092
1172
|
import type { FunctionComponent } from 'preact'
|
|
1093
1173
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1094
1174
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1103,15 +1183,15 @@ function generatePreactJsxPattern(ctx) {
|
|
|
1103
1183
|
}
|
|
1104
1184
|
|
|
1105
1185
|
// src/artifacts/preact-jsx/types.ts
|
|
1106
|
-
import { outdent as
|
|
1186
|
+
import { outdent as outdent14 } from "outdent";
|
|
1107
1187
|
function generatePreactJsxTypes(ctx) {
|
|
1108
1188
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1109
1189
|
return {
|
|
1110
|
-
jsxFactory:
|
|
1190
|
+
jsxFactory: outdent14`
|
|
1111
1191
|
import type { ${upperName} } from '../types/jsx'
|
|
1112
1192
|
export declare const ${factoryName}: ${upperName}
|
|
1113
1193
|
`,
|
|
1114
|
-
jsxType:
|
|
1194
|
+
jsxType: outdent14`
|
|
1115
1195
|
import type { ComponentProps, JSX } from 'preact'
|
|
1116
1196
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1117
1197
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1145,12 +1225,96 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1145
1225
|
};
|
|
1146
1226
|
}
|
|
1147
1227
|
|
|
1228
|
+
// src/artifacts/preact-jsx/jsx.string-literal.ts
|
|
1229
|
+
import { outdent as outdent15 } from "outdent";
|
|
1230
|
+
function generatePreactJsxStringLiteralFactory(ctx) {
|
|
1231
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1232
|
+
return {
|
|
1233
|
+
js: outdent15`
|
|
1234
|
+
import { h } from 'preact'
|
|
1235
|
+
import { forwardRef } from 'preact/compat'
|
|
1236
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1237
|
+
|
|
1238
|
+
function createStyledFn(Dynamic) {
|
|
1239
|
+
return function styledFn(template) {
|
|
1240
|
+
const baseClassName = css(template)
|
|
1241
|
+
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1242
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1243
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1244
|
+
|
|
1245
|
+
return h(Element, {
|
|
1246
|
+
ref,
|
|
1247
|
+
...elementProps,
|
|
1248
|
+
className: classes(),
|
|
1249
|
+
})
|
|
1250
|
+
})
|
|
1251
|
+
|
|
1252
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1253
|
+
return ${componentName}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
function createJsxFactory() {
|
|
1258
|
+
const cache = new Map()
|
|
1259
|
+
|
|
1260
|
+
return new Proxy(createStyledFn, {
|
|
1261
|
+
apply(_, __, args) {
|
|
1262
|
+
return createStyledFn(...args)
|
|
1263
|
+
},
|
|
1264
|
+
get(_, el) {
|
|
1265
|
+
if (!cache.has(el)) {
|
|
1266
|
+
cache.set(el, createStyledFn(el))
|
|
1267
|
+
}
|
|
1268
|
+
return cache.get(el)
|
|
1269
|
+
},
|
|
1270
|
+
})
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
export const ${factoryName} = createJsxFactory()
|
|
1274
|
+
`
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// src/artifacts/preact-jsx/types.string-literal.ts
|
|
1279
|
+
import { outdent as outdent16 } from "outdent";
|
|
1280
|
+
function generatePreactJsxStringLiteralTypes(ctx) {
|
|
1281
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1282
|
+
return {
|
|
1283
|
+
jsxFactory: outdent16`
|
|
1284
|
+
import type { ${upperName} } from '../types/jsx'
|
|
1285
|
+
export declare const ${factoryName}: ${upperName}
|
|
1286
|
+
`,
|
|
1287
|
+
jsxType: outdent16`
|
|
1288
|
+
import type { ComponentProps, JSX } from 'preact'
|
|
1289
|
+
|
|
1290
|
+
type ElementType = keyof JSX.IntrinsicElements
|
|
1291
|
+
|
|
1292
|
+
type Dict = Record<string, unknown>
|
|
1293
|
+
|
|
1294
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1295
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1296
|
+
displayName?: string
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
interface JsxFactory {
|
|
1300
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1304
|
+
|
|
1305
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1306
|
+
|
|
1307
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1308
|
+
`
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1148
1312
|
// src/artifacts/qwik-jsx/jsx.ts
|
|
1149
|
-
import { outdent as
|
|
1313
|
+
import { outdent as outdent17 } from "outdent";
|
|
1150
1314
|
function generateQwikJsxFactory(ctx) {
|
|
1151
1315
|
const { factoryName, componentName } = ctx.jsx;
|
|
1152
1316
|
return {
|
|
1153
|
-
js:
|
|
1317
|
+
js: outdent17`
|
|
1154
1318
|
import { h } from '@builder.io/qwik'
|
|
1155
1319
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1156
1320
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1214,7 +1378,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1214
1378
|
}
|
|
1215
1379
|
|
|
1216
1380
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1217
|
-
import { outdent as
|
|
1381
|
+
import { outdent as outdent18 } from "outdent";
|
|
1218
1382
|
import { match as match3 } from "ts-pattern";
|
|
1219
1383
|
function generateQwikJsxPattern(ctx) {
|
|
1220
1384
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1223,7 +1387,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1223
1387
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1224
1388
|
return {
|
|
1225
1389
|
name: dashName,
|
|
1226
|
-
js:
|
|
1390
|
+
js: outdent18`
|
|
1227
1391
|
import { h } from '@builder.io/qwik'
|
|
1228
1392
|
${ctx.file.import(factoryName, "./factory")}
|
|
1229
1393
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1231,12 +1395,12 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1231
1395
|
export const ${jsxName} = function ${jsxName}(props) {
|
|
1232
1396
|
${match3(props.length).with(
|
|
1233
1397
|
0,
|
|
1234
|
-
() =>
|
|
1398
|
+
() => outdent18`
|
|
1235
1399
|
const styleProps = ${styleFnName}()
|
|
1236
1400
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...props })
|
|
1237
1401
|
`
|
|
1238
1402
|
).otherwise(
|
|
1239
|
-
() =>
|
|
1403
|
+
() => outdent18`
|
|
1240
1404
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1241
1405
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1242
1406
|
return h(${factoryName}.${jsxElement}, { ...styleProps, ...restProps })
|
|
@@ -1244,7 +1408,7 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1244
1408
|
)}
|
|
1245
1409
|
}
|
|
1246
1410
|
`,
|
|
1247
|
-
dts:
|
|
1411
|
+
dts: outdent18`
|
|
1248
1412
|
import type { FunctionComponent } from '@builder.io/qwik'
|
|
1249
1413
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1250
1414
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1263,15 +1427,15 @@ function generateQwikJsxPattern(ctx) {
|
|
|
1263
1427
|
}
|
|
1264
1428
|
|
|
1265
1429
|
// src/artifacts/qwik-jsx/types.ts
|
|
1266
|
-
import { outdent as
|
|
1430
|
+
import { outdent as outdent19 } from "outdent";
|
|
1267
1431
|
function generateQwikJsxTypes(ctx) {
|
|
1268
1432
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1269
1433
|
return {
|
|
1270
|
-
jsxFactory:
|
|
1434
|
+
jsxFactory: outdent19`
|
|
1271
1435
|
import { ${upperName} } from '../types/jsx'
|
|
1272
1436
|
export declare const ${factoryName}: ${upperName}
|
|
1273
1437
|
`,
|
|
1274
|
-
jsxType:
|
|
1438
|
+
jsxType: outdent19`
|
|
1275
1439
|
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1276
1440
|
import type { Assign as _Assign, JsxStyleProps, PatchedHTMLProps } from './system-types'
|
|
1277
1441
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1324,12 +1488,100 @@ export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T>, JsxSt
|
|
|
1324
1488
|
};
|
|
1325
1489
|
}
|
|
1326
1490
|
|
|
1491
|
+
// src/artifacts/qwik-jsx/jsx.string-literal.ts
|
|
1492
|
+
import { outdent as outdent20 } from "outdent";
|
|
1493
|
+
function generateQwikJsxStringLiteralFactory(ctx) {
|
|
1494
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1495
|
+
return {
|
|
1496
|
+
js: outdent20`
|
|
1497
|
+
import { h } from '@builder.io/qwik'
|
|
1498
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1499
|
+
|
|
1500
|
+
function createStyledFn(Dynamic) {
|
|
1501
|
+
return function styledFn(template) {
|
|
1502
|
+
const baseClassName = css(template)
|
|
1503
|
+
const ${componentName} = function ${componentName}(props) {
|
|
1504
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1505
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1506
|
+
|
|
1507
|
+
return h(Element, {
|
|
1508
|
+
...elementProps,
|
|
1509
|
+
className: classes(),
|
|
1510
|
+
})
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1514
|
+
return ${componentName}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
function createJsxFactory() {
|
|
1519
|
+
const cache = new Map()
|
|
1520
|
+
|
|
1521
|
+
return new Proxy(createStyledFn, {
|
|
1522
|
+
apply(_, __, args) {
|
|
1523
|
+
return createStyledFn(...args)
|
|
1524
|
+
},
|
|
1525
|
+
get(_, el) {
|
|
1526
|
+
if (!cache.has(el)) {
|
|
1527
|
+
cache.set(el, createStyledFn(el))
|
|
1528
|
+
}
|
|
1529
|
+
return cache.get(el)
|
|
1530
|
+
},
|
|
1531
|
+
})
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
export const ${factoryName} = createJsxFactory()
|
|
1535
|
+
|
|
1536
|
+
`
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// src/artifacts/qwik-jsx/types.string-literal.ts
|
|
1541
|
+
import { outdent as outdent21 } from "outdent";
|
|
1542
|
+
function generateQwikJsxStringLiteralTypes(ctx) {
|
|
1543
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1544
|
+
return {
|
|
1545
|
+
jsxFactory: outdent21`
|
|
1546
|
+
import { ${upperName} } from '../types/jsx'
|
|
1547
|
+
export declare const ${factoryName}: ${upperName}
|
|
1548
|
+
`,
|
|
1549
|
+
jsxType: outdent21`
|
|
1550
|
+
import type { FunctionComponent, QwikIntrinsicElements } from '@builder.io/qwik'
|
|
1551
|
+
|
|
1552
|
+
type ElementType = keyof QwikIntrinsicElements | FunctionComponent<any>
|
|
1553
|
+
|
|
1554
|
+
type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
|
|
1555
|
+
? QwikIntrinsicElements[T]
|
|
1556
|
+
: T extends FunctionComponent<infer P>
|
|
1557
|
+
? P
|
|
1558
|
+
: never
|
|
1559
|
+
|
|
1560
|
+
type Dict = Record<string, unknown>
|
|
1561
|
+
|
|
1562
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1563
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
interface JsxFactory {
|
|
1567
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
type JsxElements = { [K in keyof QwikIntrinsicElements]: ${componentName}<K> }
|
|
1571
|
+
|
|
1572
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1573
|
+
|
|
1574
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1575
|
+
`
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1327
1579
|
// src/artifacts/react-jsx/jsx.ts
|
|
1328
|
-
import { outdent as
|
|
1580
|
+
import { outdent as outdent22 } from "outdent";
|
|
1329
1581
|
function generateReactJsxFactory(ctx) {
|
|
1330
1582
|
const { factoryName, componentName } = ctx.jsx;
|
|
1331
1583
|
return {
|
|
1332
|
-
js:
|
|
1584
|
+
js: outdent22`
|
|
1333
1585
|
import { createElement, forwardRef, useMemo } from 'react'
|
|
1334
1586
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1335
1587
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1395,7 +1647,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1395
1647
|
}
|
|
1396
1648
|
|
|
1397
1649
|
// src/artifacts/react-jsx/pattern.ts
|
|
1398
|
-
import { outdent as
|
|
1650
|
+
import { outdent as outdent23 } from "outdent";
|
|
1399
1651
|
import { match as match4 } from "ts-pattern";
|
|
1400
1652
|
function generateReactJsxPattern(ctx) {
|
|
1401
1653
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1404,7 +1656,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1404
1656
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1405
1657
|
return {
|
|
1406
1658
|
name: dashName,
|
|
1407
|
-
js:
|
|
1659
|
+
js: outdent23`
|
|
1408
1660
|
import { createElement, forwardRef } from 'react'
|
|
1409
1661
|
${ctx.file.import(factoryName, "./factory")}
|
|
1410
1662
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1412,12 +1664,12 @@ function generateReactJsxPattern(ctx) {
|
|
|
1412
1664
|
export const ${jsxName} = forwardRef(function ${jsxName}(props, ref) {
|
|
1413
1665
|
${match4(props.length).with(
|
|
1414
1666
|
0,
|
|
1415
|
-
() =>
|
|
1667
|
+
() => outdent23`
|
|
1416
1668
|
const styleProps = ${styleFnName}()
|
|
1417
1669
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...props })
|
|
1418
1670
|
`
|
|
1419
1671
|
).otherwise(
|
|
1420
|
-
() =>
|
|
1672
|
+
() => outdent23`
|
|
1421
1673
|
const { ${props.join(", ")}, ...restProps } = props
|
|
1422
1674
|
const styleProps = ${styleFnName}({${props.join(", ")}})
|
|
1423
1675
|
return createElement(${factoryName}.${jsxElement}, { ref, ...styleProps, ...restProps })
|
|
@@ -1425,7 +1677,7 @@ function generateReactJsxPattern(ctx) {
|
|
|
1425
1677
|
)}
|
|
1426
1678
|
})
|
|
1427
1679
|
`,
|
|
1428
|
-
dts:
|
|
1680
|
+
dts: outdent23`
|
|
1429
1681
|
import type { FunctionComponent } from 'react'
|
|
1430
1682
|
import type { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1431
1683
|
import type { ${typeName} } from '../types/jsx'
|
|
@@ -1440,15 +1692,15 @@ function generateReactJsxPattern(ctx) {
|
|
|
1440
1692
|
}
|
|
1441
1693
|
|
|
1442
1694
|
// src/artifacts/react-jsx/types.ts
|
|
1443
|
-
import { outdent as
|
|
1695
|
+
import { outdent as outdent24 } from "outdent";
|
|
1444
1696
|
function generateReactJsxTypes(ctx) {
|
|
1445
1697
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1446
1698
|
return {
|
|
1447
|
-
jsxFactory:
|
|
1699
|
+
jsxFactory: outdent24`
|
|
1448
1700
|
import { ${upperName} } from '../types/jsx'
|
|
1449
1701
|
export declare const ${factoryName}: ${upperName}
|
|
1450
1702
|
`,
|
|
1451
|
-
jsxType:
|
|
1703
|
+
jsxType: outdent24`
|
|
1452
1704
|
import type { ComponentProps, ElementType } from 'react'
|
|
1453
1705
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1454
1706
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1471,21 +1723,103 @@ interface JsxFactory {
|
|
|
1471
1723
|
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P): ${componentName}<T, P['__type']>
|
|
1472
1724
|
}
|
|
1473
1725
|
|
|
1474
|
-
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1726
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
1727
|
+
|
|
1728
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
1729
|
+
|
|
1730
|
+
export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>, JsxStyleProps>
|
|
1731
|
+
`
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// src/artifacts/react-jsx/jsx.string-literal.ts
|
|
1736
|
+
import { outdent as outdent25 } from "outdent";
|
|
1737
|
+
function generateReactJsxStringLiteralFactory(ctx) {
|
|
1738
|
+
const { factoryName, componentName } = ctx.jsx;
|
|
1739
|
+
return {
|
|
1740
|
+
js: outdent25`
|
|
1741
|
+
import { createElement, forwardRef } from 'react'
|
|
1742
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1743
|
+
|
|
1744
|
+
function createStyledFn(Dynamic) {
|
|
1745
|
+
return function styledFn(template) {
|
|
1746
|
+
const baseClassName = css(template)
|
|
1747
|
+
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
1748
|
+
const { as: Element = Dynamic, ...elementProps } = props
|
|
1749
|
+
const classes = () => cx(baseClassName, elementProps.className)
|
|
1750
|
+
|
|
1751
|
+
return createElement(Element, {
|
|
1752
|
+
ref,
|
|
1753
|
+
...elementProps,
|
|
1754
|
+
className: classes(),
|
|
1755
|
+
})
|
|
1756
|
+
})
|
|
1757
|
+
|
|
1758
|
+
${componentName}.displayName = \`${factoryName}.\${Dynamic}\`
|
|
1759
|
+
return ${componentName}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
function createJsxFactory() {
|
|
1764
|
+
const cache = new Map()
|
|
1765
|
+
|
|
1766
|
+
return new Proxy(createStyledFn, {
|
|
1767
|
+
apply(_, __, args) {
|
|
1768
|
+
return createStyledFn(...args)
|
|
1769
|
+
},
|
|
1770
|
+
get(_, el) {
|
|
1771
|
+
if (!cache.has(el)) {
|
|
1772
|
+
cache.set(el, createStyledFn(el))
|
|
1773
|
+
}
|
|
1774
|
+
return cache.get(el)
|
|
1775
|
+
},
|
|
1776
|
+
})
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
export const ${factoryName} = createJsxFactory()
|
|
1780
|
+
|
|
1781
|
+
`
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
// src/artifacts/react-jsx/types.string-literal.ts
|
|
1786
|
+
import { outdent as outdent26 } from "outdent";
|
|
1787
|
+
function generateReactJsxStringLiteralTypes(ctx) {
|
|
1788
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1789
|
+
return {
|
|
1790
|
+
jsxFactory: outdent26`
|
|
1791
|
+
import { ${upperName} } from '../types/jsx'
|
|
1792
|
+
export declare const ${factoryName}: ${upperName}
|
|
1793
|
+
`,
|
|
1794
|
+
jsxType: outdent26`
|
|
1795
|
+
import type { ComponentProps, ElementType } from 'react'
|
|
1796
|
+
|
|
1797
|
+
type Dict = Record<string, unknown>
|
|
1798
|
+
|
|
1799
|
+
export type ${componentName}<T extends ElementType> = {
|
|
1800
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
1801
|
+
displayName?: string
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
interface JsxFactory {
|
|
1805
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
1475
1809
|
|
|
1476
1810
|
export type ${upperName} = JsxFactory & JsxElements
|
|
1477
1811
|
|
|
1478
|
-
export type ${typeName}<T extends ElementType> =
|
|
1812
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
1479
1813
|
`
|
|
1480
1814
|
};
|
|
1481
1815
|
}
|
|
1482
1816
|
|
|
1483
1817
|
// src/artifacts/solid-jsx/jsx.ts
|
|
1484
|
-
import { outdent as
|
|
1818
|
+
import { outdent as outdent27 } from "outdent";
|
|
1485
1819
|
function generateSolidJsxFactory(ctx) {
|
|
1486
1820
|
const { componentName, factoryName } = ctx.jsx;
|
|
1487
1821
|
return {
|
|
1488
|
-
js:
|
|
1822
|
+
js: outdent27`
|
|
1489
1823
|
import { Dynamic } from 'solid-js/web'
|
|
1490
1824
|
import { mergeProps, splitProps } from 'solid-js'
|
|
1491
1825
|
import { createComponent } from 'solid-js/web'
|
|
@@ -1562,7 +1896,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
1562
1896
|
}
|
|
1563
1897
|
|
|
1564
1898
|
// src/artifacts/solid-jsx/pattern.ts
|
|
1565
|
-
import { outdent as
|
|
1899
|
+
import { outdent as outdent28 } from "outdent";
|
|
1566
1900
|
import { match as match5 } from "ts-pattern";
|
|
1567
1901
|
function generateSolidJsxPattern(ctx) {
|
|
1568
1902
|
const { typeName, factoryName } = ctx.jsx;
|
|
@@ -1571,7 +1905,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1571
1905
|
const { description, jsxElement = "div" } = pattern.config;
|
|
1572
1906
|
return {
|
|
1573
1907
|
name: dashName,
|
|
1574
|
-
js:
|
|
1908
|
+
js: outdent28`
|
|
1575
1909
|
import { splitProps, mergeProps } from 'solid-js'
|
|
1576
1910
|
import { createComponent } from 'solid-js/web'
|
|
1577
1911
|
${ctx.file.import(factoryName, "./factory")}
|
|
@@ -1580,12 +1914,12 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1580
1914
|
export function ${jsxName}(props) {
|
|
1581
1915
|
${match5(props.length).with(
|
|
1582
1916
|
0,
|
|
1583
|
-
() =>
|
|
1917
|
+
() => outdent28`
|
|
1584
1918
|
const styleProps = ${styleFnName}()
|
|
1585
1919
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, props))
|
|
1586
1920
|
`
|
|
1587
1921
|
).otherwise(
|
|
1588
|
-
() =>
|
|
1922
|
+
() => outdent28`
|
|
1589
1923
|
const [patternProps, restProps] = splitProps(props, [${props.map((v) => JSON.stringify(v)).join(", ")}]);
|
|
1590
1924
|
const styleProps = ${styleFnName}(patternProps)
|
|
1591
1925
|
return createComponent(${factoryName}.${jsxElement}, mergeProps(styleProps, restProps))
|
|
@@ -1593,7 +1927,7 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1593
1927
|
)}
|
|
1594
1928
|
}
|
|
1595
1929
|
`,
|
|
1596
|
-
dts:
|
|
1930
|
+
dts: outdent28`
|
|
1597
1931
|
import { Component } from 'solid-js'
|
|
1598
1932
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1599
1933
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1608,15 +1942,15 @@ function generateSolidJsxPattern(ctx) {
|
|
|
1608
1942
|
}
|
|
1609
1943
|
|
|
1610
1944
|
// src/artifacts/solid-jsx/types.ts
|
|
1611
|
-
import { outdent as
|
|
1945
|
+
import { outdent as outdent29 } from "outdent";
|
|
1612
1946
|
function generateSolidJsxTypes(ctx) {
|
|
1613
1947
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1614
1948
|
return {
|
|
1615
|
-
jsxFactory:
|
|
1949
|
+
jsxFactory: outdent29`
|
|
1616
1950
|
import type { ${upperName} } from '../types/jsx'
|
|
1617
1951
|
export declare const ${factoryName}: ${upperName}
|
|
1618
1952
|
`,
|
|
1619
|
-
jsxType:
|
|
1953
|
+
jsxType: outdent29`
|
|
1620
1954
|
import type { ComponentProps, Component, JSX } from 'solid-js'
|
|
1621
1955
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1622
1956
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1650,12 +1984,102 @@ export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T>,
|
|
|
1650
1984
|
};
|
|
1651
1985
|
}
|
|
1652
1986
|
|
|
1987
|
+
// src/artifacts/solid-jsx/jsx.string-literal.ts
|
|
1988
|
+
import { outdent as outdent30 } from "outdent";
|
|
1989
|
+
function generateSolidJsxStringLiteralFactory(ctx) {
|
|
1990
|
+
const { componentName, factoryName } = ctx.jsx;
|
|
1991
|
+
return {
|
|
1992
|
+
js: outdent30`
|
|
1993
|
+
import { mergeProps, splitProps } from 'solid-js'
|
|
1994
|
+
import { Dynamic, createComponent } from 'solid-js/web'
|
|
1995
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
1996
|
+
|
|
1997
|
+
function createStyled(element) {
|
|
1998
|
+
return function styledFn(template) {
|
|
1999
|
+
const baseClassName = css(template)
|
|
2000
|
+
return function ${componentName}(props) {
|
|
2001
|
+
const mergedProps = mergeProps({ as: element }, props)
|
|
2002
|
+
const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
|
|
2003
|
+
|
|
2004
|
+
return createComponent(
|
|
2005
|
+
Dynamic,
|
|
2006
|
+
mergeProps(
|
|
2007
|
+
{
|
|
2008
|
+
get component() {
|
|
2009
|
+
return localProps.as
|
|
2010
|
+
},
|
|
2011
|
+
get class() {
|
|
2012
|
+
return cx(baseClassName, localProps.class)
|
|
2013
|
+
},
|
|
2014
|
+
},
|
|
2015
|
+
elementProps,
|
|
2016
|
+
),
|
|
2017
|
+
)
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
function createJsxFactory() {
|
|
2023
|
+
const cache = new Map()
|
|
2024
|
+
|
|
2025
|
+
return new Proxy(createStyled, {
|
|
2026
|
+
apply(_, __, args) {
|
|
2027
|
+
return createStyled(...args)
|
|
2028
|
+
},
|
|
2029
|
+
get(_, el) {
|
|
2030
|
+
if (!cache.has(el)) {
|
|
2031
|
+
cache.set(el, createStyled(el))
|
|
2032
|
+
}
|
|
2033
|
+
return cache.get(el)
|
|
2034
|
+
},
|
|
2035
|
+
})
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
export const ${factoryName} = createJsxFactory()
|
|
2039
|
+
`
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
// src/artifacts/solid-jsx/types.string-literal.ts
|
|
2044
|
+
import { outdent as outdent31 } from "outdent";
|
|
2045
|
+
function generateSolidJsxStringLiteralTypes(ctx) {
|
|
2046
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2047
|
+
return {
|
|
2048
|
+
jsxFactory: outdent31`
|
|
2049
|
+
import type { ${upperName} } from '../types/jsx'
|
|
2050
|
+
export declare const ${factoryName}: ${upperName}
|
|
2051
|
+
`,
|
|
2052
|
+
jsxType: outdent31`
|
|
2053
|
+
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
2054
|
+
|
|
2055
|
+
type Dict = Record<string, unknown>
|
|
2056
|
+
|
|
2057
|
+
type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
|
|
2058
|
+
|
|
2059
|
+
export type ${componentName}<T extends ElementType> = {
|
|
2060
|
+
(args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
|
|
2061
|
+
displayName?: string
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
interface JsxFactory {
|
|
2065
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2069
|
+
|
|
2070
|
+
export type Styled = JsxFactory & JsxElements
|
|
2071
|
+
|
|
2072
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2073
|
+
`
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
|
|
1653
2077
|
// src/artifacts/vue-jsx/jsx.ts
|
|
1654
|
-
import { outdent as
|
|
2078
|
+
import { outdent as outdent32 } from "outdent";
|
|
1655
2079
|
function generateVueJsxFactory(ctx) {
|
|
1656
2080
|
const { factoryName } = ctx.jsx;
|
|
1657
2081
|
return {
|
|
1658
|
-
js:
|
|
2082
|
+
js: outdent32`
|
|
1659
2083
|
import { defineComponent, h, computed } from 'vue'
|
|
1660
2084
|
${ctx.file.import("css, cx, cva, assignCss", "../css/index")}
|
|
1661
2085
|
${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
|
|
@@ -1728,8 +2152,62 @@ function generateVueJsxFactory(ctx) {
|
|
|
1728
2152
|
};
|
|
1729
2153
|
}
|
|
1730
2154
|
|
|
2155
|
+
// src/artifacts/vue-jsx/jsx.string-literal.ts
|
|
2156
|
+
import { outdent as outdent33 } from "outdent";
|
|
2157
|
+
function generateVueJsxStringLiteralFactory(ctx) {
|
|
2158
|
+
const { factoryName } = ctx.jsx;
|
|
2159
|
+
return {
|
|
2160
|
+
js: outdent33`
|
|
2161
|
+
import { defineComponent, h, computed } from 'vue'
|
|
2162
|
+
${ctx.file.import("css, cx", "../css/index")}
|
|
2163
|
+
|
|
2164
|
+
function createStyled(Dynamic) {
|
|
2165
|
+
function styledFn(template) {
|
|
2166
|
+
const baseClassName = css(template)
|
|
2167
|
+
return defineComponent({
|
|
2168
|
+
name: \`${factoryName}.\${Dynamic}\`,
|
|
2169
|
+
inheritAttrs: false,
|
|
2170
|
+
props: { as: { type: [String, Object], default: Dynamic } },
|
|
2171
|
+
setup(props, { slots, attrs }) {
|
|
2172
|
+
const classes = computed(() => cx(baseClassName, elementProps.className))
|
|
2173
|
+
return () => {
|
|
2174
|
+
return h(
|
|
2175
|
+
props.as,
|
|
2176
|
+
{
|
|
2177
|
+
class: classes.value,
|
|
2178
|
+
...elementProps,
|
|
2179
|
+
},
|
|
2180
|
+
slots.default && slots.default(),
|
|
2181
|
+
)
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
})
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
function createJsxFactory() {
|
|
2189
|
+
const cache = new Map()
|
|
2190
|
+
|
|
2191
|
+
return new Proxy(createStyled, {
|
|
2192
|
+
apply(_, __, args) {
|
|
2193
|
+
return createStyled(...args)
|
|
2194
|
+
},
|
|
2195
|
+
get(_, el) {
|
|
2196
|
+
if (!cache.has(el)) {
|
|
2197
|
+
cache.set(el, createStyled(el))
|
|
2198
|
+
}
|
|
2199
|
+
return cache.get(el)
|
|
2200
|
+
},
|
|
2201
|
+
})
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
export const ${factoryName} = createJsxFactory()
|
|
2205
|
+
`
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
|
|
1731
2209
|
// src/artifacts/vue-jsx/pattern.ts
|
|
1732
|
-
import { outdent as
|
|
2210
|
+
import { outdent as outdent34 } from "outdent";
|
|
1733
2211
|
function generateVueJsxPattern(ctx) {
|
|
1734
2212
|
const { typeName, factoryName } = ctx.jsx;
|
|
1735
2213
|
return ctx.patterns.details.map((pattern) => {
|
|
@@ -1738,7 +2216,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
1738
2216
|
const propList = props.map((v) => JSON.stringify(v)).join(", ");
|
|
1739
2217
|
return {
|
|
1740
2218
|
name: dashName,
|
|
1741
|
-
js:
|
|
2219
|
+
js: outdent34`
|
|
1742
2220
|
import { defineComponent, h, computed } from 'vue'
|
|
1743
2221
|
${ctx.file.import(factoryName, "./factory")}
|
|
1744
2222
|
${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
|
|
@@ -1756,7 +2234,7 @@ function generateVueJsxPattern(ctx) {
|
|
|
1756
2234
|
}
|
|
1757
2235
|
})
|
|
1758
2236
|
`,
|
|
1759
|
-
dts:
|
|
2237
|
+
dts: outdent34`
|
|
1760
2238
|
import { FunctionalComponent } from 'vue'
|
|
1761
2239
|
import { ${upperName}Properties } from '../patterns/${dashName}'
|
|
1762
2240
|
import { ${typeName} } from '../types/jsx'
|
|
@@ -1771,15 +2249,15 @@ function generateVueJsxPattern(ctx) {
|
|
|
1771
2249
|
}
|
|
1772
2250
|
|
|
1773
2251
|
// src/artifacts/vue-jsx/types.ts
|
|
1774
|
-
import { outdent as
|
|
2252
|
+
import { outdent as outdent35 } from "outdent";
|
|
1775
2253
|
function generateVueJsxTypes(ctx) {
|
|
1776
2254
|
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
1777
2255
|
return {
|
|
1778
|
-
jsxFactory:
|
|
2256
|
+
jsxFactory: outdent35`
|
|
1779
2257
|
import { ${upperName} } from '../types/jsx'
|
|
1780
2258
|
export declare const ${factoryName}: ${upperName}
|
|
1781
2259
|
`,
|
|
1782
|
-
jsxType:
|
|
2260
|
+
jsxType: outdent35`
|
|
1783
2261
|
import type { Component, FunctionalComponent } from 'vue'
|
|
1784
2262
|
import type { Assign, JsxStyleProps, JsxHTMLProps } from './system-types'
|
|
1785
2263
|
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
@@ -1935,6 +2413,161 @@ type IntrinsicElement =
|
|
|
1935
2413
|
};
|
|
1936
2414
|
}
|
|
1937
2415
|
|
|
2416
|
+
// src/artifacts/vue-jsx/types.string-literal.ts
|
|
2417
|
+
import { outdent as outdent36 } from "outdent";
|
|
2418
|
+
function generateVueJsxStringLiteralTypes(ctx) {
|
|
2419
|
+
const { factoryName, componentName, upperName, typeName } = ctx.jsx;
|
|
2420
|
+
return {
|
|
2421
|
+
jsxFactory: outdent36`
|
|
2422
|
+
import { ${upperName} } from '../types/jsx'
|
|
2423
|
+
export declare const ${factoryName}: ${upperName}
|
|
2424
|
+
`,
|
|
2425
|
+
jsxType: outdent36`
|
|
2426
|
+
import type { Component, FunctionalComponent } from 'vue'
|
|
2427
|
+
|
|
2428
|
+
type IntrinsicElement =
|
|
2429
|
+
| 'a'
|
|
2430
|
+
| 'abbr'
|
|
2431
|
+
| 'address'
|
|
2432
|
+
| 'area'
|
|
2433
|
+
| 'article'
|
|
2434
|
+
| 'aside'
|
|
2435
|
+
| 'audio'
|
|
2436
|
+
| 'b'
|
|
2437
|
+
| 'base'
|
|
2438
|
+
| 'bdi'
|
|
2439
|
+
| 'bdo'
|
|
2440
|
+
| 'blockquote'
|
|
2441
|
+
| 'body'
|
|
2442
|
+
| 'br'
|
|
2443
|
+
| 'button'
|
|
2444
|
+
| 'canvas'
|
|
2445
|
+
| 'caption'
|
|
2446
|
+
| 'cite'
|
|
2447
|
+
| 'code'
|
|
2448
|
+
| 'col'
|
|
2449
|
+
| 'colgroup'
|
|
2450
|
+
| 'data'
|
|
2451
|
+
| 'datalist'
|
|
2452
|
+
| 'dd'
|
|
2453
|
+
| 'del'
|
|
2454
|
+
| 'details'
|
|
2455
|
+
| 'dfn'
|
|
2456
|
+
| 'dialog'
|
|
2457
|
+
| 'div'
|
|
2458
|
+
| 'dl'
|
|
2459
|
+
| 'dt'
|
|
2460
|
+
| 'em'
|
|
2461
|
+
| 'embed'
|
|
2462
|
+
| 'fieldset'
|
|
2463
|
+
| 'figcaption'
|
|
2464
|
+
| 'figure'
|
|
2465
|
+
| 'footer'
|
|
2466
|
+
| 'form'
|
|
2467
|
+
| 'h1'
|
|
2468
|
+
| 'h2'
|
|
2469
|
+
| 'h3'
|
|
2470
|
+
| 'h4'
|
|
2471
|
+
| 'h5'
|
|
2472
|
+
| 'h6'
|
|
2473
|
+
| 'head'
|
|
2474
|
+
| 'header'
|
|
2475
|
+
| 'hgroup'
|
|
2476
|
+
| 'hr'
|
|
2477
|
+
| 'html'
|
|
2478
|
+
| 'i'
|
|
2479
|
+
| 'iframe'
|
|
2480
|
+
| 'img'
|
|
2481
|
+
| 'input'
|
|
2482
|
+
| 'ins'
|
|
2483
|
+
| 'kbd'
|
|
2484
|
+
| 'label'
|
|
2485
|
+
| 'legend'
|
|
2486
|
+
| 'li'
|
|
2487
|
+
| 'link'
|
|
2488
|
+
| 'main'
|
|
2489
|
+
| 'map'
|
|
2490
|
+
| 'mark'
|
|
2491
|
+
| 'math'
|
|
2492
|
+
| 'menu'
|
|
2493
|
+
| 'menuitem'
|
|
2494
|
+
| 'meta'
|
|
2495
|
+
| 'meter'
|
|
2496
|
+
| 'nav'
|
|
2497
|
+
| 'noscript'
|
|
2498
|
+
| 'object'
|
|
2499
|
+
| 'ol'
|
|
2500
|
+
| 'optgroup'
|
|
2501
|
+
| 'option'
|
|
2502
|
+
| 'output'
|
|
2503
|
+
| 'p'
|
|
2504
|
+
| 'param'
|
|
2505
|
+
| 'picture'
|
|
2506
|
+
| 'pre'
|
|
2507
|
+
| 'progress'
|
|
2508
|
+
| 'q'
|
|
2509
|
+
| 'rb'
|
|
2510
|
+
| 'rp'
|
|
2511
|
+
| 'rt'
|
|
2512
|
+
| 'rtc'
|
|
2513
|
+
| 'ruby'
|
|
2514
|
+
| 's'
|
|
2515
|
+
| 'samp'
|
|
2516
|
+
| 'script'
|
|
2517
|
+
| 'section'
|
|
2518
|
+
| 'select'
|
|
2519
|
+
| 'slot'
|
|
2520
|
+
| 'small'
|
|
2521
|
+
| 'source'
|
|
2522
|
+
| 'span'
|
|
2523
|
+
| 'strong'
|
|
2524
|
+
| 'style'
|
|
2525
|
+
| 'sub'
|
|
2526
|
+
| 'summary'
|
|
2527
|
+
| 'sup'
|
|
2528
|
+
| 'svg'
|
|
2529
|
+
| 'table'
|
|
2530
|
+
| 'tbody'
|
|
2531
|
+
| 'td'
|
|
2532
|
+
| 'template'
|
|
2533
|
+
| 'textarea'
|
|
2534
|
+
| 'tfoot'
|
|
2535
|
+
| 'th'
|
|
2536
|
+
| 'thead'
|
|
2537
|
+
| 'time'
|
|
2538
|
+
| 'title'
|
|
2539
|
+
| 'tr'
|
|
2540
|
+
| 'track'
|
|
2541
|
+
| 'u'
|
|
2542
|
+
| 'ul'
|
|
2543
|
+
| 'var'
|
|
2544
|
+
| 'video'
|
|
2545
|
+
| 'wbr'
|
|
2546
|
+
|
|
2547
|
+
type ElementType = IntrinsicElement | Component
|
|
2548
|
+
|
|
2549
|
+
type ComponentProps<T extends ElementType> = T extends keyof JSX.IntrinsicElements
|
|
2550
|
+
? JSX.IntrinsicElements[T]
|
|
2551
|
+
: T extends Component<infer Props>
|
|
2552
|
+
? Props
|
|
2553
|
+
: never
|
|
2554
|
+
|
|
2555
|
+
type ${componentName}<T extends ElementType> = FunctionalComponent<ComponentProps<T>>
|
|
2556
|
+
>
|
|
2557
|
+
|
|
2558
|
+
interface JsxFactory {
|
|
2559
|
+
<T extends ElementType>(component: T): ${componentName}<T>
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
type JsxElements = { [K in keyof JSX.IntrinsicElements]: ${componentName}<K> }
|
|
2563
|
+
|
|
2564
|
+
export type ${upperName} = JsxFactory & JsxElements
|
|
2565
|
+
|
|
2566
|
+
export type ${typeName}<T extends ElementType> = ComponentProps<T>
|
|
2567
|
+
`
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
|
|
1938
2571
|
// src/artifacts/jsx.ts
|
|
1939
2572
|
var typesMap = {
|
|
1940
2573
|
react: generateReactJsxTypes,
|
|
@@ -1943,10 +2576,18 @@ var typesMap = {
|
|
|
1943
2576
|
vue: generateVueJsxTypes,
|
|
1944
2577
|
qwik: generateQwikJsxTypes
|
|
1945
2578
|
};
|
|
2579
|
+
var typesStringLiteralMap = {
|
|
2580
|
+
react: generateSolidJsxStringLiteralTypes,
|
|
2581
|
+
solid: generateReactJsxStringLiteralTypes,
|
|
2582
|
+
qwik: generateQwikJsxStringLiteralTypes,
|
|
2583
|
+
preact: generatePreactJsxStringLiteralTypes,
|
|
2584
|
+
vue: generateVueJsxStringLiteralTypes
|
|
2585
|
+
};
|
|
1946
2586
|
function generateJsxTypes(ctx) {
|
|
1947
2587
|
if (!ctx.jsx.framework)
|
|
1948
2588
|
return;
|
|
1949
|
-
|
|
2589
|
+
const type = ctx.isTemplateLiteralSyntax ? typesStringLiteralMap[ctx.jsx.framework] : typesMap[ctx.jsx.framework];
|
|
2590
|
+
return type?.(ctx);
|
|
1950
2591
|
}
|
|
1951
2592
|
var factoryMap = {
|
|
1952
2593
|
react: generateReactJsxFactory,
|
|
@@ -1955,10 +2596,18 @@ var factoryMap = {
|
|
|
1955
2596
|
vue: generateVueJsxFactory,
|
|
1956
2597
|
qwik: generateQwikJsxFactory
|
|
1957
2598
|
};
|
|
2599
|
+
var factoryStringLiteralMap = {
|
|
2600
|
+
react: generateReactJsxStringLiteralFactory,
|
|
2601
|
+
solid: generateSolidJsxStringLiteralFactory,
|
|
2602
|
+
qwik: generateQwikJsxStringLiteralFactory,
|
|
2603
|
+
preact: generatePreactJsxStringLiteralFactory,
|
|
2604
|
+
vue: generateVueJsxStringLiteralFactory
|
|
2605
|
+
};
|
|
1958
2606
|
function generateJsxFactory(ctx) {
|
|
1959
2607
|
if (!ctx.jsx.framework)
|
|
1960
2608
|
return;
|
|
1961
|
-
|
|
2609
|
+
const factory = ctx.isTemplateLiteralSyntax ? factoryStringLiteralMap[ctx.jsx.framework] : factoryMap[ctx.jsx.framework];
|
|
2610
|
+
return factory?.(ctx);
|
|
1962
2611
|
}
|
|
1963
2612
|
var patternMap = {
|
|
1964
2613
|
react: generateReactJsxPattern,
|
|
@@ -1968,6 +2617,8 @@ var patternMap = {
|
|
|
1968
2617
|
qwik: generateQwikJsxPattern
|
|
1969
2618
|
};
|
|
1970
2619
|
function generateJsxPatterns(ctx) {
|
|
2620
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2621
|
+
return [];
|
|
1971
2622
|
if (ctx.patterns.isEmpty() && !ctx.jsx.framework)
|
|
1972
2623
|
return [];
|
|
1973
2624
|
return patternMap[ctx.jsx.framework](ctx);
|
|
@@ -2035,7 +2686,7 @@ var recipe_d_ts_default = {
|
|
|
2035
2686
|
|
|
2036
2687
|
// src/artifacts/generated/pattern.d.ts.json
|
|
2037
2688
|
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
|
|
2689
|
+
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
2690
|
};
|
|
2040
2691
|
|
|
2041
2692
|
// src/artifacts/generated/parts.d.ts.json
|
|
@@ -2062,9 +2713,9 @@ function getGeneratedTypes() {
|
|
|
2062
2713
|
}
|
|
2063
2714
|
|
|
2064
2715
|
// src/artifacts/types/main.ts
|
|
2065
|
-
import { outdent as
|
|
2716
|
+
import { outdent as outdent37 } from "outdent";
|
|
2066
2717
|
var generateTypesEntry = () => ({
|
|
2067
|
-
global:
|
|
2718
|
+
global: outdent37`
|
|
2068
2719
|
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2069
2720
|
import type { Parts } from './parts'
|
|
2070
2721
|
import type { PatternConfig } from './pattern'
|
|
@@ -2081,19 +2732,19 @@ var generateTypesEntry = () => ({
|
|
|
2081
2732
|
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>;
|
|
2082
2733
|
}
|
|
2083
2734
|
`,
|
|
2084
|
-
index:
|
|
2735
|
+
index: outdent37`
|
|
2085
2736
|
import './global'
|
|
2086
2737
|
export type { ConditionalValue } from './conditions'
|
|
2087
2738
|
export type { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
2088
2739
|
|
|
2089
2740
|
`,
|
|
2090
|
-
helpers:
|
|
2741
|
+
helpers: outdent37`
|
|
2091
2742
|
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
2092
2743
|
`
|
|
2093
2744
|
});
|
|
2094
2745
|
|
|
2095
2746
|
// src/artifacts/types/prop-types.ts
|
|
2096
|
-
import { outdent as
|
|
2747
|
+
import { outdent as outdent38 } from "outdent";
|
|
2097
2748
|
function generatePropTypes(ctx) {
|
|
2098
2749
|
const {
|
|
2099
2750
|
config: { strictTokens },
|
|
@@ -2101,7 +2752,7 @@ function generatePropTypes(ctx) {
|
|
|
2101
2752
|
} = ctx;
|
|
2102
2753
|
const strictText = `${strictTokens ? "" : " | CssValue<T>"}`;
|
|
2103
2754
|
const result = [
|
|
2104
|
-
|
|
2755
|
+
outdent38`
|
|
2105
2756
|
import type { ConditionalValue } from './conditions';
|
|
2106
2757
|
import type { CssProperties } from './system-types'
|
|
2107
2758
|
import type { Tokens } from '../tokens'
|
|
@@ -2124,7 +2775,7 @@ function generatePropTypes(ctx) {
|
|
|
2124
2775
|
result.push(` ${key}: Shorthand<${JSON.stringify(value)}>;`);
|
|
2125
2776
|
});
|
|
2126
2777
|
result.push("}");
|
|
2127
|
-
return
|
|
2778
|
+
return outdent38`
|
|
2128
2779
|
${result.join("\n")}
|
|
2129
2780
|
|
|
2130
2781
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
@@ -2137,10 +2788,10 @@ function generatePropTypes(ctx) {
|
|
|
2137
2788
|
|
|
2138
2789
|
// src/artifacts/types/style-props.ts
|
|
2139
2790
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
2140
|
-
import
|
|
2791
|
+
import outdent39 from "outdent";
|
|
2141
2792
|
function generateStyleProps(ctx) {
|
|
2142
2793
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
2143
|
-
return
|
|
2794
|
+
return outdent39`
|
|
2144
2795
|
import type { ConditionalValue } from './conditions'
|
|
2145
2796
|
import type { PropertyValue } from './prop-type'
|
|
2146
2797
|
import type { Token } from '../tokens'
|
|
@@ -2157,7 +2808,7 @@ function generateStyleProps(ctx) {
|
|
|
2157
2808
|
|
|
2158
2809
|
// src/artifacts/types/token-types.ts
|
|
2159
2810
|
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
2160
|
-
import { outdent as
|
|
2811
|
+
import { outdent as outdent40 } from "outdent";
|
|
2161
2812
|
import pluralize from "pluralize";
|
|
2162
2813
|
var categories = [
|
|
2163
2814
|
"zIndex",
|
|
@@ -2202,7 +2853,7 @@ function generateTokenTypes(ctx) {
|
|
|
2202
2853
|
result.add("} & { [token: string]: never }");
|
|
2203
2854
|
set.add(Array.from(result).join("\n"));
|
|
2204
2855
|
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
2205
|
-
return
|
|
2856
|
+
return outdent40.string(Array.from(set).join("\n\n"));
|
|
2206
2857
|
}
|
|
2207
2858
|
|
|
2208
2859
|
// src/artifacts/index.ts
|
|
@@ -2260,8 +2911,8 @@ function setupTypes(ctx) {
|
|
|
2260
2911
|
};
|
|
2261
2912
|
}
|
|
2262
2913
|
function setupCss(ctx) {
|
|
2263
|
-
const code = generateCssFn(ctx);
|
|
2264
|
-
const conditions = generateConditions(ctx);
|
|
2914
|
+
const code = ctx.isTemplateLiteralSyntax ? generateStringLiteralCssFn(ctx) : generateCssFn(ctx);
|
|
2915
|
+
const conditions = ctx.isTemplateLiteralSyntax ? generateStringLiteralConditions(ctx) : generateConditions(ctx);
|
|
2265
2916
|
return {
|
|
2266
2917
|
dir: ctx.paths.css,
|
|
2267
2918
|
files: [
|
|
@@ -2272,6 +2923,8 @@ function setupCss(ctx) {
|
|
|
2272
2923
|
};
|
|
2273
2924
|
}
|
|
2274
2925
|
function setupCva(ctx) {
|
|
2926
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2927
|
+
return;
|
|
2275
2928
|
const code = generateCvaFn(ctx);
|
|
2276
2929
|
return {
|
|
2277
2930
|
dir: ctx.paths.css,
|
|
@@ -2297,8 +2950,8 @@ function setupRecipes(ctx) {
|
|
|
2297
2950
|
return;
|
|
2298
2951
|
const indexFiles = files.filter((file) => !file.name.includes("create-recipe"));
|
|
2299
2952
|
const index = {
|
|
2300
|
-
js:
|
|
2301
|
-
dts:
|
|
2953
|
+
js: outdent41.string(indexFiles.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2954
|
+
dts: outdent41.string(indexFiles.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2302
2955
|
};
|
|
2303
2956
|
return {
|
|
2304
2957
|
dir: ctx.paths.recipe,
|
|
@@ -2311,12 +2964,14 @@ function setupRecipes(ctx) {
|
|
|
2311
2964
|
};
|
|
2312
2965
|
}
|
|
2313
2966
|
function setupPatterns(ctx) {
|
|
2967
|
+
if (ctx.isTemplateLiteralSyntax)
|
|
2968
|
+
return;
|
|
2314
2969
|
const files = generatePattern(ctx);
|
|
2315
2970
|
if (!files)
|
|
2316
2971
|
return;
|
|
2317
2972
|
const index = {
|
|
2318
|
-
js:
|
|
2319
|
-
dts:
|
|
2973
|
+
js: outdent41.string(files.map((file) => ctx.file.export(`./${file.name}`)).join("\n")),
|
|
2974
|
+
dts: outdent41.string(files.map((file) => `export * from './${file.name}'`).join("\n"))
|
|
2320
2975
|
};
|
|
2321
2976
|
return {
|
|
2322
2977
|
dir: ctx.paths.pattern,
|
|
@@ -2336,13 +2991,13 @@ function setupJsx(ctx) {
|
|
|
2336
2991
|
const factory = generateJsxFactory(ctx);
|
|
2337
2992
|
const patterns = generateJsxPatterns(ctx);
|
|
2338
2993
|
const index = {
|
|
2339
|
-
js:
|
|
2994
|
+
js: outdent41`
|
|
2340
2995
|
${ctx.file.export("./factory")}
|
|
2341
|
-
${
|
|
2996
|
+
${outdent41.string(patterns.map((file) => ctx.file.export(`./${file.name}`)).join("\n"))}
|
|
2342
2997
|
`,
|
|
2343
|
-
dts:
|
|
2998
|
+
dts: outdent41`
|
|
2344
2999
|
export * from './factory'
|
|
2345
|
-
${
|
|
3000
|
+
${outdent41.string(patterns.map((file) => `export * from './${file.name}'`).join("\n"))}
|
|
2346
3001
|
export type { ${ctx.jsx.typeName} } from '../types/jsx'
|
|
2347
3002
|
`
|
|
2348
3003
|
};
|
|
@@ -2351,7 +3006,7 @@ function setupJsx(ctx) {
|
|
|
2351
3006
|
files: [
|
|
2352
3007
|
...patterns.map((file) => ({ file: ctx.file.ext(file.name), code: file.js })),
|
|
2353
3008
|
...patterns.map((file) => ({ file: `${file.name}.d.ts`, code: file.dts })),
|
|
2354
|
-
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp
|
|
3009
|
+
{ file: ctx.file.ext("is-valid-prop"), code: isValidProp?.js },
|
|
2355
3010
|
{ file: "factory.d.ts", code: types.jsxFactory },
|
|
2356
3011
|
{ file: ctx.file.ext("factory"), code: factory?.js },
|
|
2357
3012
|
{ file: "index.d.ts", code: index.dts },
|
|
@@ -2361,15 +3016,15 @@ function setupJsx(ctx) {
|
|
|
2361
3016
|
}
|
|
2362
3017
|
function setupCssIndex(ctx) {
|
|
2363
3018
|
const index = {
|
|
2364
|
-
js:
|
|
3019
|
+
js: outdent41`
|
|
2365
3020
|
${ctx.file.export("./css")}
|
|
2366
3021
|
${ctx.file.export("./cx")}
|
|
2367
|
-
${ctx.file.export("./cva")}
|
|
3022
|
+
${ctx.isTemplateLiteralSyntax ? "" : ctx.file.export("./cva")}
|
|
2368
3023
|
`,
|
|
2369
|
-
dts:
|
|
3024
|
+
dts: outdent41`
|
|
2370
3025
|
export * from './css'
|
|
2371
3026
|
export * from './cx'
|
|
2372
|
-
export * from './cva'
|
|
3027
|
+
${ctx.isTemplateLiteralSyntax ? "" : `export * from './cva'`}
|
|
2373
3028
|
`
|
|
2374
3029
|
};
|
|
2375
3030
|
return {
|
|
@@ -2557,6 +3212,7 @@ var helpers = {
|
|
|
2557
3212
|
var getBaseEngine = (conf) => {
|
|
2558
3213
|
const { config } = conf;
|
|
2559
3214
|
const theme = config.theme ?? {};
|
|
3215
|
+
const isTemplateLiteralSyntax = config.syntax === "template-literal";
|
|
2560
3216
|
const hash = {
|
|
2561
3217
|
tokens: isBool(config.hash) ? config.hash : config.hash?.cssVar,
|
|
2562
3218
|
className: isBool(config.hash) ? config.hash : config.hash?.className
|
|
@@ -2575,12 +3231,12 @@ var getBaseEngine = (conf) => {
|
|
|
2575
3231
|
const utility = new Utility({
|
|
2576
3232
|
prefix: prefix.className,
|
|
2577
3233
|
tokens,
|
|
2578
|
-
config: config.utilities,
|
|
3234
|
+
config: isTemplateLiteralSyntax ? {} : config.utilities,
|
|
2579
3235
|
separator: config.separator,
|
|
2580
3236
|
shorthands: config.shorthands
|
|
2581
3237
|
});
|
|
2582
3238
|
const conditions = new Conditions({
|
|
2583
|
-
conditions: config.conditions,
|
|
3239
|
+
conditions: isTemplateLiteralSyntax ? {} : config.conditions,
|
|
2584
3240
|
breakpoints: config.theme?.breakpoints
|
|
2585
3241
|
});
|
|
2586
3242
|
const { textStyles, layerStyles } = theme;
|
|
@@ -2618,6 +3274,7 @@ var getBaseEngine = (conf) => {
|
|
|
2618
3274
|
};
|
|
2619
3275
|
return {
|
|
2620
3276
|
...conf,
|
|
3277
|
+
isTemplateLiteralSyntax,
|
|
2621
3278
|
studio,
|
|
2622
3279
|
hash,
|
|
2623
3280
|
prefix,
|
|
@@ -2699,7 +3356,7 @@ var getPatternEngine = (config) => {
|
|
|
2699
3356
|
return Object.entries(patterns).map(([name, pattern]) => ({
|
|
2700
3357
|
type: "pattern",
|
|
2701
3358
|
name: pattern.jsx ?? capitalize3(name),
|
|
2702
|
-
props: Object.keys(pattern
|
|
3359
|
+
props: Object.keys(pattern?.properties ?? {}),
|
|
2703
3360
|
baseName: name
|
|
2704
3361
|
}));
|
|
2705
3362
|
}),
|
|
@@ -2739,6 +3396,7 @@ var defaults = (conf) => ({
|
|
|
2739
3396
|
jsxFactory: "styled",
|
|
2740
3397
|
outExtension: "mjs",
|
|
2741
3398
|
shorthands: true,
|
|
3399
|
+
syntax: "object-literal",
|
|
2742
3400
|
...conf.config
|
|
2743
3401
|
}
|
|
2744
3402
|
});
|