@bamboocss/generator 1.15.0 → 1.16.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context, Recipes, expandNestedCss, extractParentSelectors, extractTrailingPseudos, pruneKeyframes, pruneTokenVars, stringify } from "@bamboocss/core";
2
2
  import { logger } from "@bamboocss/logger";
3
- import { BambooError, capitalize, compact, cssVarRefs, dashCase, isBoolean, isObject, mapEntries, unionType, uniq, walkObject } from "@bamboocss/shared";
3
+ import { BambooError, capitalize, compact, cssVarRefs, dashCase, groupClassName, isBoolean, isObject, mapEntries, unionType, walkObject } from "@bamboocss/shared";
4
4
  import { match } from "ts-pattern";
5
5
  import outdent$1, { outdent } from "outdent";
6
6
  import { stringify as stringify$1 } from "javascript-stringify";
@@ -81,36 +81,6 @@ function generateConditions(ctx) {
81
81
  };
82
82
  }
83
83
  //#endregion
84
- //#region src/artifacts/js/conditions.string-literal.ts
85
- function generateStringLiteralConditions(ctx) {
86
- return {
87
- js: outdent$1`
88
- ${ctx.file.import("withoutSpace", "../helpers")}
89
-
90
- export const isCondition = (val) => condRegex.test(val)
91
-
92
- const condRegex = /^@|&|&$/
93
- const selectorRegex = /&|@/
94
-
95
- export const finalizeConditions = (paths) => {
96
- return paths.map((path) => (selectorRegex.test(path) ? \`[\${withoutSpace(path.trim())}]\` : path))
97
- }
98
-
99
- export function sortConditions(paths){
100
- return paths.sort((a, b) => {
101
- const aa = isCondition(a)
102
- const bb = isCondition(b)
103
- if (aa && !bb) return 1
104
- if (!aa && bb) return -1
105
- return 0
106
- })
107
- }
108
- `,
109
- dts: outdent$1`
110
- `
111
- };
112
- }
113
- //#endregion
114
84
  //#region src/artifacts/js/css-fn.ts
115
85
  function generateCssFn(ctx) {
116
86
  const { utility, hash, prefix, conditions } = ctx;
@@ -180,7 +150,7 @@ function generateCssFn(ctx) {
180
150
  `,
181
151
  js: outdent`
182
152
  ${ctx.file.import("cloneStyles, createCss, createMergeCss, hypenateProperty, leafClass, memo, viewTransitionClassName, withoutSpace", "../helpers")}
183
- ${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
153
+ ${[ctx.file.import("sortConditions, finalizeConditions", "./conditions"), ctx.config.cssMode === "grouped" ? ctx.file.import("groups", "./groups") : ""].filter(Boolean).join("\n")}
184
154
 
185
155
  const utilities = "${utility.entries().map(([prop, className]) => {
186
156
  const shorthandList = getPropShorthands(prop);
@@ -210,7 +180,7 @@ function generateCssFn(ctx) {
210
180
  `}
211
181
 
212
182
  const context = {
213
- ${[hash.className && "hash: true,", ctx.config.cssMode === "grouped" && "grouped: true,"].filter(Boolean).join("\n ")}
183
+ ${[hash.className && "hash: true,", ctx.config.cssMode === "grouped" && "grouped: true,\n knownGroups: groups,"].filter(Boolean).join("\n ")}
214
184
  conditions: {
215
185
  shift: sortConditions,
216
186
  finalize: finalizeConditions,
@@ -235,6 +205,7 @@ function generateCssFn(ctx) {
235
205
  // condition object would otherwise poison it for everyone after them.
236
206
  css.raw = (...styles) => cloneStyles(mergeCss(...styles))
237
207
 
208
+
238
209
  // Emitted for the source transform, which rewrites a single dynamic style leaf into a
239
210
  // call to this rather than leaving a \`css()\` behind. \`prefix\` is the class up to the
240
211
  // value, resolved at build time; \`prop\` is only used for the shapes \`leafClass\`
@@ -259,77 +230,20 @@ function generateCssFn(ctx) {
259
230
  };
260
231
  }
261
232
  //#endregion
262
- //#region src/artifacts/js/css-fn.string-literal.ts
263
- function generateStringLiteralCssFn(ctx) {
264
- const { utility, hash, prefix } = ctx;
265
- const { separator } = utility;
266
- return {
267
- dts: outdent`
268
- ${ctx.file.importType("SystemStyleObject", "../types/index")}
269
-
270
- type Styles =
271
- | { raw: readonly string[] | ArrayLike<string> }
272
- | SystemStyleObject
273
- | boolean
274
- | null
275
- | undefined
276
-
277
- interface CssRawFunction {
278
- (...styles: Styles[]): SystemStyleObject
279
- }
280
-
281
- interface CssFunction {
282
- (...styles: Styles[]): string
283
-
284
- raw: CssRawFunction
285
- }
286
-
287
- export declare const css: CssFunction;
288
- `,
289
- js: outdent`
290
- ${ctx.file.import("astish, cloneStyles, createCss, isObject, mergeProps, withoutSpace", "../helpers")}
291
- ${ctx.file.import("finalizeConditions, sortConditions", "./conditions")}
292
-
293
- function transform(prop, value) {
294
- const className = \`$\{prop}${separator}$\{withoutSpace(value)}\`
295
- return { className }
296
- }
297
-
298
- const context = {
299
- hash: ${hash.className ? "true" : "false"},
300
- conditions: {
301
- shift: sortConditions,
302
- finalize: finalizeConditions,
303
- breakpoints: { keys: [] },
304
- },
305
- utility: {
306
- prefix: ${prefix.className ? JSON.stringify(prefix.className) : void 0},
307
- transform,
308
- hasShorthand: false,
309
- toHash: ${utility.toHash},
310
- resolveShorthand(prop) {
311
- return prop
312
- },
313
- }
314
- }
315
-
316
- const cssFn = createCss(context)
317
-
318
- const fn = (style) => (isObject(style) ? style : astish(style[0]))
319
- export const css = (...styles) => cssFn(mergeProps(...styles.filter(Boolean).map(fn)))
320
- // Same independence guarantee as the object-syntax css.raw(), so the public
321
- // API behaves identically across both syntaxes.
322
- css.raw = (...styles) => cloneStyles(mergeProps(...styles.filter(Boolean).map(fn)))
323
- `
324
- };
325
- }
326
- //#endregion
327
233
  //#region src/artifacts/js/cva.ts
328
234
  function generateCvaFn(ctx) {
235
+ const { utility, hash, prefix } = ctx;
236
+ const withPrefix = prefix.className ? `(className) => className ? ${JSON.stringify(prefix.className)} + '-' + className : ${JSON.stringify(prefix.className)}` : `(className) => className`;
329
237
  return {
330
238
  js: outdent`
331
- ${ctx.file.import("cloneStyles, compact, mergeProps, memo, splitProps, uniq", "../helpers")}
332
- ${ctx.file.import("css, mergeCss", "./css")}
239
+ ${ctx.file.import("cloneStyles, compact, getRecipeClassNames, getRecipeIdentity, mergeProps, memo, splitProps, toHash, uniq", "../helpers")}
240
+ ${ctx.file.import("mergeCss", "./css")}
241
+
242
+ // What \`createCss\` does to a class name, for the recipe path: prefix it, and hash it
243
+ // when \`hash.className\` is set. The build applies the same two steps to the rules it
244
+ // emits — see \`checkNamingAgreement\`, which compares the results.
245
+ const withPrefix = ${withPrefix}
246
+ const formatRecipeClass = ${hash.className ? `(className) => withPrefix((${utility.toHash})([className], toHash))` : `withPrefix`}
333
247
 
334
248
  const defaults = (conf) => ({
335
249
  base: {},
@@ -343,6 +257,11 @@ function generateCvaFn(ctx) {
343
257
  const { base, variants, defaultVariants, compoundVariants } = defaults(config)
344
258
  const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
345
259
 
260
+ // Derived from the config, because the build derives it from the same config while
261
+ // emitting the stylesheet and the two never meet. \`className\` when the author set
262
+ // one, a hash of the styles otherwise.
263
+ const name = getRecipeIdentity(config)
264
+
346
265
  function resolve(props = {}) {
347
266
  const computedVariants = getVariantProps(props)
348
267
  let variantCss = { ...base }
@@ -351,6 +270,13 @@ function generateCvaFn(ctx) {
351
270
  variantCss = mergeCss(variantCss, variants[key][value])
352
271
  }
353
272
  }
273
+ // A recipe with no compound variants has nothing left to merge, and the merge is
274
+ // not free just because its second operand is empty: \`mergeCss\` is memoized on its
275
+ // arguments, so the call hashes the whole accumulated style object before finding
276
+ // there is nothing to do. Most recipes declare no compound variants at all, so
277
+ // this is the common shape rather than a special case.
278
+ if (compoundVariants.length === 0) return variantCss
279
+
354
280
  const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
355
281
  return mergeCss(variantCss, compoundVariantCss)
356
282
  }
@@ -375,10 +301,25 @@ function generateCvaFn(ctx) {
375
301
  //
376
302
  // \`raw\` still clones what it returns. The memoized object is shared, so handing it to a
377
303
  // caller that mutated it would poison every later call.
304
+ //
305
+ // A recipe whose variants are all boolean could index an array instead of hashing, and
306
+ // that was built and measured: +25% to +35% on \`raw()\`. It is not here because the
307
+ // trade is bad. Correctness needs the selection read from own enumerable keys only, and
308
+ // every variant to carry a boolean default so the merge order is pinned — and once that
309
+ // gate is honest, no \`cva\`/\`sva\` call site in this repo passes it, because real recipes
310
+ // mix a string variant in. The cost is unconditional: +289 B gzipped on that module for
311
+ // every consumer, qualifying or not.
378
312
  const resolveVariants = memo(resolve)
379
313
 
314
+ // The class names the build emitted rules for: the recipe's own class, plus one per
315
+ // selected variant. Not \`css(resolve(props))\` — that would name classes by property,
316
+ // and the stylesheet names this recipe's rules semantically, in the \`recipes\` layer.
317
+ //
318
+ // Compound variants are absent on purpose. Their rule selects on the variant classes
319
+ // already in this list — \`.btn--size_sm.btn--tone_a\` — so it applies without anything
320
+ // being added here, and adding a class for it would name a rule that does not exist.
380
321
  function cvaFn(props) {
381
- return css(resolve(props))
322
+ return getRecipeClassNames(name, variants, getVariantProps(props), '${utility.separator}', formatRecipeClass)
382
323
  }
383
324
 
384
325
  const variantKeys = Object.keys(variants)
@@ -437,36 +378,55 @@ function generateCvaFn(ctx) {
437
378
  }
438
379
  //#endregion
439
380
  //#region src/artifacts/js/cx.ts
440
- const dts = outdent$1`
381
+ /**
382
+ * `cx` joins class names. It does not resolve conflicts between them, in any build.
383
+ *
384
+ * It used to, when the class names happened to carry a property to compare — atomic mode
385
+ * with `hash.className` off. That made it a correctness tool in development and a plain
386
+ * join in a hashed production build, from the same source, with no error either way. An
387
+ * override that worked locally silently stopped working when it shipped.
388
+ *
389
+ * The two could not be reconciled by teaching the matcher to read hashed names.
390
+ * `cssMode: 'grouped'` names a *whole call* with one class — `toHash(['grouped', groupId])`
391
+ * — so there is no single property behind it to compare, whatever the naming scheme. As
392
+ * long as grouped exists, some builds can never merge, and a `cx` that merges in the rest
393
+ * is a behavioural difference keyed on a config flag.
394
+ *
395
+ * So precedence is decided where it can be decided the same way everywhere: by
396
+ * {@link https://bamboocss.com/docs/concepts/cascade-layers cascade layers}. A component
397
+ * whose styles a consumer will override belongs in `recipes` — write it with `cva`/`sva`,
398
+ * not bare `css()` — and the consumer's `css()` in `utilities` wins by layer, in every
399
+ * build. Two `css()` outputs joined with `cx` are in the same layer and resolve by source
400
+ * order; when you own both, merge the style objects with `css(a, b)` instead.
401
+ */
402
+ const declaration = outdent$1`
441
403
  type Argument = string | boolean | null | undefined | Argument[]
442
404
 
443
405
  /**
444
- * Join classNames into a single string, with the last conflicting utility winning.
406
+ * Join classNames into a single string.
445
407
  *
446
- * \`cx('px_4', 'px_2')\` is \`'px_2'\`: two classes that set the same property under the
447
- * same conditions cannot both apply, and which one the browser picks would otherwise
448
- * depend on their order in the stylesheet rather than on the order you passed them.
449
- * Classes bamboo did not generate are left alone, duplicates included.
408
+ * This does **not** resolve conflicts between them: \`cx('px_4', 'px_2')\` keeps both, and
409
+ * the browser picks by their order in the stylesheet rather than by the order you passed
410
+ * them. That is true of every build — atomic, hashed and grouped alike.
411
+ *
412
+ * To override a style rather than append to it, let the cascade decide: styles from
413
+ * \`cva\`/\`sva\` sit in the \`recipes\` layer and \`css()\` in \`utilities\`, so a consumer's
414
+ * \`css()\` always wins. Between two \`css()\` calls you own, merge the objects instead —
415
+ * \`css(base, override)\` resolves per property before any class name exists.
450
416
  */
451
417
  export declare function cx(...args: Argument[]): string
452
418
  `;
453
- /**
454
- * The plain concatenating \`cx\`, for when the class names carry nothing to merge on.
455
- *
456
- * With \`hash.className\` every class is an opaque hash, so there is no property to compare
457
- * and no merge to do — emitting the matcher would only cost bytes on a path that runs in
458
- * the browser on every render.
459
- */
460
- function concatOnly() {
461
- return outdent$1`
419
+ function generateCx() {
420
+ return {
421
+ js: outdent$1`
462
422
  function cx(...args) {
463
423
  let str = ''
464
424
 
465
425
  for (let i = 0; i < args.length; i++) {
466
426
  const arg = args[i]
467
427
  if (!arg) continue
468
- // Arrays are part of the declared type, so this branch has to handle them even
469
- // though it does no merging — returning '' for \`cx(['a', 'b'])\` would be a lie.
428
+ // Arrays are part of the declared type, so this branch has to handle them.
429
+ // Returning '' for \`cx(['a', 'b'])\` would be a lie.
470
430
  const part = Array.isArray(arg) ? cx(...arg) : typeof arg === 'string' ? arg : ''
471
431
  if (!part) continue
472
432
  str && (str += ' ')
@@ -476,185 +436,18 @@ function concatOnly() {
476
436
  }
477
437
 
478
438
  export { cx }
479
- `;
480
- }
481
- function generateCx(ctx) {
482
- const { utility, hash, prefix } = ctx;
483
- const separatorChar = utility.separator;
484
- const utilityClassNames = [...new Set(utility.keys().map((key) => {
485
- const withEmptyValue = utility.getClassName(utility.resolveShorthand(key), "");
486
- return withEmptyValue.endsWith(separatorChar) ? withEmptyValue.slice(0, -separatorChar.length) : withEmptyValue;
487
- }))].sort();
488
- const recipeClassNames = [...new Set(ctx.recipes.details.map((node) => node.className))].filter(Boolean).sort();
489
- if (hash.className || utilityClassNames.length === 0) return {
490
- js: concatOnly(),
491
- dts
492
- };
493
- return {
494
- js: outdent$1`
495
- const cxSeparator = ${JSON.stringify(utility.separator)}
496
- const cxPrefix = ${prefix.className ? JSON.stringify(prefix.className + "-") : "''"}
497
- const cxUtilities = new Set(${JSON.stringify(utilityClassNames.join(","))}.split(','))
498
- const cxRecipes = ${recipeClassNames.length ? `new Set(${JSON.stringify(recipeClassNames.join(","))}.split(','))` : "null"}
499
-
500
- /**
501
- * The declaration a bamboo class sets: its condition path plus the property, without the
502
- * value. Two classes sharing one are alternatives, and only the last can apply.
503
- *
504
- * \`null\` for anything that is not a bamboo class, which is then never merged.
505
- */
506
- function mergeKey(className) {
507
- let end = className.length
508
-
509
- // \`c_red\` and \`c_red!\` are the same declaration. Argument order decides between them,
510
- // which is the point of this function — the cascade would always pick the important
511
- // one no matter which the caller asked for.
512
- if (end > 0 && className.charCodeAt(end - 1) === 33) end -= 1
513
- if (end === 0) return null
514
-
515
- // The last colon ends the condition path — but only one outside brackets, since an
516
- // arbitrary selector carries its own: \`[&[data-x="a:b"]]:px_4\`.
517
- let depth = 0
518
- let lastColon = -1
519
- for (let i = 0; i < end; i++) {
520
- const code = className.charCodeAt(i)
521
- if (code === 91) depth++
522
- else if (code === 93) depth--
523
- else if (code === 58 && depth === 0) lastColon = i
524
- }
525
-
526
- // Conditions come before the prefix — \`hover:bam-px_4\` — so the prefix is skipped
527
- // after the condition path, not before it. When a prefix is configured every class
528
- // bamboo emits carries it, so one that does not is by definition someone else's.
529
- let propStart = lastColon + 1
530
- if (cxPrefix) {
531
- if (!className.startsWith(cxPrefix, propStart)) return null
532
- propStart += cxPrefix.length
533
- }
534
-
535
- // A recipe owns its whole class, bare or with a \`--variant\` suffix, whatever it
536
- // looks like to the utility matcher below.
537
- if (cxRecipes !== null) {
538
- const variantIdx = className.indexOf('--', propStart)
539
- const base = variantIdx === -1 ? className.slice(propStart, end) : className.slice(propStart, variantIdx)
540
- if (cxRecipes.has(base)) return null
541
- }
542
-
543
- // The longest registered utility name wins, not the first separator. Utility names
544
- // contain the separator themselves under \`separator: '-'\` — \`bd-w\`, \`ov-x\`,
545
- // \`translate-x\` — and their leading segment is often a utility too, so stopping at the
546
- // first \`-\` would key \`bd-w-4px\` and \`bd-c-red\` both on \`bd\` and drop one of them.
547
- let property = null
548
- let sepIdx = className.indexOf(cxSeparator, propStart)
549
- while (sepIdx > propStart && sepIdx < end) {
550
- const candidate = className.slice(propStart, sepIdx)
551
- if (cxUtilities.has(candidate)) property = candidate
552
- sepIdx = className.indexOf(cxSeparator, sepIdx + 1)
553
- }
554
-
555
- // Only a class bamboo generated for a utility. A recipe class or a hand-written one
556
- // may well contain the separator, and merging on the text before it would drop a
557
- // class the caller meant to keep.
558
- if (property === null) return null
559
-
560
- return lastColon === -1 ? property : className.slice(0, lastColon) + ':' + property
561
- }
562
-
563
- function isClassWhitespace(code) {
564
- return code === 32 || code === 9 || code === 10 || code === 12 || code === 13
565
- }
566
-
567
- function flattenParts(parts, out) {
568
- for (let i = 0; i < parts.length; i++) {
569
- const part = parts[i]
570
- if (!part) continue
571
- if (Array.isArray(part)) flattenParts(part, out)
572
- else if (typeof part === 'string') out.push(part)
573
- }
574
- }
575
-
576
- function mergeClassStrings(classes) {
577
- const seen = new Map()
578
- const order = []
579
- let id = 0
580
-
581
- for (let c = 0; c < classes.length; c++) {
582
- const cls = classes[c]
583
- let tokenStart = 0
584
-
585
- for (let i = 0; i <= cls.length; i++) {
586
- // The class attribute splits on all ASCII whitespace, not just the space, and a
587
- // multi-line template literal is an ordinary way to write one.
588
- if (i !== cls.length && !isClassWhitespace(cls.charCodeAt(i))) continue
589
- if (i === tokenStart) {
590
- tokenStart = i + 1
591
- continue
592
- }
593
-
594
- const token = cls.slice(tokenStart, i)
595
- tokenStart = i + 1
596
-
597
- const key = mergeKey(token)
598
- if (key !== null) {
599
- // Keeps the first position and the last value, so a later override lands where
600
- // the class it replaces already sat.
601
- if (!seen.has(key)) order.push(key)
602
- seen.set(key, token)
603
- } else {
604
- // Not ours to reason about — kept as written, duplicates and all.
605
- const uniqueKey = '\\0' + id++
606
- order.push(uniqueKey)
607
- seen.set(uniqueKey, token)
608
- }
609
- }
610
- }
611
-
612
- if (order.length === 0) return ''
613
- let str = seen.get(order[0])
614
- for (let i = 1; i < order.length; i++) str += ' ' + seen.get(order[i])
615
- return str
616
- }
617
-
618
- function cx() {
619
- // Everything that produces a bamboo class string — \`css()\`, a recipe, a nested \`cx\` —
620
- // emits one that is already conflict-free, so a lone string has nothing to merge and
621
- // tokenizing it is pure cost. This is the hot path: \`cx(staticClasses, props.className)\`
622
- // with no \`className\` passed.
623
- if (arguments.length === 1) {
624
- const only = arguments[0]
625
- if (typeof only === 'string') return only
626
- if (!only) return ''
627
- }
628
-
629
- const flat = []
630
- flattenParts(arguments, flat)
631
- if (flat.length === 0) return ''
632
- if (flat.length === 1) return flat[0]
633
- return mergeClassStrings(flat)
634
- }
635
-
636
- export { cx }
637
- `,
638
- dts
439
+ `,
440
+ dts: declaration
639
441
  };
640
442
  }
641
443
  //#endregion
642
- //#region src/artifacts/generated/astish.mjs.json
643
- var content$11 = "//#region src/astish.ts\nconst newRule = /(?:([\\u0080-\\uFFFF\\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\\s*)/g;\nconst ruleClean = /\\/\\*[^]*?\\*\\/| +/g;\nconst ruleNewline = /\\n+/g;\nconst empty = \" \";\nconst astish = (val, tree = [{}]) => {\n if (!val) return tree[0];\n let block, left;\n while (block = newRule.exec(val.replace(ruleClean, \"\"))) if (block[4]) tree.shift();\n else if (block[3]) {\n left = block[3].replace(ruleNewline, empty).trim();\n if (!left.includes(\"&\") && !left.startsWith(\"@\")) left = \"& \" + left;\n tree.unshift(tree[0][left] = tree[0][left] || {});\n } else tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim();\n return tree[0];\n};\n//#endregion\nexport { astish };\n";
644
- //#endregion
645
444
  //#region src/artifacts/generated/helpers.mjs.json
646
- var content$10 = "//#region src/assert.ts\nfunction isObject(value) {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\nconst isObjectOrArray = (obj) => typeof obj === \"object\" && obj !== null;\n//#endregion\n//#region src/condition.ts\nconst isBaseCondition = (v) => v === \"base\";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n//#endregion\n//#region 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) name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i) h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n//#endregion\n//#region src/important.ts\nconst importantRegex = /\\s*!(important)?/i;\nconst whitespaceRegex = /\\s/;\n/**\n* Collapse every run of whitespace to a single space, which is what the class name is\n* built from. Exported because `leafClass` has to reproduce this exact pipeline, and a\n* second copy of it would be free to drift from the one `createCss` runs.\n*/\nfunction sanitize(value) {\n if (typeof value !== \"string\") return value;\n const collapsed = whitespaceRegex.test(value) ? value.replaceAll(/[\\n\\s]+/g, \" \") : value;\n return collapsed.includes(\"\\0\") ? collapsed.replaceAll(\"\\0\", \"\") : collapsed;\n}\nfunction isImportant(value) {\n if (typeof value !== \"string\") return false;\n return value.includes(\"!\") && importantRegex.test(value);\n}\nfunction withoutImportant(value) {\n if (typeof value !== \"string\") return value;\n if (!value.includes(\"!\")) return value.trim();\n return value.replace(importantRegex, \"\").trim();\n}\nfunction withoutSpace(str) {\n if (typeof str !== \"string\") return str;\n return str.includes(\" \") ? str.replaceAll(\" \", \"_\") : str;\n}\n//#endregion\n//#region src/memo.ts\n/**\n* Bounded argument memo used by the generated runtime (`css`, patterns, `cva`, recipes).\n*\n* Two regimes, picked per call:\n*\n* - Arguments that are flat (objects of primitives) take a cheap structural hash\n* and are confirmed with an exact comparison, so a hash collision can never\n* serve the wrong result. This is the shape `css({ ... })` has.\n* - Anything nested falls back to `JSON.stringify`, which V8 does faster than a\n* JS walk.\n*\n* The second point is the counter-intuitive one, and it has been measured rather\n* than assumed. Extending the structural hash to recurse — so nested styles could\n* take the fast path too — is *slower*, because it trades one native serialization\n* for two JS walks (hash, then the deep equality that confirms it). Over 10k\n* iterations per shape:\n*\n* shape stringify recursive hash + deep equal\n* flat 1.06ms 2.09ms\n* _hover 1.00ms 2.16ms\n* responsive 1.23ms 2.15ms\n* realistic 2.32ms 5.84ms\n* nested 3 deep 1.22ms 2.35ms\n*\n* So a nested `css()` call costing several times a flat one is not a defect here.\n* It is the floor for a value-keyed memo in JS, and the way to avoid it is to not\n* make the call — see the build-time fold in `@bamboocss/vite`.\n*\n* Both regimes key on *values*, never on object identity: mutating a style object\n* between calls changes its hash, so the next call misses and recomputes rather\n* than serving a stale class. Keying nested arguments on the identity of the inner\n* objects would skip serialization entirely, but it cannot detect a mutation, and\n* \"same object, different contents\" is exactly what a style object built per render\n* looks like.\n*\n* Both caches are bounded. An unbounded memo is a leak in any long-lived process\n* (SSR), where the set of distinct style objects grows without limit.\n*/\n/**\n* Distinct hashes held per memoized function before the cache rotates.\n*\n* This bounds *buckets*, not entries: a bucket keeps up to `MAX_BUCKET` colliding\n* argument lists, so the ceiling is `MAX_ENTRIES * MAX_BUCKET` live entries, and\n* twice that across both generations, since the previous one is retained until the\n* next rotation. Collisions are rare in practice, so the realistic figure is close\n* to `MAX_ENTRIES` — but the worst case is what matters when sizing a long-lived\n* process, so state it plainly.\n*\n* Rotation beats evicting the oldest key: single-key eviction is worst-case for a\n* working set that cycles, because it drops exactly the entry about to be needed.\n* Measured on a cycling set of 20k styles, one-at-a-time eviction cost ~719ns/op\n* against ~189ns unbounded, while rotation holds ~274ns. On realistic skewed\n* access rotation is at or below the unbounded cost.\n*/\nconst MAX_ENTRIES = 1e3;\n/** Entries kept per hash bucket, to bound the cost of a collision scan. */\nconst MAX_BUCKET = 8;\n/**\n* DJB2 over the arguments' own keys and primitive values.\n* Returns `null` for anything nested, which routes the call to the string key.\n*/\nconst flatHashOrNull = (args) => {\n let h = 5381;\n for (let a = 0; a < args.length; a++) {\n const obj = args[a];\n if (obj === null || typeof obj !== \"object\") {\n const t = typeof obj;\n if (t === \"string\") for (let i = 0; i < obj.length; i++) h = h * 33 ^ obj.charCodeAt(i);\n else if (t === \"number\") h = h * 33 ^ (obj | 0);\n else if (t === \"boolean\") h = h * 33 ^ (obj ? 991 : 997);\n else h = h * 33 ^ 3;\n continue;\n }\n if (Array.isArray(obj)) h = h * 33 ^ 7;\n else {\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) return null;\n }\n for (const k in obj) {\n const v = obj[k];\n const tv = typeof v;\n if (v !== null && tv === \"object\") return null;\n for (let i = 0; i < k.length; i++) h = h * 33 ^ k.charCodeAt(i);\n if (tv === \"string\") for (let i = 0; i < v.length; i++) h = h * 33 ^ v.charCodeAt(i);\n else if (tv === \"number\") h = h * 33 ^ (v | 0);\n else if (tv === \"boolean\") h = h * 33 ^ (v ? 991 : 997);\n else h = h * 33 ^ 2;\n }\n }\n return h >>> 0;\n};\n/**\n* Value snapshot of the arguments, taken once at insert.\n*\n* The cache must not hold the caller's objects: a style object can capture a much\n* larger graph, and keeping it alive until the cache rotates changes GC behaviour\n* for code that never asked to be cached. Only the flat path reaches here, so a\n* shallow copy contains primitives only and retains nothing.\n*\n* Comparing against a copy also removes the last way a mutation could be missed.\n* Were the caller's own object stored, `oa === ob` would short-circuit the value\n* comparison, and a mutation that happened to preserve the hash would return the\n* stale entry. Against a copy that check can only ever be true for equal\n* primitives.\n*/\nconst snapshotArgs = (args) => {\n const values = [];\n const counts = [];\n for (let i = 0; i < args.length; i++) {\n const o = args[i];\n if (o !== null && typeof o === \"object\") {\n const copy = Array.isArray(o) ? [] : {};\n let n = 0;\n for (const k in o) {\n copy[k] = o[k];\n n++;\n }\n values.push(copy);\n counts.push(n);\n } else {\n values.push(o);\n counts.push(0);\n }\n }\n return {\n values,\n counts\n };\n};\n/**\n* Exact match, so a `flatHashOrNull` collision is resolved rather than trusted.\n* `bCounts` is the cached side's key count; comparing against it avoids the\n* `Object.keys()` allocation this would otherwise make on every cache hit.\n*/\nconst flatArgsEqual = (a, b, bCounts) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const oa = a[i];\n const ob = b[i];\n if (oa === ob) continue;\n if (oa === null || ob === null || typeof oa !== \"object\" || typeof ob !== \"object\") return false;\n if (Array.isArray(oa) !== Array.isArray(ob)) return false;\n let n = 0;\n for (const k in oa) {\n if (oa[k] !== ob[k]) return false;\n n++;\n }\n if (n !== bCounts[i]) return false;\n }\n return true;\n};\nconst memo = (fn) => {\n let buckets = /* @__PURE__ */ new Map();\n let priorBuckets = /* @__PURE__ */ new Map();\n let strings = /* @__PURE__ */ new Map();\n let priorStrings = /* @__PURE__ */ new Map();\n /**\n * One scalar argument, keyed directly.\n *\n * This is the shape of the hottest callers — `isCssProperty(prop)` runs per prop\n * per render — and a plain map lookup beats hashing, bucket scanning and\n * snapshotting for it. Distinct types stay distinct keys, so `1` and `'1'` do not\n * share an entry.\n */\n let scalars = /* @__PURE__ */ new Map();\n let priorScalars = /* @__PURE__ */ new Map();\n const scan = (bucket, args) => {\n if (bucket) for (let i = 0; i < bucket.length; i++) {\n const entry = bucket[i];\n if (flatArgsEqual(args, entry.values, entry.counts)) return entry;\n }\n };\n const get = (...args) => {\n if (args.length === 1) {\n const only = args[0];\n if (only === null || typeof only !== \"object\") {\n if (scalars.has(only)) return scalars.get(only);\n if (priorScalars.has(only)) {\n const promoted = priorScalars.get(only);\n scalars.set(only, promoted);\n return promoted;\n }\n const out = fn(only);\n scalars.set(only, out);\n if (scalars.size > MAX_ENTRIES) {\n priorScalars = scalars;\n scalars = /* @__PURE__ */ new Map();\n }\n return out;\n }\n }\n const hash = flatHashOrNull(args);\n if (hash !== null) {\n let bucket = buckets.get(hash);\n const hit = scan(bucket, args);\n if (hit) return hit.out;\n const priorHit = scan(priorBuckets.get(hash), args);\n if (priorHit) {\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push(priorHit);\n if (bucket.length > MAX_BUCKET) bucket.shift();\n return priorHit.out;\n }\n const snap = snapshotArgs(args);\n const out = fn(...args);\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push({\n values: snap.values,\n counts: snap.counts,\n out\n });\n if (bucket.length > MAX_BUCKET) bucket.shift();\n if (buckets.size > MAX_ENTRIES) {\n priorBuckets = buckets;\n buckets = /* @__PURE__ */ new Map();\n }\n return out;\n }\n const key = JSON.stringify(args);\n if (strings.has(key)) return strings.get(key);\n if (priorStrings.has(key)) {\n const promoted = priorStrings.get(key);\n strings.set(key, promoted);\n return promoted;\n }\n const out = fn(...args);\n strings.set(key, out);\n if (strings.size > MAX_ENTRIES) {\n priorStrings = strings;\n strings = /* @__PURE__ */ new Map();\n }\n return out;\n };\n return get;\n};\n//#endregion\n//#region src/merge-props.ts\nconst MERGE_OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\nfunction mergeProps(...sources) {\n return sources.reduce((prev, obj) => {\n if (!obj) return prev;\n Object.keys(obj).forEach((key) => {\n if (MERGE_OMIT.has(key)) return;\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);\n else prev[key] = value;\n });\n return prev;\n }, {});\n}\n//#endregion\n//#region src/walk-object.ts\nconst isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObjectOrArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop, child) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) return predicate(value, path);\n const next = inner(child, childPath);\n if (isNotNullish(next)) result[key] = next;\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (Array.isArray(obj)) return obj.map((value) => fn(value));\n if (!isObject(obj)) return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n//#endregion\n//#region 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) acc[key] = current;\n return acc;\n }, {});\n}\n/**\n* Whether walking the object would only rebuild it.\n*\n* Normalizing does three things: it renames a shorthand to its longhand, expands a responsive\n* array into a breakpoint object, and drops nullish leaves. A flat object of plain values\n* written in longhand needs none of them, and that is most of what `css()` is handed — but it\n* still paid for a full rebuild plus a path array per key.\n*\n* Every clause has to be exact, since a false positive returns an object the walk would have\n* changed. Nullish is one of them: a leaf the walk removes must not survive, or a later merge\n* would see it override the value beneath it. The array check is another, and it is on the\n* container as well as the values — `stop` is handed the container, so an array arriving at\n* the top level becomes a breakpoint object rather than being walked into.\n*\n* `for...in` reads inherited keys the walk ignores, which is safe in the only direction it can\n* be wrong — an extra key can send this to the slow path, never past it.\n*\n* It does read every value, as `compactStyles` and the argument memo already do, so an\n* accessor prop is read once more than before. Style props are values by the time they get\n* here and reading one has no effect, but it is the reason this cannot be reordered to read\n* lazily.\n*/\nfunction needsNoNormalizing(styles, resolveShorthand) {\n if (Array.isArray(styles)) return false;\n for (const key in styles) {\n const value = styles[key];\n if (value == null || typeof value === \"object\") return false;\n if (resolveShorthand !== void 0 && resolveShorthand(key) !== key) return false;\n }\n return true;\n}\n/**\n* The result may be the argument itself rather than a fresh object, so callers have to treat\n* it as read-only. Every one of them does today: merging accumulates into its own object and\n* the two `raw()` helpers clone at the boundary.\n*/\nfunction normalizeStyleObject(styles, context, shorthand = true) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n if (needsNoNormalizing(styles, shorthand && hasShorthand ? resolveShorthand : void 0)) return styles;\n return walkObject(styles, (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n }, {\n stop: (value) => Array.isArray(value),\n getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0\n });\n}\n//#endregion\n//#region src/classname.ts\nconst fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nconst ENTRY_SEP = \"]___[\";\nconst COND_SEP = \"<___>\";\nfunction createCss(context) {\n const { utility, hash, grouped, conditions: conds = fallbackCondition } = context;\n const { prefix } = utility;\n const formatClassName = prefix ? (str) => str ? `${prefix}-${str}` : prefix : (str) => str || \"\";\n const hashFn = (conditions, className) => {\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n return formatClassName(utility.toHash(baseArray, toHash));\n }\n const finalized = conds.finalize(conditions);\n if (finalized.length === 0) return formatClassName(className);\n return [...finalized, formatClassName(className)].join(\":\");\n };\n if (grouped) return memo(({ base, ...styles } = {}) => {\n const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);\n const hashes = [];\n walkObject(normalizedObject, (value, paths) => {\n if (value == null) return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const parts = [`${prop}${ENTRY_SEP}value:${value}`];\n if (conditions.length) parts.push(`cond:${conditions.join(COND_SEP)}`);\n hashes.push(parts.join(ENTRY_SEP));\n });\n if (hashes.length === 0) return \"\";\n hashes.sort();\n const groupId = hashes.join(\"|\");\n return formatClassName(utility.toHash([\"grouped\", groupId], toHash));\n });\n return memo(({ base, ...styles } = {}) => {\n const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n if (value == null) return;\n const important = isImportant(value);\n const [prop, ...allConditions] = conds.shift(paths);\n let className = hashFn(filterBaseConditions(allConditions), utility.transform(prop, withoutImportant(sanitize(value))).className);\n if (important) className = `${className}!`;\n classNames.add(className);\n });\n return Array.from(classNames).join(\" \");\n });\n}\n/**\n* Whether a style object carries anything `compact` would have kept.\n*\n* The question `compactStyles` asks is only ever \"is this empty once undefined values are\n* dropped\", but it used to answer it by building the compacted object and then a key array\n* for it, then throwing both away. `Object.keys` enumerates exactly what `compact`'s\n* `Object.entries` did — own, enumerable, string-keyed — so this is the same predicate\n* without the two allocations, and it stops at the first value that settles it.\n*/\nfunction hasDefinedValue(style) {\n const keys = Object.keys(style);\n for (let i = 0; i < keys.length; i++) if (style[keys[i]] !== void 0) return true;\n return false;\n}\nfunction compactStyles(...styles) {\n return styles.flat().filter((style) => isObject(style) && hasDefinedValue(style));\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1) return allStyles;\n return allStyles.map((style) => normalizeStyleObject(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 {\n mergeCss: memo(mergeCss),\n assignCss\n };\n}\n//#endregion\n//#region src/clone-styles.ts\nconst OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\n/**\n* Independent copy of a style object, nested condition blocks included.\n*\n* Merged style objects are cached, so anything handed to user code has to be\n* copied first: a caller mutating what it received would otherwise change what\n* every later caller reads back. `css.raw()` and `cva.raw()` are those boundaries.\n*\n* Kept separate from `mergeProps` deliberately. Merging is on the hot path — it\n* runs on every `css()` cache miss and on every render of a pattern component\n* under `jsxStyleProps: 'minimal'` — and copying there charges every caller for a\n* guarantee only the two `raw()` helpers need. Measured on a realistic style\n* object (5 base properties, 4 condition blocks) that was roughly twice the cost\n* of merging alone.\n*/\nfunction cloneStyles(styles) {\n if (Array.isArray(styles)) return styles.map((value) => cloneStyles(value));\n if (!isObject(styles)) return styles;\n const out = {};\n for (const key of Object.keys(styles)) {\n if (OMIT.has(key)) continue;\n out[key] = cloneStyles(styles[key]);\n }\n return out;\n}\n//#endregion\n//#region src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));\n}\n//#endregion\n//#region src/leaf-class.ts\n/**\n* The class a single dynamic style leaf resolves to, given the prefix its property and\n* condition path produce.\n*\n* ## Why this can exist at all\n*\n* `css()` builds a class from the value alone — `utility.transform` is string\n* construction over a static map, and nothing consults which rules were actually emitted.\n* So `css({ color: tone })` already returns `c_<tone>` for a value the extractor never\n* saw, with no CSS behind it. Reproducing that string here cannot be less correct than\n* the call it replaces; it just skips the object literal, the merge and the memo.\n*\n* ## Why it is not a template literal\n*\n* Three shapes do not reduce to `prefix + value`, and all three return `undefined` so the\n* caller runs `css()` instead:\n*\n* - An array is expanded to a responsive object by `normalizeStyleObject`, so it produces\n* one class per breakpoint rather than one class.\n* - An object is a condition block, walked into for the same reason.\n* - `null` and `undefined` are skipped by the walk entirely, which is an empty string\n* rather than a class — that one is answered here, since it needs no `css()` call.\n*\n* ## Why the character scan\n*\n* The remaining work — collapsing whitespace, stripping `!important`, turning spaces into\n* underscores — is three regexes, and paying them per call makes this *slower* than a\n* memo hit. Almost no token value contains whitespace or `!`, so one scan for the\n* characters that make any of it necessary sends the common value straight to a\n* concatenation. A false positive only costs the slow path, so the scan errs wide.\n*/\nfunction leafClass(prefix, value) {\n if (value == null) return \"\";\n const type = typeof value;\n if (type === \"number\" || type === \"boolean\") return `${prefix}${value}`;\n if (type !== \"string\") return void 0;\n const str = value;\n for (let index = 0; index < str.length; index++) {\n const code = str.charCodeAt(index);\n if (code <= 33 || code === 160 || code === 5760 || code >= 8192) return slowLeaf(prefix, str);\n }\n return `${prefix}${str}`;\n}\n/** The full pipeline `createCss` runs, for a value that needs it. */\nfunction slowLeaf(prefix, value) {\n const important = isImportant(value);\n const className = `${prefix}${withoutSpace(withoutImportant(sanitize(value)))}`;\n return important ? `${className}!` : className;\n}\n//#endregion\n//#region src/hypenate-property.ts\nconst wordRegex = /([A-Z])/g;\nconst msRegex = /^ms-/;\nconst hypenateProperty = memo((property) => {\n if (property.startsWith(\"--\")) return property;\n return property.replace(wordRegex, \"-$1\").replace(msRegex, \"-ms-\").toLowerCase();\n});\n//#endregion\n//#region src/is-css-function.ts\nconst fnRegExp = new RegExp(`^(${[\n \"min\",\n \"max\",\n \"clamp\",\n \"calc\"\n].join(\"|\")})\\\\(.*\\\\)`);\nconst isCssFunction = (v) => typeof v === \"string\" && fnRegExp.test(v);\n//#endregion\n//#region src/is-css-unit.ts\nconst lengthUnitsPattern = `(?:${\"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%\".split(\",\").join(\"|\")})`;\nconst lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nconst isCssUnit = (v) => typeof v === \"string\" && lengthRegExp.test(v);\n//#endregion\n//#region src/is-css-var.ts\nconst isCssVar = (v) => typeof v === \"string\" && /^var\\(--.+\\)$/.test(v);\n//#endregion\n//#region src/pattern-fns.ts\nconst patternFns = {\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit\n};\nconst getPatternStyles = (pattern, styles) => {\n if (!pattern?.defaultValues) return styles;\n const defaults = typeof pattern.defaultValues === \"function\" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\n};\n//#endregion\n//#region src/slot.ts\nconst getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join(\"__\"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const recipeParts = (recipe.slots ?? []).map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n return Object.fromEntries(recipeParts);\n};\nconst getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({\n ...compoundVariant,\n css: compoundVariant.css[slotName]\n}));\n//#endregion\n//#region src/split-props.ts\n/**\n* Deal a props object into one bucket per key group, plus a final bucket for the rest.\n* A key goes to the first group that claims it.\n*\n* ## Why the descriptor is read per key rather than in bulk\n*\n* This used to call `Object.getOwnPropertyDescriptors` for the whole object and\n* `defineProperty` for every key it moved. Copying plain values instead is 2.4–2.9x faster\n* on the shapes that allow it, but it is only correct where props are data — and they are\n* not always. Solid compiles props to accessors, so reading one eagerly runs whatever it\n* wraps: splitting a component's props would construct its children before the surrounding\n* provider exists.\n*\n* So the descriptor is fetched per key, and the value path is taken only when it changes\n* nothing observable. An accessor keeps its laziness, a non-enumerable key keeps its\n* invisibility, and `__proto__` is defined rather than assigned so it stays an own\n* property instead of reaching the prototype setter.\n*\n* The one thing the value path drops is `writable`/`configurable`, so a bucket key taken\n* from frozen props is writable where it used to be frozen. Nothing here relies on that,\n* and preserving it would mean `defineProperty` on the common path — the cost this exists\n* to avoid. Keys that take the descriptor path keep theirs, so a bucket can be\n* inconsistent in that one respect.\n*\n* Key order within a bucket is preserved exactly. It is not cosmetic: `cva` merges\n* variant props in iteration order, and the parser reads the rest bucket as the style\n* props it encodes, so order reaches the emitted CSS.\n*/\nfunction splitProps(props, ...keys) {\n const allKeys = Object.getOwnPropertyNames(props);\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const split = (group) => {\n const clone = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n if (!descriptor) continue;\n if (\"get\" in descriptor || \"set\" in descriptor || !descriptor.enumerable || key === \"__proto__\") Object.defineProperty(clone, key, descriptor);\n else clone[key] = descriptor.value;\n taken.add(key);\n }\n return clone;\n };\n /**\n * The predicate is called with the key alone.\n *\n * Handing it to `filter` passes `(key, index, allKeys)`. A one-parameter predicate cannot\n * see the extras, but a memoized one reads its whole argument list — and the predicates\n * that arrive here are memoized, `isCssProperty` among them. So the memo hashed the entire\n * key array once per prop, and keyed its cache on it: two elements with different prop sets\n * shared no entry even for the same prop name.\n *\n * Worth ~9.7x on that path, and nothing at all on a plain predicate — which is why the\n * bench below it needs a memoized case to see this at all.\n *\n * A loop rather than `filter((k) => key(k))` because the wrapper allocates a closure per\n * group. The two measure the same to within noise; the loop just does not need one.\n */\n const matching = (predicate) => {\n const group = [];\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (predicate(key)) group.push(key);\n }\n return group;\n };\n return keys.map((key) => split(Array.isArray(key) ? key : matching(key))).concat(split(allKeys));\n}\n//#endregion\n//#region src/uniq.ts\nconst uniq = (...items) => {\n const set = items.reduce((acc, currItems) => {\n if (currItems) currItems.forEach((item) => acc.add(item));\n return acc;\n }, /* @__PURE__ */ new Set([]));\n return Array.from(set);\n};\n//#endregion\n//#region src/view-transition.ts\n/**\n* The slots a `viewTransition()` bag accepts, in the order they are emitted.\n*\n* Anything else in the options object is ignored — including by the hash, so adding a\n* comment key or spreading an unrelated object does not fork the class name.\n*/\nconst viewTransitionSlots = [\n \"group\",\n \"imagePair\",\n \"old\",\n \"new\"\n];\n/**\n* Serialize a value with object keys sorted, so two style objects that differ only in\n* authoring order hash to the same class.\n*\n* Values JSON has no encoding for (`undefined`, functions, symbols) serialize as `null`\n* rather than being dropped. Nothing reaches here holding one — `filterSlots` removes\n* nullish slots, and the extractor drops nullish leaves — so this is only a floor: it\n* keeps a hole in an array from shifting the elements after it.\n*\n* Not exported. The name promises a general-purpose stable serializer, and this is not\n* one; `viewTransitionClassName` is the whole reason it exists.\n*/\nfunction stableStringify(value) {\n if (value === null) return \"null\";\n const type = typeof value;\n if (type === \"boolean\") return value ? \"true\" : \"false\";\n if (type === \"number\") return Number.isFinite(value) ? String(value) : \"null\";\n if (type === \"string\") return JSON.stringify(value);\n if (Array.isArray(value)) {\n let out = \"[\";\n for (let index = 0; index < value.length; index++) {\n if (index) out += \",\";\n out += stableStringify(value[index]);\n }\n return out + \"]\";\n }\n if (type === \"object\") {\n const keys = Object.keys(value).sort();\n let out = \"{\";\n for (let index = 0; index < keys.length; index++) {\n if (index) out += \",\";\n const key = keys[index];\n out += JSON.stringify(key) + \":\" + stableStringify(value[key]);\n }\n return out + \"}\";\n }\n return \"null\";\n}\n/**\n* Keep the four known slots, dropping any that is nullish.\n*\n* Both halves of the contract have to agree on what an empty slot is, and only one of\n* them gets a choice. The extractor evaluates the source, and a nullish property is gone\n* from what it hands over — `{ new: undefined }` and `{}` reach the build identically.\n* So absent, `undefined` and `null` collapse here too, and `new: enabled ? {…} : null`\n* hashes to the bag it actually styles.\n*/\nfunction filterSlots(options) {\n const filtered = {};\n if (!options || typeof options !== \"object\") return filtered;\n for (const slot of viewTransitionSlots) {\n const value = options[slot];\n if (value != null) filtered[slot] = value;\n }\n return filtered;\n}\n/**\n* The class a `viewTransition()` call resolves to.\n*\n* This is the whole contract between the build and the runtime: the extractor hashes the\n* options it found in the source, the generated `viewTransition()` hashes the options it\n* is called with, and the CSS only reaches the element if the two agree. They agree by\n* construction — both call this function — but only over what the extractor can see. A\n* value it cannot resolve statically is absent from its side and present on the runtime's,\n* which is why a bag has to be a static object literal to be styled at all.\n*\n* The class is used twice, as the `view-transition-class` value and as the argument to\n* `::view-transition-*(.cls)`, so the prefix applies to both.\n*/\nfunction viewTransitionClassName(options, prefix = \"\") {\n const base = \"vt_\" + toHash(stableStringify(filterSlots(options)));\n return prefix ? prefix + \"-\" + base : base;\n}\n//#endregion\nexport { cloneStyles, compact, createCss, createMergeCss, filterBaseConditions, getPatternStyles, getSlotCompoundVariant, getSlotRecipes, hypenateProperty, isBaseCondition, isObject, leafClass, mapObject, memo, mergeProps, patternFns, splitProps, toHash, uniq, viewTransitionClassName, walkObject, withoutSpace };\n";
647
- //#endregion
648
- //#region src/artifacts/generated/normalize-html.mjs.json
649
- var content$9 = "//#region src/normalize-html.ts\nconst htmlProps = [\n \"htmlSize\",\n \"htmlTranslate\",\n \"htmlWidth\",\n \"htmlHeight\"\n];\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//#endregion\nexport { normalizeHTMLProps };\n";
445
+ var content$8 = "//#region src/assert.ts\nfunction isObject(value) {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\nconst isObjectOrArray = (obj) => typeof obj === \"object\" && obj !== null;\n//#endregion\n//#region src/condition.ts\nconst isBaseCondition = (v) => v === \"base\";\nfunction filterBaseConditions(c) {\n return c.slice().filter((v) => !isBaseCondition(v));\n}\n//#endregion\n//#region 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) name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i) h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n//#endregion\n//#region src/important.ts\nconst importantRegex = /\\s*!(important)?/i;\nconst whitespaceRegex = /\\s/;\n/**\n* Collapse every run of whitespace to a single space, which is what the class name is\n* built from. Exported because `leafClass` has to reproduce this exact pipeline, and a\n* second copy of it would be free to drift from the one `createCss` runs.\n*/\nfunction sanitize(value) {\n if (typeof value !== \"string\") return value;\n const collapsed = whitespaceRegex.test(value) ? value.replaceAll(/[\\n\\s]+/g, \" \") : value;\n return collapsed.includes(\"\\0\") ? collapsed.replaceAll(\"\\0\", \"\") : collapsed;\n}\nfunction isImportant(value) {\n if (typeof value !== \"string\") return false;\n return value.includes(\"!\") && importantRegex.test(value);\n}\nfunction withoutImportant(value) {\n if (typeof value !== \"string\") return value;\n if (!value.includes(\"!\")) return value.trim();\n return value.replace(importantRegex, \"\").trim();\n}\nfunction withoutSpace(str) {\n if (typeof str !== \"string\") return str;\n return str.includes(\" \") ? str.replaceAll(\" \", \"_\") : str;\n}\n//#endregion\n//#region src/memo.ts\n/**\n* Bounded argument memo used by the generated runtime (`css`, patterns, `cva`, recipes).\n*\n* Two regimes, picked per call:\n*\n* - Arguments that are flat (objects of primitives) take a cheap structural hash\n* and are confirmed with an exact comparison, so a hash collision can never\n* serve the wrong result. This is the shape `css({ ... })` has.\n* - Anything nested falls back to `JSON.stringify`, which V8 does faster than a\n* JS walk.\n*\n* The second point is the counter-intuitive one, and it has been measured rather\n* than assumed. Extending the structural hash to recurse — so nested styles could\n* take the fast path too — is *slower*, because it trades one native serialization\n* for two JS walks (hash, then the deep equality that confirms it). Over 10k\n* iterations per shape:\n*\n* shape stringify recursive hash + deep equal\n* flat 1.06ms 2.09ms\n* _hover 1.00ms 2.16ms\n* responsive 1.23ms 2.15ms\n* realistic 2.32ms 5.84ms\n* nested 3 deep 1.22ms 2.35ms\n*\n* So a nested `css()` call costing several times a flat one is not a defect here.\n* It is the floor for a value-keyed memo in JS, and the way to avoid it is to not\n* make the call — see the build-time fold in `@bamboocss/vite`.\n*\n* Both regimes key on *values*, never on object identity: mutating a style object\n* between calls changes its hash, so the next call misses and recomputes rather\n* than serving a stale class. Keying nested arguments on the identity of the inner\n* objects would skip serialization entirely, but it cannot detect a mutation, and\n* \"same object, different contents\" is exactly what a style object built per render\n* looks like.\n*\n* Both caches are bounded. An unbounded memo is a leak in any long-lived process\n* (SSR), where the set of distinct style objects grows without limit.\n*/\n/**\n* Distinct hashes held per memoized function before the cache rotates.\n*\n* This bounds *buckets*, not entries: a bucket keeps up to `MAX_BUCKET` colliding\n* argument lists, so the ceiling is `MAX_ENTRIES * MAX_BUCKET` live entries, and\n* twice that across both generations, since the previous one is retained until the\n* next rotation. Collisions are rare in practice, so the realistic figure is close\n* to `MAX_ENTRIES` — but the worst case is what matters when sizing a long-lived\n* process, so state it plainly.\n*\n* Rotation beats evicting the oldest key: single-key eviction is worst-case for a\n* working set that cycles, because it drops exactly the entry about to be needed.\n* Measured on a cycling set of 20k styles, one-at-a-time eviction cost ~719ns/op\n* against ~189ns unbounded, while rotation holds ~274ns. On realistic skewed\n* access rotation is at or below the unbounded cost.\n*/\nconst MAX_ENTRIES = 1e3;\n/** Entries kept per hash bucket, to bound the cost of a collision scan. */\nconst MAX_BUCKET = 8;\n/**\n* DJB2 over the arguments' own keys and primitive values.\n* Returns `null` for anything nested, which routes the call to the string key.\n*/\nconst flatHashOrNull = (args) => {\n let h = 5381;\n for (let a = 0; a < args.length; a++) {\n const obj = args[a];\n if (obj === null || typeof obj !== \"object\") {\n const t = typeof obj;\n if (t === \"string\") for (let i = 0; i < obj.length; i++) h = h * 33 ^ obj.charCodeAt(i);\n else if (t === \"number\") h = h * 33 ^ (obj | 0);\n else if (t === \"boolean\") h = h * 33 ^ (obj ? 991 : 997);\n else h = h * 33 ^ 3;\n continue;\n }\n if (Array.isArray(obj)) h = h * 33 ^ 7;\n else {\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) return null;\n }\n for (const k in obj) {\n const v = obj[k];\n const tv = typeof v;\n if (v !== null && tv === \"object\") return null;\n for (let i = 0; i < k.length; i++) h = h * 33 ^ k.charCodeAt(i);\n if (tv === \"string\") for (let i = 0; i < v.length; i++) h = h * 33 ^ v.charCodeAt(i);\n else if (tv === \"number\") h = h * 33 ^ (v | 0);\n else if (tv === \"boolean\") h = h * 33 ^ (v ? 991 : 997);\n else h = h * 33 ^ 2;\n }\n }\n return h >>> 0;\n};\n/**\n* Value snapshot of the arguments, taken once at insert.\n*\n* The cache must not hold the caller's objects: a style object can capture a much\n* larger graph, and keeping it alive until the cache rotates changes GC behaviour\n* for code that never asked to be cached. Only the flat path reaches here, so a\n* shallow copy contains primitives only and retains nothing.\n*\n* Comparing against a copy also removes the last way a mutation could be missed.\n* Were the caller's own object stored, `oa === ob` would short-circuit the value\n* comparison, and a mutation that happened to preserve the hash would return the\n* stale entry. Against a copy that check can only ever be true for equal\n* primitives.\n*/\nconst snapshotArgs = (args) => {\n const values = [];\n const counts = [];\n for (let i = 0; i < args.length; i++) {\n const o = args[i];\n if (o !== null && typeof o === \"object\") {\n const copy = Array.isArray(o) ? [] : {};\n let n = 0;\n for (const k in o) {\n copy[k] = o[k];\n n++;\n }\n values.push(copy);\n counts.push(n);\n } else {\n values.push(o);\n counts.push(0);\n }\n }\n return {\n values,\n counts\n };\n};\n/**\n* Exact match, so a `flatHashOrNull` collision is resolved rather than trusted.\n* `bCounts` is the cached side's key count; comparing against it avoids the\n* `Object.keys()` allocation this would otherwise make on every cache hit.\n*/\nconst flatArgsEqual = (a, b, bCounts) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const oa = a[i];\n const ob = b[i];\n if (oa === ob) continue;\n if (oa === null || ob === null || typeof oa !== \"object\" || typeof ob !== \"object\") return false;\n if (Array.isArray(oa) !== Array.isArray(ob)) return false;\n let n = 0;\n for (const k in oa) {\n if (oa[k] !== ob[k]) return false;\n n++;\n }\n if (n !== bCounts[i]) return false;\n }\n return true;\n};\nconst memo = (fn) => {\n let buckets = /* @__PURE__ */ new Map();\n let priorBuckets = /* @__PURE__ */ new Map();\n let strings = /* @__PURE__ */ new Map();\n let priorStrings = /* @__PURE__ */ new Map();\n /**\n * One scalar argument, keyed directly.\n *\n * This is the shape of the hottest callers — `isCssProperty(prop)` runs per prop\n * per render — and a plain map lookup beats hashing, bucket scanning and\n * snapshotting for it. Distinct types stay distinct keys, so `1` and `'1'` do not\n * share an entry.\n */\n let scalars = /* @__PURE__ */ new Map();\n let priorScalars = /* @__PURE__ */ new Map();\n const scan = (bucket, args) => {\n if (bucket) for (let i = 0; i < bucket.length; i++) {\n const entry = bucket[i];\n if (flatArgsEqual(args, entry.values, entry.counts)) return entry;\n }\n };\n const get = (...args) => {\n if (args.length === 1) {\n const only = args[0];\n if (only === null || typeof only !== \"object\") {\n if (scalars.has(only)) return scalars.get(only);\n if (priorScalars.has(only)) {\n const promoted = priorScalars.get(only);\n scalars.set(only, promoted);\n return promoted;\n }\n const out = fn(only);\n scalars.set(only, out);\n if (scalars.size > MAX_ENTRIES) {\n priorScalars = scalars;\n scalars = /* @__PURE__ */ new Map();\n }\n return out;\n }\n }\n const hash = flatHashOrNull(args);\n if (hash !== null) {\n let bucket = buckets.get(hash);\n const hit = scan(bucket, args);\n if (hit) return hit.out;\n const priorHit = scan(priorBuckets.get(hash), args);\n if (priorHit) {\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push(priorHit);\n if (bucket.length > MAX_BUCKET) bucket.shift();\n return priorHit.out;\n }\n const snap = snapshotArgs(args);\n const out = fn(...args);\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push({\n values: snap.values,\n counts: snap.counts,\n out\n });\n if (bucket.length > MAX_BUCKET) bucket.shift();\n if (buckets.size > MAX_ENTRIES) {\n priorBuckets = buckets;\n buckets = /* @__PURE__ */ new Map();\n }\n return out;\n }\n const key = JSON.stringify(args);\n if (strings.has(key)) return strings.get(key);\n if (priorStrings.has(key)) {\n const promoted = priorStrings.get(key);\n strings.set(key, promoted);\n return promoted;\n }\n const out = fn(...args);\n strings.set(key, out);\n if (strings.size > MAX_ENTRIES) {\n priorStrings = strings;\n strings = /* @__PURE__ */ new Map();\n }\n return out;\n };\n return get;\n};\n//#endregion\n//#region src/merge-props.ts\nconst MERGE_OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\nfunction mergeProps(...sources) {\n return sources.reduce((prev, obj) => {\n if (!obj) return prev;\n Object.keys(obj).forEach((key) => {\n if (MERGE_OMIT.has(key)) return;\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);\n else prev[key] = value;\n });\n return prev;\n }, {});\n}\n//#endregion\n//#region src/walk-object.ts\nconst isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObjectOrArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop, child) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) return predicate(value, path);\n const next = inner(child, childPath);\n if (isNotNullish(next)) result[key] = next;\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (Array.isArray(obj)) return obj.map((value) => fn(value));\n if (!isObject(obj)) return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n//#endregion\n//#region 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) acc[key] = current;\n return acc;\n }, {});\n}\n/**\n* Whether walking the object would only rebuild it.\n*\n* Normalizing does three things: it renames a shorthand to its longhand, expands a responsive\n* array into a breakpoint object, and drops nullish leaves. A flat object of plain values\n* written in longhand needs none of them, and that is most of what `css()` is handed — but it\n* still paid for a full rebuild plus a path array per key.\n*\n* Every clause has to be exact, since a false positive returns an object the walk would have\n* changed. Nullish is one of them: a leaf the walk removes must not survive, or a later merge\n* would see it override the value beneath it. The array check is another, and it is on the\n* container as well as the values — `stop` is handed the container, so an array arriving at\n* the top level becomes a breakpoint object rather than being walked into.\n*\n* `for...in` reads inherited keys the walk ignores, which is safe in the only direction it can\n* be wrong — an extra key can send this to the slow path, never past it.\n*\n* It does read every value, as `compactStyles` and the argument memo already do, so an\n* accessor prop is read once more than before. Style props are values by the time they get\n* here and reading one has no effect, but it is the reason this cannot be reordered to read\n* lazily.\n*/\nfunction needsNoNormalizing(styles, resolveShorthand) {\n if (Array.isArray(styles)) return false;\n for (const key in styles) {\n const value = styles[key];\n if (value == null || typeof value === \"object\") return false;\n if (resolveShorthand !== void 0 && resolveShorthand(key) !== key) return false;\n }\n return true;\n}\n/**\n* The result may be the argument itself rather than a fresh object, so callers have to treat\n* it as read-only. Every one of them does today: merging accumulates into its own object and\n* the two `raw()` helpers clone at the boundary.\n*/\nfunction normalizeStyleObject(styles, context, shorthand = true) {\n const { utility, conditions } = context;\n const { hasShorthand, resolveShorthand } = utility;\n if (needsNoNormalizing(styles, shorthand && hasShorthand ? resolveShorthand : void 0)) return styles;\n return walkObject(styles, (value) => {\n return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;\n }, {\n stop: (value) => Array.isArray(value),\n getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0\n });\n}\n//#endregion\n//#region src/classname.ts\nconst fallbackCondition = {\n shift: (v) => v,\n finalize: (v) => v,\n breakpoints: { keys: [] }\n};\nconst ENTRY_SEP = \"]___[\";\nconst COND_SEP = \"<___>\";\n/**\n* The class a whole grouped `css()` call resolves to, given its group id.\n*\n* Shared with `StyleDecoder.collectGrouped` on purpose: both sides name this class, and\n* deriving it twice is what let `hash.className` re-hash on the build side only, leaving\n* every grouped element carrying a class no rule was emitted for.\n*\n* A group id already digests every declaration in the call, so it is hashed exactly once\n* and `hash.className` is deliberately not consulted — that option shortens *utility*\n* class names, and a grouped class is not one. The build `esc()`s the result for a\n* selector; the runtime does not. That asymmetry belongs to the callers.\n*/\nfunction groupClassName(groupId, toHashFn, formatClassName) {\n return formatClassName(toHashFn([\"grouped\", groupId], toHash));\n}\nfunction createCss(context) {\n const { utility, hash, grouped, conditions: conds = fallbackCondition } = context;\n const { prefix } = utility;\n const formatClassName = prefix ? (str) => str ? `${prefix}-${str}` : prefix : (str) => str || \"\";\n const hashFn = (conditions, className) => {\n if (hash) {\n const baseArray = [...conds.finalize(conditions), className];\n return formatClassName(utility.toHash(baseArray, toHash));\n }\n const finalized = conds.finalize(conditions);\n if (finalized.length === 0) return formatClassName(className);\n return [...finalized, formatClassName(className)].join(\":\");\n };\n /** One declaration, kept only when there is a fallback that might need to name it. */\n const atomicName = (prop, value, conditions) => {\n const important = isImportant(value);\n const className = hashFn(conditions, utility.transform(prop, withoutImportant(sanitize(value))).className);\n return important ? `${className}!` : className;\n };\n if (grouped) {\n const { knownGroups } = context;\n return memo(({ base, ...styles } = {}) => {\n const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);\n const hashes = [];\n const leaves = knownGroups ? [] : void 0;\n walkObject(normalizedObject, (value, paths) => {\n if (value == null) return;\n const [prop, ...allConditions] = conds.shift(paths);\n const conditions = filterBaseConditions(allConditions);\n const parts = [`${prop}${ENTRY_SEP}value:${value}`];\n if (conditions.length) parts.push(`cond:${conditions.join(COND_SEP)}`);\n hashes.push(parts.join(ENTRY_SEP));\n leaves?.push([\n prop,\n value,\n conditions\n ]);\n });\n if (hashes.length === 0) return \"\";\n hashes.sort();\n const className = groupClassName(hashes.join(\"|\"), utility.toHash, formatClassName);\n if (!leaves || knownGroups.has(className)) return className;\n const classNames = new Set([className]);\n for (const [prop, value, conditions] of leaves) classNames.add(atomicName(prop, value, conditions));\n return Array.from(classNames).join(\" \");\n });\n }\n return memo(({ base, ...styles } = {}) => {\n const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);\n const classNames = /* @__PURE__ */ new Set();\n walkObject(normalizedObject, (value, paths) => {\n if (value == null) return;\n const [prop, ...allConditions] = conds.shift(paths);\n classNames.add(atomicName(prop, value, filterBaseConditions(allConditions)));\n });\n return Array.from(classNames).join(\" \");\n });\n}\n/**\n* Whether a style object carries anything `compact` would have kept.\n*\n* The question `compactStyles` asks is only ever \"is this empty once undefined values are\n* dropped\", but it used to answer it by building the compacted object and then a key array\n* for it, then throwing both away. `Object.keys` enumerates exactly what `compact`'s\n* `Object.entries` did — own, enumerable, string-keyed — so this is the same predicate\n* without the two allocations, and it stops at the first value that settles it.\n*/\nfunction hasDefinedValue(style) {\n const keys = Object.keys(style);\n for (let i = 0; i < keys.length; i++) if (style[keys[i]] !== void 0) return true;\n return false;\n}\nfunction compactStyles(...styles) {\n return styles.flat().filter((style) => isObject(style) && hasDefinedValue(style));\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1) return allStyles;\n return allStyles.map((style) => normalizeStyleObject(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 {\n mergeCss: memo(mergeCss),\n assignCss\n };\n}\n//#endregion\n//#region src/clone-styles.ts\nconst OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\n/**\n* Independent copy of a style object, nested condition blocks included.\n*\n* Merged style objects are cached, so anything handed to user code has to be\n* copied first: a caller mutating what it received would otherwise change what\n* every later caller reads back. `css.raw()` and `cva.raw()` are those boundaries.\n*\n* Kept separate from `mergeProps` deliberately. Merging is on the hot path — it\n* runs on every `css()` cache miss and on every render of a pattern component\n* under `jsxStyleProps: 'minimal'` — and copying there charges every caller for a\n* guarantee only the two `raw()` helpers need. Measured on a realistic style\n* object (5 base properties, 4 condition blocks) that was roughly twice the cost\n* of merging alone.\n*/\nfunction cloneStyles(styles) {\n if (Array.isArray(styles)) return styles.map((value) => cloneStyles(value));\n if (!isObject(styles)) return styles;\n const out = {};\n for (const key of Object.keys(styles)) {\n if (OMIT.has(key)) continue;\n out[key] = cloneStyles(styles[key]);\n }\n return out;\n}\n//#endregion\n//#region src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));\n}\n//#endregion\n//#region src/leaf-class.ts\n/**\n* The class a single dynamic style leaf resolves to, given the prefix its property and\n* condition path produce.\n*\n* ## Why this can exist at all\n*\n* `css()` builds a class from the value alone — `utility.transform` is string\n* construction over a static map, and nothing consults which rules were actually emitted.\n* So `css({ color: tone })` already returns `c_<tone>` for a value the extractor never\n* saw, with no CSS behind it. Reproducing that string here cannot be less correct than\n* the call it replaces; it just skips the object literal, the merge and the memo.\n*\n* ## Why it is not a template literal\n*\n* Three shapes do not reduce to `prefix + value`, and all three return `undefined` so the\n* caller runs `css()` instead:\n*\n* - An array is expanded to a responsive object by `normalizeStyleObject`, so it produces\n* one class per breakpoint rather than one class.\n* - An object is a condition block, walked into for the same reason.\n* - `null` and `undefined` are skipped by the walk entirely, which is an empty string\n* rather than a class — that one is answered here, since it needs no `css()` call.\n*\n* ## Why the character scan\n*\n* The remaining work — collapsing whitespace, stripping `!important`, turning spaces into\n* underscores — is three regexes, and paying them per call makes this *slower* than a\n* memo hit. Almost no token value contains whitespace or `!`, so one scan for the\n* characters that make any of it necessary sends the common value straight to a\n* concatenation. A false positive only costs the slow path, so the scan errs wide.\n*/\nfunction leafClass(prefix, value) {\n if (value == null) return \"\";\n const type = typeof value;\n if (type === \"number\" || type === \"boolean\") return `${prefix}${value}`;\n if (type !== \"string\") return void 0;\n const str = value;\n for (let index = 0; index < str.length; index++) {\n const code = str.charCodeAt(index);\n if (code <= 33 || code === 160 || code === 5760 || code >= 8192) return slowLeaf(prefix, str);\n }\n return `${prefix}${str}`;\n}\n/** The full pipeline `createCss` runs, for a value that needs it. */\nfunction slowLeaf(prefix, value) {\n const important = isImportant(value);\n const className = `${prefix}${withoutSpace(withoutImportant(sanitize(value)))}`;\n return important ? `${className}!` : className;\n}\n//#endregion\n//#region src/hypenate-property.ts\nconst wordRegex = /([A-Z])/g;\nconst msRegex = /^ms-/;\nconst hypenateProperty = memo((property) => {\n if (property.startsWith(\"--\")) return property;\n return property.replace(wordRegex, \"-$1\").replace(msRegex, \"-ms-\").toLowerCase();\n});\n//#endregion\n//#region src/recipe-identity.ts\n/** The fields that decide what CSS a recipe produces. Anything else is metadata. */\nconst STYLE_FIELDS = [\n \"base\",\n \"variants\",\n \"compoundVariants\",\n \"defaultVariants\"\n];\n/**\n* A serialization that depends on the config's *content* and not on how it was written.\n*\n* Object keys are sorted, so reordering two variants in the source does not rename every\n* class the recipe emits. Arrays keep their order, because `compoundVariants` is precedence\n* ordered and two orderings are two different recipes.\n*\n* A function serializes to `null` rather than to its source. `JSON.stringify` already drops\n* them, and stringifying instead would key the name on whether the bundle was minified —\n* the same build-dependent divergence that `cx` was changed to avoid. Nothing that survives\n* static extraction is a function, so there is no real config this loses information about.\n*/\nconst stable = (value) => {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n if (Array.isArray(value)) return `[${value.map(stable).join(\",\")}]`;\n const source = value;\n return `{${Object.keys(source).sort().map((key) => `${JSON.stringify(key)}:${stable(source[key])}`).join(\",\")}}`;\n};\n/**\n* The name an inline `cva`/`sva` emits its classes under — `button--size_sm`, where this\n* returns the `button`.\n*\n* A config recipe gets its name from the key it is declared under. An inline one has no\n* such key, and the two places that need the name never meet: the build derives it while\n* emitting the stylesheet, the runtime derives it again in the browser. So it has to come\n* from something both of them see, which leaves the config object itself.\n*\n* Deriving it from the *binding* — `const button = cva(...)` — was the obvious alternative\n* and does not work. Only the build can see that binding; handing it to the runtime means\n* rewriting the call, and then a pipeline without that transform names classes differently\n* from one with it. An optional `className` gets the same readable output with none of\n* that, because it travels inside the config to both sides.\n*\n* `className` is the field a config recipe already names itself with, and it means the same\n* thing here — the prefix every class the recipe emits is built from. An inline recipe that\n* declares one is indistinguishable in the stylesheet from a recipe declared in config.\n*/\nconst getRecipeIdentity = (config, prefix = \"cva\") => {\n const declared = config?.className;\n if (typeof declared === \"string\" && declared) return declared;\n const styles = {};\n for (const field of STYLE_FIELDS) {\n const value = config?.[field];\n if (value !== void 0) styles[field] = value;\n }\n return `${prefix}_${toHash(stable(styles))}`;\n};\n/**\n* The classes a recipe puts on an element: its own, plus one per selected variant.\n*\n* Lives here rather than in the generated `cva` because the build has to be able to check\n* it. `checkNamingAgreement` derives class names both ways and compares them, and it can\n* only do that against the code the browser actually runs — a second implementation written\n* to match would agree with itself and prove nothing.\n*\n* Compound variants are absent by design. Their rule selects on the variant classes already\n* in this list, so it applies without a class of its own.\n*/\nconst getRecipeClassNames = (name, variants, selection, separator = \"_\", format = (className) => className) => {\n let result = format(name);\n for (const variant of Object.keys(variants ?? {})) {\n const value = selection[variant];\n if (value == null) continue;\n if (variants?.[variant]?.[value] == null) continue;\n result += ` ${format(`${name}--${variant}${separator}${withoutSpace(value)}`)}`;\n }\n return result;\n};\n//#endregion\n//#region src/is-css-function.ts\nconst fnRegExp = new RegExp(`^(${[\n \"min\",\n \"max\",\n \"clamp\",\n \"calc\"\n].join(\"|\")})\\\\(.*\\\\)`);\nconst isCssFunction = (v) => typeof v === \"string\" && fnRegExp.test(v);\n//#endregion\n//#region src/is-css-unit.ts\nconst lengthUnitsPattern = `(?:${\"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%\".split(\",\").join(\"|\")})`;\nconst lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nconst isCssUnit = (v) => typeof v === \"string\" && lengthRegExp.test(v);\n//#endregion\n//#region src/is-css-var.ts\nconst isCssVar = (v) => typeof v === \"string\" && /^var\\(--.+\\)$/.test(v);\n//#endregion\n//#region src/pattern-fns.ts\nconst patternFns = {\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit\n};\nconst getPatternStyles = (pattern, styles) => {\n if (!pattern?.defaultValues) return styles;\n const defaults = typeof pattern.defaultValues === \"function\" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\n};\n//#endregion\n//#region src/slot.ts\nconst getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join(\"__\"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const recipeParts = (recipe.slots ?? []).map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n return Object.fromEntries(recipeParts);\n};\nconst getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({\n ...compoundVariant,\n css: compoundVariant.css[slotName]\n}));\n//#endregion\n//#region src/split-props.ts\n/**\n* Deal a props object into one bucket per key group, plus a final bucket for the rest.\n* A key goes to the first group that claims it.\n*\n* ## Why the descriptor is read per key rather than in bulk\n*\n* This used to call `Object.getOwnPropertyDescriptors` for the whole object and\n* `defineProperty` for every key it moved. Copying plain values instead is 2.4–2.9x faster\n* on the shapes that allow it, but it is only correct where props are data — and they are\n* not always. Solid compiles props to accessors, so reading one eagerly runs whatever it\n* wraps: splitting a component's props would construct its children before the surrounding\n* provider exists.\n*\n* So the descriptor is fetched per key, and the value path is taken only when it changes\n* nothing observable. An accessor keeps its laziness, a non-enumerable key keeps its\n* invisibility, and `__proto__` is defined rather than assigned so it stays an own\n* property instead of reaching the prototype setter.\n*\n* The one thing the value path drops is `writable`/`configurable`, so a bucket key taken\n* from frozen props is writable where it used to be frozen. Nothing here relies on that,\n* and preserving it would mean `defineProperty` on the common path — the cost this exists\n* to avoid. Keys that take the descriptor path keep theirs, so a bucket can be\n* inconsistent in that one respect.\n*\n* Key order within a bucket is preserved exactly. It is not cosmetic: `cva` merges\n* variant props in iteration order, and the parser reads the rest bucket as the style\n* props it encodes, so order reaches the emitted CSS.\n*/\nfunction splitProps(props, ...keys) {\n const allKeys = Object.getOwnPropertyNames(props);\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const split = (group) => {\n const clone = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n if (!descriptor) continue;\n if (\"get\" in descriptor || \"set\" in descriptor || !descriptor.enumerable || key === \"__proto__\") Object.defineProperty(clone, key, descriptor);\n else clone[key] = descriptor.value;\n taken.add(key);\n }\n return clone;\n };\n /**\n * The predicate is called with the key alone.\n *\n * Handing it to `filter` passes `(key, index, allKeys)`. A one-parameter predicate cannot\n * see the extras, but a memoized one reads its whole argument list — and the predicates\n * that arrive here are memoized, `isCssProperty` among them. So the memo hashed the entire\n * key array once per prop, and keyed its cache on it: two elements with different prop sets\n * shared no entry even for the same prop name.\n *\n * Worth ~9.7x on that path, and nothing at all on a plain predicate — which is why the\n * bench below it needs a memoized case to see this at all.\n *\n * A loop rather than `filter((k) => key(k))` because the wrapper allocates a closure per\n * group. The two measure the same to within noise; the loop just does not need one.\n */\n const matching = (predicate) => {\n const group = [];\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (predicate(key)) group.push(key);\n }\n return group;\n };\n return keys.map((key) => split(Array.isArray(key) ? key : matching(key))).concat(split(allKeys));\n}\n//#endregion\n//#region src/uniq.ts\nconst uniq = (...items) => {\n const set = items.reduce((acc, currItems) => {\n if (currItems) currItems.forEach((item) => acc.add(item));\n return acc;\n }, /* @__PURE__ */ new Set([]));\n return Array.from(set);\n};\n//#endregion\n//#region src/view-transition.ts\n/**\n* The slots a `viewTransition()` bag accepts, in the order they are emitted.\n*\n* Anything else in the options object is ignored — including by the hash, so adding a\n* comment key or spreading an unrelated object does not fork the class name.\n*/\nconst viewTransitionSlots = [\n \"group\",\n \"imagePair\",\n \"old\",\n \"new\"\n];\n/**\n* Serialize a value with object keys sorted, so two style objects that differ only in\n* authoring order hash to the same class.\n*\n* Values JSON has no encoding for (`undefined`, functions, symbols) serialize as `null`\n* rather than being dropped. Nothing reaches here holding one — `filterSlots` removes\n* nullish slots, and the extractor drops nullish leaves — so this is only a floor: it\n* keeps a hole in an array from shifting the elements after it.\n*\n* Not exported. The name promises a general-purpose stable serializer, and this is not\n* one; `viewTransitionClassName` is the whole reason it exists.\n*/\nfunction stableStringify(value) {\n if (value === null) return \"null\";\n const type = typeof value;\n if (type === \"boolean\") return value ? \"true\" : \"false\";\n if (type === \"number\") return Number.isFinite(value) ? String(value) : \"null\";\n if (type === \"string\") return JSON.stringify(value);\n if (Array.isArray(value)) {\n let out = \"[\";\n for (let index = 0; index < value.length; index++) {\n if (index) out += \",\";\n out += stableStringify(value[index]);\n }\n return out + \"]\";\n }\n if (type === \"object\") {\n const keys = Object.keys(value).sort();\n let out = \"{\";\n for (let index = 0; index < keys.length; index++) {\n if (index) out += \",\";\n const key = keys[index];\n out += JSON.stringify(key) + \":\" + stableStringify(value[key]);\n }\n return out + \"}\";\n }\n return \"null\";\n}\n/**\n* Keep the four known slots, dropping any that is nullish.\n*\n* Both halves of the contract have to agree on what an empty slot is, and only one of\n* them gets a choice. The extractor evaluates the source, and a nullish property is gone\n* from what it hands over — `{ new: undefined }` and `{}` reach the build identically.\n* So absent, `undefined` and `null` collapse here too, and `new: enabled ? {…} : null`\n* hashes to the bag it actually styles.\n*/\nfunction filterSlots(options) {\n const filtered = {};\n if (!options || typeof options !== \"object\") return filtered;\n for (const slot of viewTransitionSlots) {\n const value = options[slot];\n if (value != null) filtered[slot] = value;\n }\n return filtered;\n}\n/**\n* The class a `viewTransition()` call resolves to.\n*\n* This is the whole contract between the build and the runtime: the extractor hashes the\n* options it found in the source, the generated `viewTransition()` hashes the options it\n* is called with, and the CSS only reaches the element if the two agree. They agree by\n* construction — both call this function — but only over what the extractor can see. A\n* value it cannot resolve statically is absent from its side and present on the runtime's,\n* which is why a bag has to be a static object literal to be styled at all.\n*\n* The class is used twice, as the `view-transition-class` value and as the argument to\n* `::view-transition-*(.cls)`, so the prefix applies to both.\n*/\nfunction viewTransitionClassName(options, prefix = \"\") {\n const base = \"vt_\" + toHash(stableStringify(filterSlots(options)));\n return prefix ? prefix + \"-\" + base : base;\n}\n//#endregion\nexport { cloneStyles, compact, createCss, createMergeCss, filterBaseConditions, getPatternStyles, getRecipeClassNames, getRecipeIdentity, getSlotCompoundVariant, getSlotRecipes, hypenateProperty, isBaseCondition, isObject, leafClass, mapObject, memo, mergeProps, patternFns, splitProps, toHash, uniq, viewTransitionClassName, walkObject, withoutSpace };\n";
650
446
  //#endregion
651
447
  //#region src/artifacts/js/helpers.ts
652
- function generateHelpers(ctx) {
448
+ function generateHelpers() {
653
449
  return { js: outdent`
654
- ${content$10}
655
- ${ctx.isTemplateLiteralSyntax ? content$11 : ""}
656
-
657
- ${ctx.jsx.framework ? `${content$9}` : ""}
450
+ ${content$8}
658
451
 
659
452
  export function __spreadValues(a, b) {
660
453
  return { ...a, ...b }
@@ -666,74 +459,6 @@ function generateHelpers(ctx) {
666
459
  ` };
667
460
  }
668
461
  //#endregion
669
- //#region src/artifacts/generated/is-valid-prop.mjs.json
670
- var content$8 = "//#region src/index.ts\nconst userGenerated = \"\".split(\",\");\nconst allCssProperties = \"WebkitAppearance,WebkitBorderBefore,WebkitBorderBeforeColor,WebkitBorderBeforeStyle,WebkitBorderBeforeWidth,WebkitBoxReflect,WebkitLineClamp,WebkitMask,WebkitMaskAttachment,WebkitMaskClip,WebkitMaskComposite,WebkitMaskImage,WebkitMaskOrigin,WebkitMaskPosition,WebkitMaskPositionX,WebkitMaskPositionY,WebkitMaskRepeat,WebkitMaskRepeatX,WebkitMaskRepeatY,WebkitMaskSize,WebkitOverflowScrolling,WebkitTapHighlightColor,WebkitTextFillColor,WebkitTextStroke,WebkitTextStrokeColor,WebkitTextStrokeWidth,WebkitTouchCallout,WebkitUserModify,WebkitUserSelect,accentColor,alignContent,alignItems,alignSelf,alignTracks,all,anchorName,anchorScope,animation,animationComposition,animationDelay,animationDirection,animationDuration,animationFillMode,animationIterationCount,animationName,animationPlayState,animationRange,animationRangeEnd,animationRangeStart,animationTimeline,animationTimingFunction,appearance,aspectRatio,backdropFilter,backfaceVisibility,background,backgroundAttachment,backgroundBlendMode,backgroundClip,backgroundColor,backgroundImage,backgroundOrigin,backgroundPosition,backgroundPositionX,backgroundPositionY,backgroundRepeat,backgroundSize,blockSize,border,borderBlock,borderBlockColor,borderBlockEnd,borderBlockEndColor,borderBlockEndStyle,borderBlockEndWidth,borderBlockStart,borderBlockStartColor,borderBlockStartStyle,borderBlockStartWidth,borderBlockStyle,borderBlockWidth,borderBottom,borderBottomColor,borderBottomLeftRadius,borderBottomRightRadius,borderBottomStyle,borderBottomWidth,borderCollapse,borderColor,borderEndEndRadius,borderEndStartRadius,borderImage,borderImageOutset,borderImageRepeat,borderImageSlice,borderImageSource,borderImageWidth,borderInline,borderInlineColor,borderInlineEnd,borderInlineEndColor,borderInlineEndStyle,borderInlineEndWidth,borderInlineStart,borderInlineStartColor,borderInlineStartStyle,borderInlineStartWidth,borderInlineStyle,borderInlineWidth,borderLeft,borderLeftColor,borderLeftStyle,borderLeftWidth,borderRadius,borderRight,borderRightColor,borderRightStyle,borderRightWidth,borderSpacing,borderStartEndRadius,borderStartStartRadius,borderStyle,borderTop,borderTopColor,borderTopLeftRadius,borderTopRightRadius,borderTopStyle,borderTopWidth,borderWidth,bottom,boxAlign,boxDecorationBreak,boxDirection,boxFlex,boxFlexGroup,boxLines,boxOrdinalGroup,boxOrient,boxPack,boxShadow,boxSizing,breakAfter,breakBefore,breakInside,captionSide,caret,caretColor,caretShape,clear,clip,clipPath,clipRule,color,colorInterpolationFilters,colorScheme,columnCount,columnFill,columnGap,columnRule,columnRuleColor,columnRuleStyle,columnRuleWidth,columnSpan,columnWidth,columns,contain,containIntrinsicBlockSize,containIntrinsicHeight,containIntrinsicInlineSize,containIntrinsicSize,containIntrinsicWidth,container,containerName,containerType,content,contentVisibility,cornerShape,counterIncrement,counterReset,counterSet,cursor,cx,cy,d,direction,display,dominantBaseline,emptyCells,fieldSizing,fill,fillOpacity,fillRule,filter,flex,flexBasis,flexDirection,flexFlow,flexGrow,flexShrink,flexWrap,float,floodColor,floodOpacity,font,fontFamily,fontFeatureSettings,fontKerning,fontLanguageOverride,fontOpticalSizing,fontPalette,fontSize,fontSizeAdjust,fontSmooth,fontStretch,fontStyle,fontSynthesis,fontSynthesisPosition,fontSynthesisSmallCaps,fontSynthesisStyle,fontSynthesisWeight,fontVariant,fontVariantAlternates,fontVariantCaps,fontVariantEastAsian,fontVariantEmoji,fontVariantLigatures,fontVariantNumeric,fontVariantPosition,fontVariationSettings,fontWeight,forcedColorAdjust,gap,grid,gridArea,gridAutoColumns,gridAutoFlow,gridAutoRows,gridColumn,gridColumnEnd,gridColumnGap,gridColumnStart,gridGap,gridRow,gridRowEnd,gridRowGap,gridRowStart,gridTemplate,gridTemplateAreas,gridTemplateColumns,gridTemplateRows,hangingPunctuation,height,hyphenateCharacter,hyphenateLimitChars,hyphens,imageOrientation,imageRendering,imageResolution,imeMode,initialLetter,initialLetterAlign,inlineSize,inset,insetBlock,insetBlockEnd,insetBlockStart,insetInline,insetInlineEnd,insetInlineStart,interpolateSize,isolation,justifyContent,justifyItems,justifySelf,justifyTracks,left,letterSpacing,lightingColor,lineBreak,lineClamp,lineHeight,lineHeightStep,listStyle,listStyleImage,listStylePosition,listStyleType,margin,marginBlock,marginBlockEnd,marginBlockStart,marginBottom,marginInline,marginInlineEnd,marginInlineStart,marginLeft,marginRight,marginTop,marginTrim,marker,markerEnd,markerMid,markerStart,mask,maskBorder,maskBorderMode,maskBorderOutset,maskBorderRepeat,maskBorderSlice,maskBorderSource,maskBorderWidth,maskClip,maskComposite,maskImage,maskMode,maskOrigin,maskPosition,maskRepeat,maskSize,maskType,masonryAutoFlow,mathDepth,mathShift,mathStyle,maxBlockSize,maxHeight,maxInlineSize,maxLines,maxWidth,minBlockSize,minHeight,minInlineSize,minWidth,mixBlendMode,objectFit,objectPosition,offset,offsetAnchor,offsetDistance,offsetPath,offsetPosition,offsetRotate,opacity,order,orphans,outline,outlineColor,outlineOffset,outlineStyle,outlineWidth,overflow,overflowAnchor,overflowBlock,overflowClipBox,overflowClipMargin,overflowInline,overflowWrap,overflowX,overflowY,overlay,overscrollBehavior,overscrollBehaviorBlock,overscrollBehaviorInline,overscrollBehaviorX,overscrollBehaviorY,padding,paddingBlock,paddingBlockEnd,paddingBlockStart,paddingBottom,paddingInline,paddingInlineEnd,paddingInlineStart,paddingLeft,paddingRight,paddingTop,page,pageBreakAfter,pageBreakBefore,pageBreakInside,paintOrder,perspective,perspectiveOrigin,placeContent,placeItems,placeSelf,pointerEvents,position,positionAnchor,positionArea,positionTry,positionTryFallbacks,positionTryOrder,positionVisibility,printColorAdjust,quotes,r,resize,right,rotate,rowGap,rubyAlign,rubyMerge,rubyPosition,rx,ry,scale,scrollBehavior,scrollMargin,scrollMarginBlock,scrollMarginBlockEnd,scrollMarginBlockStart,scrollMarginBottom,scrollMarginInline,scrollMarginInlineEnd,scrollMarginInlineStart,scrollMarginLeft,scrollMarginRight,scrollMarginTop,scrollPadding,scrollPaddingBlock,scrollPaddingBlockEnd,scrollPaddingBlockStart,scrollPaddingBottom,scrollPaddingInline,scrollPaddingInlineEnd,scrollPaddingInlineStart,scrollPaddingLeft,scrollPaddingRight,scrollPaddingTop,scrollSnapAlign,scrollSnapCoordinate,scrollSnapDestination,scrollSnapPointsX,scrollSnapPointsY,scrollSnapStop,scrollSnapType,scrollSnapTypeX,scrollSnapTypeY,scrollTimeline,scrollTimelineAxis,scrollTimelineName,scrollbarColor,scrollbarGutter,scrollbarWidth,shapeImageThreshold,shapeMargin,shapeOutside,shapeRendering,stopColor,stopOpacity,stroke,strokeDasharray,strokeDashoffset,strokeLinecap,strokeLinejoin,strokeMiterlimit,strokeOpacity,strokeWidth,tabSize,tableLayout,textAlign,textAlignLast,textAnchor,textBox,textBoxEdge,textBoxTrim,textCombineUpright,textDecoration,textDecorationColor,textDecorationLine,textDecorationSkip,textDecorationSkipInk,textDecorationStyle,textDecorationThickness,textEmphasis,textEmphasisColor,textEmphasisPosition,textEmphasisStyle,textIndent,textJustify,textOrientation,textOverflow,textRendering,textShadow,textSizeAdjust,textSpacingTrim,textTransform,textUnderlineOffset,textUnderlinePosition,textWrap,textWrapMode,textWrapStyle,timelineScope,top,touchAction,transform,transformBox,transformOrigin,transformStyle,transition,transitionBehavior,transitionDelay,transitionDuration,transitionProperty,transitionTimingFunction,translate,unicodeBidi,userSelect,vectorEffect,verticalAlign,viewTimeline,viewTimelineAxis,viewTimelineInset,viewTimelineName,viewTransitionName,visibility,whiteSpace,whiteSpaceCollapse,widows,width,willChange,wordBreak,wordSpacing,wordWrap,writingMode,x,y,zIndex,zoom,alignmentBaseline,baselineShift,colorInterpolation,colorRendering,glyphOrientationVertical\".split(\",\").concat(userGenerated);\nconst properties = new Map(allCssProperties.map((prop) => [prop, true]));\nfunction memo(fn) {\n const cache = Object.create(null);\n return (arg) => {\n if (cache[arg] === void 0) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\nconst cssPropertySelectorRegex = /&|@/;\nconst isCssProperty = /* @__PURE__ */ memo((prop) => {\n return properties.has(prop) || prop.startsWith(\"--\") || cssPropertySelectorRegex.test(prop);\n});\n//#endregion\nexport { allCssProperties, isCssProperty };\n";
671
- //#endregion
672
- //#region src/artifacts/js/is-valid-prop.ts
673
- const cssPropListRegex = /const userGenerated = ".*?"\.split\(","\);\s*const allCssProperties = "(.*?)"\.split\(","\)\.concat\(userGenerated\);/;
674
- const memoFnDeclarationRegex = /function memo(?:.+?)\n((?:var|const|let) cssPropertySelectorRegex)/s;
675
- function generateIsValidProp(ctx) {
676
- if (ctx.isTemplateLiteralSyntax) return;
677
- let content = content$8;
678
- const propertyList = content.match(cssPropListRegex);
679
- if (!propertyList) throw new BambooError("NOT_FOUND", "Could not find the property list in the prebuilt is-valid-prop module. Its bundled shape has changed.");
680
- const userProperties = match(ctx.jsx.styleProps).with("all", () => Array.from(ctx.properties)).with("minimal", () => ["css"]).with("none", () => ["css"]).exhaustive();
681
- const browserProperties = ctx.jsx.styleProps === "all" ? propertyList[1].split(",") : [];
682
- content = content.replace(cssPropListRegex, () => `const allCssProperties = "${uniq(browserProperties, userProperties).join(",")}".split(",");`);
683
- content = content.replace(memoFnDeclarationRegex, "$1");
684
- if (ctx.jsx.styleProps === "minimal" || ctx.jsx.styleProps === "none") content = content.replace("/* @__PURE__ */ memo(", "/* @__PURE__ */ (");
685
- else content = ctx.file.import("memo", "../helpers") + "\n" + content;
686
- content = ctx.file.import("splitProps", "../helpers") + "\n" + content;
687
- content += `export const splitCssProps = (props) => splitProps(props, isCssProperty)`;
688
- return {
689
- js: content,
690
- dts: outdent`
691
- import type { DistributiveOmit, HTMLBambooProps, JsxStyleProps, Pretty } from '../types';
692
-
693
- declare const isCssProperty: (value: string) => boolean;
694
-
695
- type CssPropKey = keyof JsxStyleProps
696
- type OmittedCssProps<T> = Pretty<DistributiveOmit<T, CssPropKey>>
697
-
698
- declare const splitCssProps: <T>(props: T) => [JsxStyleProps, OmittedCssProps<T>]
699
-
700
- export { isCssProperty, splitCssProps };
701
- `
702
- };
703
- }
704
- //#endregion
705
- //#region src/artifacts/js/jsx-helper.ts
706
- function generatedJsxHelpers(ctx) {
707
- return { js: match(ctx.isTemplateLiteralSyntax).with(true, () => outdent`
708
- export const getDisplayName = (Component) => {
709
- if (typeof Component === 'string') return Component
710
- return Component?.displayName || Component?.name || 'Component'
711
- }`).otherwise(() => outdent`
712
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
713
-
714
- export const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
715
-
716
- export const composeShouldForwardProps = (tag, shouldForwardProp) =>
717
- tag.__shouldForwardProps__ && shouldForwardProp
718
- ? (propName) => tag.__shouldForwardProps__(propName) && shouldForwardProp(propName)
719
- : shouldForwardProp
720
-
721
- export const composeCvaFn = (cvaA, cvaB) => {
722
- if (cvaA && !cvaB) return cvaA
723
- if (!cvaA && cvaB) return cvaB
724
- if ((cvaA.__cva__ && cvaB.__cva__) || (cvaA.__recipe__ && cvaB.__recipe__)) return cvaA.merge(cvaB)
725
- const error = new TypeError('Cannot merge cva with recipe. Please use either cva or recipe.')
726
- TypeError.captureStackTrace?.(error)
727
- throw error
728
- }
729
-
730
- export const getDisplayName = (Component) => {
731
- if (typeof Component === 'string') return Component
732
- return Component?.displayName || Component?.name || 'Component'
733
- }
734
- `) };
735
- }
736
- //#endregion
737
462
  //#region src/artifacts/js/package-json.ts
738
463
  /**
739
464
  * The generated output is a plain directory, not an installed package, so bundlers
@@ -857,22 +582,12 @@ function generatePattern(ctx, filters) {
857
582
  //#region src/shared.ts
858
583
  const isBooleanValue = (value) => value === "true" || value === "false";
859
584
  const formatFunctionValue = (value) => isBooleanValue(value) ? value : `'${value}'`;
860
- const formatJsxValue = (value) => isBooleanValue(value) ? `{${value}}` : `"${value}"`;
861
585
  const buildFunctionProps = (key, value) => `${key}: ${formatFunctionValue(value)}`;
862
- const buildJsxProps = (key, value) => `${key}=${formatJsxValue(value)}`;
863
586
  const formatProps = (props, options = {}) => {
864
587
  const { keyValueSeparator = ": ", propSeparator = ", ", quoteStyle = "single" } = options;
865
588
  const quote = quoteStyle === "single" ? "'" : quoteStyle === "double" ? "\"" : "";
866
589
  return Object.entries(props).filter(([_, value]) => value != null).map(([key, value]) => `${key}${keyValueSeparator}${quote}${value}${quote}`).join(propSeparator);
867
590
  };
868
- const formatJsxComponent = (component, props) => {
869
- const formattedProps = formatProps(props, {
870
- keyValueSeparator: "=",
871
- propSeparator: " ",
872
- quoteStyle: "double"
873
- });
874
- return `<${component}${formattedProps ? " " + formattedProps : ""} />`;
875
- };
876
591
  const collectCompositionStyles = (values) => {
877
592
  const result = [];
878
593
  walkObject(values, (token, paths) => {
@@ -886,27 +601,6 @@ const collectCompositionStyles = (values) => {
886
601
  }, { stop: (v) => isObject(v) && "value" in v });
887
602
  return result;
888
603
  };
889
- /**
890
- * Generates a single JSX example based on jsxStyleProps setting
891
- */
892
- const generateJsxExample = (props, jsxStyleProps = "all", component = "Box") => {
893
- if (jsxStyleProps === "all") return formatJsxComponent(component, props);
894
- if (jsxStyleProps === "minimal") return `<${component} css={{ ${formatProps(props)} }} />`;
895
- return null;
896
- };
897
- /**
898
- * Generates function and JSX examples for a style property
899
- */
900
- const generateJsxExamples = (props, jsxStyleProps = "all", component = "Box") => {
901
- const functionExamples = [`css({ ${formatProps(props)} })`];
902
- const jsxExamples = [];
903
- const jsxExample = generateJsxExample(props, jsxStyleProps, component);
904
- if (jsxExample) jsxExamples.push(jsxExample);
905
- return {
906
- functionExamples,
907
- jsxExamples
908
- };
909
- };
910
604
  const COMPOSITION_STYLE_CONFIG = {
911
605
  "text-styles": {
912
606
  prop: "textStyle",
@@ -921,14 +615,14 @@ const COMPOSITION_STYLE_CONFIG = {
921
615
  themeKey: "animationStyles"
922
616
  }
923
617
  };
924
- function generateCompositionStyleSpec(type, theme, jsxStyleProps) {
618
+ function generateCompositionStyleSpec(type, theme) {
925
619
  const { prop, themeKey } = COMPOSITION_STYLE_CONFIG[type];
926
620
  return {
927
621
  type,
928
622
  data: collectCompositionStyles(theme?.[themeKey] ?? {}).map((style) => ({
929
623
  name: style.name,
930
624
  description: style.description,
931
- ...generateJsxExamples({ [prop]: style.name }, jsxStyleProps)
625
+ functionExamples: [`css({ ${formatProps({ [prop]: style.name })} })`]
932
626
  }))
933
627
  };
934
628
  }
@@ -947,7 +641,6 @@ function generateCreateRecipe(ctx) {
947
641
  dts: "",
948
642
  js: outdent`
949
643
  ${ctx.file.import("finalizeConditions, sortConditions", "../css/conditions")}
950
- ${ctx.file.import("css", "../css/css")}
951
644
  ${ctx.file.import("assertCompoundVariant, getCompoundVariantCss", "../css/cva")}
952
645
  ${ctx.file.import("cx", "../css/cx")}
953
646
  ${ctx.file.import("compact, createCss, splitProps, uniq, withoutSpace", "../helpers")}
@@ -961,7 +654,7 @@ function generateCreateRecipe(ctx) {
961
654
  };
962
655
  };
963
656
 
964
- const recipeFn = (variants, withCompoundVariants = true) => {
657
+ const recipeFn = (variants) => {
965
658
  const transform = (prop, value) => {
966
659
  assertCompoundVariant(name, compoundVariants, variants, prop)
967
660
 
@@ -989,11 +682,10 @@ function generateCreateRecipe(ctx) {
989
682
 
990
683
  const recipeStyles = getVariantProps(variants)
991
684
 
992
- if (withCompoundVariants) {
993
- const compoundVariantStyles = getCompoundVariantCss(compoundVariants, recipeStyles)
994
- return cx(recipeCss(recipeStyles), css(compoundVariantStyles))
995
- }
996
-
685
+ // No class for the compound variants. Their rule selects on the variant classes
686
+ // \`recipeCss\` just named — \`.btn--size_sm.btn--tone_a\` — so it applies on its own,
687
+ // and it is in the same layer as the rest of the recipe rather than atomically in
688
+ // \`utilities\` above it.
997
689
  return recipeCss(recipeStyles)
998
690
  }
999
691
 
@@ -1045,9 +737,22 @@ function generateRecipes(ctx, filters) {
1045
737
  else defaultValue = JSON.stringify(defaultValue);
1046
738
  return ctx.file.jsDocComment("", { default: defaultValue });
1047
739
  };
740
+ const slotNames = Recipes.isSlotRecipeConfig(config) ? config.slots : [];
741
+ const anchorSlotNames = Recipes.isSlotRecipeConfig(config) ? Recipes.getScopeRoots(config) : [];
1048
742
  return {
1049
743
  name: dashName,
1050
- js: match(config).when(Recipes.isSlotRecipeConfig, (config) => outdent`
744
+ js: match(config).when(Recipes.isSlotRecipeConfig, (config) => {
745
+ const anchors = Recipes.getScopeRoots(config);
746
+ /**
747
+ * Which slots each variant writes styles for.
748
+ *
749
+ * A scope reaches every slot inside an anchor's subtree. A slot under no anchor at
750
+ * all is not reached, and nothing here can detect that — reachability is a fact
751
+ * about the DOM. This is what says which slots a variant has to get to, so the
752
+ * component layer can thread the ones a scope cannot.
753
+ */
754
+ const slotsAffectedBy = Object.fromEntries(Object.entries(config.variants ?? {}).map(([variant, values]) => [variant, Array.from(new Set(Object.values(values ?? {}).flatMap((slotStyles) => Object.keys(slotStyles ?? {}))))]));
755
+ return outdent`
1051
756
  ${ctx.file.import("compact, getSlotCompoundVariant, memo, splitProps", "../helpers")}
1052
757
  ${ctx.file.import("createRecipe", "./create-recipe")}
1053
758
 
@@ -1055,11 +760,27 @@ function generateRecipes(ctx, filters) {
1055
760
  const ${baseName}CompoundVariants = ${stringify$2(compoundVariants ?? [])}
1056
761
 
1057
762
  const ${baseName}SlotNames = ${stringify$2(config.slots.map((slot) => [slot, `${config.className}__${slot}`]))}
763
+ ${anchors.length ? outdent`
764
+ /**
765
+ * Only the anchors take variants: ${anchors.map((slot) => `\`${baseName}.${slot}\``).join(", ")}.
766
+ * Every other slot's variant styles are emitted as rules scoped by a class an anchor
767
+ * carries, so that slot's class is a constant and nothing has to reach it at runtime.
768
+ */
769
+ const ${baseName}Anchors = ${JSON.stringify(anchors)}
770
+ const ${baseName}AnchorFns = /* @__PURE__ */ ${baseName}Anchors.map((slotName) => [slotName, createRecipe(\`${config.className}__\${slotName}\`, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
771
+ const ${baseName}StaticSlots = /* @__PURE__ */ Object.fromEntries(
772
+ ${baseName}SlotNames.filter(([slotName]) => !${baseName}Anchors.includes(slotName)),
773
+ )
774
+
775
+ const ${baseName}Fn = memo((props = {}) => ({
776
+ ...${baseName}StaticSlots,
777
+ ...Object.fromEntries(${baseName}AnchorFns.map(([slotName, anchorFn]) => [slotName, anchorFn.recipeFn(props)])),
778
+ }))` : outdent`
1058
779
  const ${baseName}SlotFns = /* @__PURE__ */ ${baseName}SlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName))])
1059
780
 
1060
781
  const ${baseName}Fn = memo((props = {}) => {
1061
782
  return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]))
1062
- })
783
+ })`}
1063
784
 
1064
785
  const ${baseName}VariantKeys = ${stringify$2(Object.keys(variantKeyMap))}
1065
786
  const getVariantProps = (variants) => ({ ...${baseName}DefaultVariants, ...compact(variants) })
@@ -1068,15 +789,25 @@ function generateRecipes(ctx, filters) {
1068
789
  __recipe__: false,
1069
790
  __name__: '${baseName}',
1070
791
  raw: (props) => props,
1071
- classNameMap: {},
792
+ /** Each slot's constant class, for targeting a slot in the DOM. */
793
+ classNameMap: /* @__PURE__ */ Object.fromEntries(${baseName}SlotNames),
794
+ /** The slots that enclose other slots, and so anchor their variant rules. */
795
+ scopeRoots: ${JSON.stringify(anchors)},
1072
796
  variantKeys: ${baseName}VariantKeys,
1073
797
  variantMap: ${stringify$2(variantKeyMap)},
798
+ /** Which slots each variant actually reaches, for a slot a scope cannot get to. */
799
+ slotsAffectedBy: ${stringify$2(slotsAffectedBy)},
1074
800
  splitVariantProps(props) {
1075
801
  return splitProps(props, ${baseName}VariantKeys)
1076
802
  },
1077
- getVariantProps
803
+ getVariantProps,
804
+ ${anchors.length ? outdent`
805
+ ...Object.fromEntries(${baseName}AnchorFns.map(([slotName, anchorFn]) => [slotName, anchorFn.recipeFn])),
806
+ ...${baseName}StaticSlots,
807
+ ` : ""}
1078
808
  })
1079
- `).otherwise((config) => outdent`
809
+ `;
810
+ }).otherwise((config) => outdent`
1080
811
  ${ctx.file.import("memo, splitProps", "../helpers")}
1081
812
  ${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
1082
813
 
@@ -1133,6 +864,13 @@ function generateRecipes(ctx, filters) {
1133
864
  variantKeys: Array<keyof ${upperName}Variant>
1134
865
  splitVariantProps<Props extends ${upperName}VariantProps>(props: Props): [${upperName}VariantProps, Pretty<DistributiveOmit<Props, keyof ${upperName}VariantProps>>]
1135
866
  getVariantProps: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
867
+ ${Recipes.isSlotRecipeConfig(config) ? outdent`
868
+ /** Which slots each variant writes styles for. */
869
+ slotsAffectedBy: Record<keyof ${upperName}Variant, ${upperName}Slot[]>` : ""}
870
+ ${anchorSlotNames.length ? outdent`
871
+ /** The slots that take variants — every other one is scoped by a class an anchor carries. */
872
+ ${anchorSlotNames.map((slot) => `${slot}: (props?: ${upperName}VariantProps) => string`).join("\n")}
873
+ ${slotNames.filter((slot) => !anchorSlotNames.includes(slot)).map((slot) => `${slot}: string`).join("\n")}` : ""}
1136
874
  }
1137
875
 
1138
876
  ${ctx.file.jsDocComment(description, { deprecated })}
@@ -1146,2819 +884,283 @@ function generateRecipes(ctx, filters) {
1146
884
  function generateSvaFn(ctx) {
1147
885
  return {
1148
886
  js: outdent`
1149
- ${ctx.file.import("compact, getSlotRecipes, memo, splitProps", "../helpers")}
887
+ ${ctx.file.import("compact, getRecipeIdentity, getSlotRecipes, memo, splitProps", "../helpers")}
1150
888
  ${ctx.file.import("cva", "./cva")}
1151
889
  ${ctx.file.import("cx", "./cx")}
1152
890
 
1153
891
  export function sva(config) {
1154
- const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
892
+ // Named before the split, so each slot's class is \`name__slot\`. Left to
893
+ // \`getSlotRecipes\`, a config with no \`className\` gives every slot the bare slot name
894
+ // — \`root\` — which every other anonymous recipe with a \`root\` slot would share. The
895
+ // build injects the identity at the same point, for the same reason.
896
+ const name = getRecipeIdentity(config, 'sva')
897
+ const withName = { ...config, className: config.className ?? name }
898
+
899
+ const slots = Object.entries(getSlotRecipes(withName)).map(([slot, slotCva]) => [slot, cva(slotCva)])
1155
900
  const defaultVariants = config.defaultVariants ?? {}
1156
901
 
902
+ // Populated whether or not the author set a \`className\`. Every slot recipe is given
903
+ // one before the split — the identity when the config declares none — so the guard
904
+ // that used to sit here left an anonymous \`sva\` reporting no slot classes despite
905
+ // emitting them.
1157
906
  const classNameMap = slots.reduce((acc, [slot, cvaFn]) => {
1158
- if (config.className) acc[slot] = cvaFn.config.className
907
+ acc[slot] = cvaFn.config.className
1159
908
  return acc
1160
909
  }, {})
1161
910
 
1162
- function svaFn(props) {
1163
- const result = slots.map(([slot, cvaFn]) => [slot, cx(cvaFn(props), classNameMap[slot])])
1164
- return Object.fromEntries(result)
1165
- }
1166
-
1167
- function raw(props) {
1168
- const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
1169
- return Object.fromEntries(result)
1170
- }
1171
-
1172
- const variants = config.variants ?? {};
1173
- const variantKeys = Object.keys(variants);
1174
-
1175
- function splitVariantProps(props) {
1176
- return splitProps(props, variantKeys);
1177
- }
1178
- const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
1179
-
1180
- const variantMap = Object.fromEntries(
1181
- Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
1182
- );
1183
-
1184
- return Object.assign(memo(svaFn), {
1185
- __cva__: false,
1186
- raw,
1187
- config,
1188
- variantMap,
1189
- variantKeys,
1190
- classNameMap,
1191
- splitVariantProps,
1192
- getVariantProps,
1193
- })
1194
- }
1195
- `,
1196
- dts: outdent`
1197
- ${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
1198
-
1199
- export declare const sva: SlotRecipeCreatorFn
1200
- `
1201
- };
1202
- }
1203
- //#endregion
1204
- //#region src/artifacts/js/token.ts
1205
- function generateTokenJs(ctx) {
1206
- const { tokens } = ctx;
1207
- const map = /* @__PURE__ */ new Map();
1208
- tokens.allTokens.forEach((token) => {
1209
- const { varRef, isVirtual } = token.extensions;
1210
- const value = isVirtual || token.extensions.condition !== "base" ? varRef : token.value;
1211
- map.set(token.name, {
1212
- value,
1213
- variable: varRef
1214
- });
1215
- });
1216
- const obj = Object.fromEntries(map);
1217
- return {
1218
- js: outdent$1`
1219
- const tokens = ${JSON.stringify(obj, null, 2)}
1220
-
1221
- export function token(path, fallback) {
1222
- return tokens[path]?.value || fallback
1223
- }
1224
-
1225
- function tokenVar(path, fallback) {
1226
- return tokens[path]?.variable || fallback
1227
- }
1228
-
1229
- token.var = tokenVar
1230
- `,
1231
- dts: outdent$1`
1232
- ${ctx.file.importType("Token", "./tokens")}
1233
-
1234
- export declare const token: {
1235
- (path: Token, fallback?: string): string
1236
- var: (path: Token, fallback?: string) => string
1237
- }
1238
-
1239
- ${ctx.file.exportTypeStar("./tokens")}
1240
- `
1241
- };
1242
- }
1243
- //#endregion
1244
- //#region src/artifacts/preact-jsx/jsx.ts
1245
- function generatePreactJsxFactory(ctx) {
1246
- const { factoryName, componentName } = ctx.jsx;
1247
- return { js: outdent`
1248
- import { h } from 'preact'
1249
- import { forwardRef } from 'preact/compat'
1250
- ${ctx.file.import("defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName", "./factory-helper")}
1251
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1252
- ${ctx.file.import("css, cx, cva", "../css/index")}
1253
- ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1254
-
1255
- function styledFn(Dynamic, configOrCva = {}, options = {}) {
1256
- const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1257
-
1258
- const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1259
- const shouldForwardProp = (prop) => {
1260
- if (options.forwardProps?.includes(prop)) return true
1261
- return forwardFn(prop, cvaFn.variantKeys)
1262
- }
1263
-
1264
- const defaultProps = Object.assign(
1265
- options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1266
- options.defaultProps,
1267
- )
1268
-
1269
- const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1270
- const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1271
- const __base__ = Dynamic.__base__ || Dynamic
1272
-
1273
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1274
- const { as: Element = __base__, unstyled, children, ...restProps } = props
1275
-
1276
-
1277
- // Not memoized, deliberately. \`restProps\` is rest destructuring, so it is a fresh
1278
- // object on every render and a dependency on it can never match — a memo here is a
1279
- // guaranteed miss that still costs a hook slot, a deps array and a retained cell.
1280
- const combinedProps = Object.assign({}, defaultProps, restProps)
1281
-
1282
- const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] =
1283
- splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
1284
-
1285
- function recipeClass() {
1286
- const { css: cssStyles, ...propStyles } = styleProps
1287
- const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
1288
- return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1289
- }
1290
-
1291
- function cvaClass() {
1292
- const { css: cssStyles, ...propStyles } = styleProps
1293
- const cvaStyles = __cvaFn__.raw(variantProps)
1294
- return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, combinedProps.className)
1295
- }
1296
-
1297
- const classes = () => {
1298
- if (unstyled) {
1299
- const { css: cssStyles, ...propStyles } = styleProps
1300
- return cx(css(propStyles, cssStyles), combinedProps.class, combinedProps.className)
1301
- }
1302
- return configOrCva.__recipe__ ? recipeClass() : cvaClass()
1303
- }
1304
-
1305
- return h(Element, {
1306
- ...forwardedProps,
1307
- ...elementProps,
1308
- ...normalizeHTMLProps(htmlProps),
1309
- ref,
1310
- className: classes()
1311
- }, children ?? combinedProps.children)
1312
- })
1313
-
1314
- const name = getDisplayName(__base__)
1315
-
1316
- ${componentName}.displayName = \`${factoryName}.\${name}\`
1317
- ${componentName}.__cva__ = __cvaFn__
1318
- ${componentName}.__base__ = __base__
1319
- ${componentName}.__shouldForwardProps__ = shouldForwardProp
1320
-
1321
- return ${componentName}
1322
- }
1323
-
1324
- function createJsxFactory() {
1325
- const cache = new Map()
1326
-
1327
- return new Proxy(styledFn, {
1328
- apply(_, __, args) {
1329
- return styledFn(...args)
1330
- },
1331
- get(_, el) {
1332
- if (!cache.has(el)) {
1333
- cache.set(el, styledFn(el))
1334
- }
1335
- return cache.get(el)
1336
- },
1337
- })
1338
- }
1339
-
1340
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
1341
- ` };
1342
- }
1343
- //#endregion
1344
- //#region src/artifacts/preact-jsx/pattern.ts
1345
- function generatePreactJsxPattern(ctx, filters) {
1346
- const { typeName, factoryName, styleProps: jsxStyleProps } = ctx.jsx;
1347
- return ctx.patterns.filterDetails(filters).map((pattern) => {
1348
- const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
1349
- const { description, jsxElement = "div", deprecated } = pattern.config;
1350
- return {
1351
- name: dashName,
1352
- js: outdent`
1353
- import { h } from 'preact'
1354
- import { forwardRef } from 'preact/compat'
1355
- ${jsxStyleProps === "minimal" ? ctx.file.import("mergeCss", "../css/css") : ""}
1356
- ${ctx.file.import("splitProps", "../helpers")}
1357
- ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1358
- ${ctx.file.import(factoryName, "./factory")}
1359
-
1360
- export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
1361
- ${match(jsxStyleProps).with("none", () => outdent`
1362
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1363
-
1364
- const styleProps = ${styleFnName}(patternProps)
1365
- const mergedProps = { ref, ...restProps, css: styleProps }
1366
-
1367
- return h(${factoryName}.${jsxElement}, mergedProps)
1368
- `).with("minimal", () => outdent`
1369
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1370
-
1371
- const styleProps = ${styleFnName}(patternProps)
1372
- const cssProps = { css: mergeCss(styleProps, props.css) }
1373
- const mergedProps = { ref, ...restProps, ...cssProps }
1374
-
1375
- return h(${factoryName}.${jsxElement}, mergedProps)
1376
- `).with("all", () => outdent`
1377
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1378
-
1379
- const styleProps = ${styleFnName}(patternProps)
1380
- const mergedProps = { ref, ...styleProps, ...restProps }
1381
-
1382
- return h(${factoryName}.${jsxElement}, mergedProps)
1383
- `).exhaustive()}
1384
- })
1385
- `,
1386
- dts: outdent`
1387
- import type { FunctionComponent } from 'preact'
1388
- ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1389
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
1390
- ${ctx.file.importType(typeName, "../types/jsx")}
1391
-
1392
- export interface ${upperName}Props extends ${upperName}Properties, DistributiveOmit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}> {}
1393
-
1394
- ${ctx.file.jsDocComment(description, { deprecated })}
1395
- export declare const ${jsxName}: FunctionComponent<${upperName}Props>
1396
- `
1397
- };
1398
- });
1399
- }
1400
- //#endregion
1401
- //#region src/artifacts/preact-jsx/types.ts
1402
- function generatePreactJsxTypes(ctx) {
1403
- const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1404
- return {
1405
- jsxFactory: outdent`
1406
- import type { ${upperName} } from '../types/jsx'
1407
- export declare const ${factoryName}: ${upperName}
1408
- `,
1409
- jsxType: outdent`
1410
- import type { ComponentProps, JSX } from 'preact'
1411
- ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1412
- ${ctx.file.importType("Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty", "./system-types")}
1413
-
1414
- export type ElementType = JSX.ElementType
1415
-
1416
- interface Dict {
1417
- [k: string]: unknown
1418
- }
1419
-
1420
- export type DataAttrs = Record<\`data-\${string}\`, unknown>
1421
-
1422
- export interface UnstyledProps {
1423
- /**
1424
- * Whether to remove recipe styles
1425
- */
1426
- unstyled?: boolean | undefined
1427
- }
1428
-
1429
- export interface AsProps {
1430
- /**
1431
- * The element to render as
1432
- */
1433
- as?: ElementType | undefined
1434
- }
1435
-
1436
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
1437
- (props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>): JSX.Element
1438
- displayName?: string | undefined
1439
- }
1440
-
1441
- interface RecipeFn {
1442
- __type: any
1443
- }
1444
-
1445
- export interface JsxFactoryOptions<TProps extends Dict> {
1446
- dataAttr?: boolean
1447
- defaultProps?: Partial<TProps> & DataAttrs
1448
- shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
1449
- forwardProps?: string[]
1450
- }
1451
-
1452
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, P>
1453
-
1454
- export type JsxElement<T extends ElementType, P extends Dict> = T extends ${componentName}<infer A, infer B>
1455
- ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1456
- : ${componentName}<T, P>
1457
-
1458
- export interface JsxFactory {
1459
- <T extends ElementType>(component: T): ${componentName}<T, {}>
1460
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1461
- T,
1462
- RecipeSelection<P>
1463
- >
1464
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1465
- }
1466
-
1467
- export type JsxElements = {
1468
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
1469
- }
1470
-
1471
- export type ${upperName} = JsxFactory & JsxElements
1472
-
1473
- export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
1474
-
1475
- export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1476
- `
1477
- };
1478
- }
1479
- //#endregion
1480
- //#region src/artifacts/preact-jsx/create-style-context.ts
1481
- function generatePreactCreateStyleContext(ctx) {
1482
- const { factoryName } = ctx.jsx;
1483
- return {
1484
- js: outdent`
1485
- ${ctx.file.import("cx, css, sva", "../css/index")}
1486
- ${ctx.file.import(factoryName, "./factory")}
1487
- ${ctx.file.import("getDisplayName", "./factory-helper")}
1488
- import { createContext } from 'preact'
1489
- import { useContext } from 'preact/hooks'
1490
- import { createElement, forwardRef } from 'preact/compat'
1491
-
1492
- function createSafeContext(contextName) {
1493
- const Context = createContext(undefined)
1494
- const useStyleContext = (componentName, slot) => {
1495
- const context = useContext(Context)
1496
- if (context === undefined) {
1497
- const componentInfo = componentName ? \`Component "\${componentName}"\` : 'A component'
1498
- const slotInfo = slot ? \` (slot: "\${slot}")\` : ''
1499
-
1500
- throw new Error(
1501
- \`\${componentInfo}\${slotInfo} cannot access \${contextName} because it's missing its Provider.\`
1502
- )
1503
- }
1504
- return context
1505
- }
1506
- return [Context, useStyleContext]
1507
- }
1508
-
1509
- export function createStyleContext(recipe) {
1510
- const isConfigRecipe = '__recipe__' in recipe
1511
- const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined
1512
- const contextName = recipeName ? \`createStyleContext("\${recipeName}")\` : 'createStyleContext'
1513
-
1514
- const [StyleContext, useStyleContext] = createSafeContext(contextName)
1515
- const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
1516
-
1517
- const getResolvedProps = (props, slotStyles) => {
1518
- const { unstyled, ...restProps } = props
1519
- if (unstyled) return restProps
1520
- if (isConfigRecipe) {
1521
- return { ...restProps, className: cx(slotStyles, restProps.className) }
1522
- }
1523
- ${outdent.string(match(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`))}
1524
- }
1525
-
1526
- const withRootProvider = (Component, options) => {
1527
- const WithRootProvider = (props) => {
1528
- const [variantProps, otherProps] = svaFn.splitVariantProps(props)
1529
-
1530
- const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
1531
- slotStyles._classNameMap = svaFn.classNameMap
1532
-
1533
- const mergedProps = options?.defaultProps
1534
- ? { ...options.defaultProps, ...otherProps }
1535
- : otherProps
1536
-
1537
- return createElement(StyleContext.Provider, {
1538
- value: slotStyles,
1539
- children: createElement(Component, mergedProps)
1540
- })
1541
- }
1542
-
1543
- const componentName = getDisplayName(Component)
1544
- WithRootProvider.displayName = \`withRootProvider(\${componentName})\`
1545
-
1546
- return WithRootProvider
1547
- }
1548
-
1549
- const withProvider = (Component, slot, options) => {
1550
- const StyledComponent = ${factoryName}(Component, {}, options)
1551
-
1552
- const WithProvider = forwardRef(function WithProvider(props, ref) {
1553
- const [variantProps, restProps] = svaFn.splitVariantProps(props)
1554
-
1555
- const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
1556
- slotStyles._classNameMap = svaFn.classNameMap
1557
-
1558
- const propsWithClass = { ...restProps, className: restProps.className ?? options?.defaultProps?.className }
1559
- const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
1560
- return createElement(StyleContext.Provider, {
1561
- value: slotStyles,
1562
- children: createElement(StyledComponent, {
1563
- ...resolvedProps,
1564
- className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
1565
- ref,
1566
- })
1567
- })
1568
- })
1569
-
1570
- const componentName = getDisplayName(Component)
1571
- WithProvider.displayName = \`withProvider(\${componentName})\`
1572
-
1573
- return WithProvider
1574
- }
1575
-
1576
- const withContext = (Component, slot, options) => {
1577
- const StyledComponent = ${factoryName}(Component, {}, options)
1578
- const componentName = getDisplayName(Component)
1579
-
1580
- const WithContext = forwardRef(function WithContext(props, ref) {
1581
- const slotStyles = useStyleContext(componentName, slot)
1582
-
1583
- const propsWithClass = { ...props, className: props.className ?? options?.defaultProps?.className }
1584
- const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
1585
- return createElement(StyledComponent, {
1586
- ...resolvedProps,
1587
- className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
1588
- ref,
1589
- })
1590
- })
1591
-
1592
- WithContext.displayName = \`withContext(\${componentName})\`
1593
-
1594
- return WithContext
1595
- }
1596
-
1597
- return {
1598
- withRootProvider,
1599
- withProvider,
1600
- withContext,
1601
- }
1602
- }
1603
- `,
1604
- dts: outdent`
1605
- ${ctx.file.importType("SlotRecipeRuntimeFn, RecipeVariantProps", "../types/recipe")}
1606
- ${ctx.file.importType("JsxHTMLProps, JsxStyleProps, Assign", "../types/system-types")}
1607
- ${ctx.file.importType("JsxFactoryOptions, DataAttrs, AsProps", "../types/jsx")}
1608
- import type { ComponentType, ComponentProps, JSX } from 'preact/compat'
1609
-
1610
- interface UnstyledProps {
1611
- unstyled?: boolean | undefined
1612
- }
1613
-
1614
- interface WithProviderOptions<P = {}> {
1615
- defaultProps?: (Partial<P> & DataAttrs) | undefined
1616
- }
1617
-
1618
- type ElementType = JSX.ElementType
1619
-
1620
- type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
1621
- interface SlotRecipeFn {
1622
- __type: any
1623
- __slot: string
1624
- (props?: any): any
1625
- }
1626
- type SlotRecipe = SvaFn | SlotRecipeFn
1627
-
1628
- type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
1629
-
1630
- type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
1631
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
1632
- >
1633
-
1634
- type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
1635
- ComponentProps<T> & UnstyledProps & RecipeVariantProps<R>
1636
- >
1637
-
1638
- type StyleContextConsumer<T extends ElementType> = ComponentType<
1639
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
1640
- >
1641
-
1642
- export interface StyleContext<R extends SlotRecipe> {
1643
- withRootProvider: <T extends ElementType>(
1644
- Component: T,
1645
- options?: WithProviderOptions<ComponentProps<T>> | undefined
1646
- ) => StyleContextRootProvider<T, R>
1647
- withProvider: <T extends ElementType>(
1648
- Component: T,
1649
- slot: InferSlot<R>,
1650
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
1651
- ) => StyleContextProvider<T, R>
1652
- withContext: <T extends ElementType>(
1653
- Component: T,
1654
- slot: InferSlot<R>,
1655
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
1656
- ) => StyleContextConsumer<T>
1657
- }
1658
-
1659
- export declare function createStyleContext<R extends SlotRecipe>(recipe: R): StyleContext<R>
1660
- `
1661
- };
1662
- }
1663
- //#endregion
1664
- //#region src/artifacts/preact-jsx/jsx.string-literal.ts
1665
- function generatePreactJsxStringLiteralFactory(ctx) {
1666
- const { factoryName, componentName } = ctx.jsx;
1667
- return { js: outdent`
1668
- import { h } from 'preact'
1669
- import { forwardRef } from 'preact/compat'
1670
- ${ctx.file.import("getDisplayName", "./factory-helper")}
1671
- ${ctx.file.import("css, cx", "../css/index")}
1672
-
1673
- function createStyledFn(Dynamic) {
1674
- const __base__ = Dynamic.__base__ || Dynamic
1675
- return function styledFn(template) {
1676
- const styles = css.raw(Dynamic.__styles__, template)
1677
-
1678
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
1679
- const { as: Element = __base__, ...elementProps } = props
1680
-
1681
- function classes() {
1682
- return cx(css(styles), elementProps.className)
1683
- }
1684
-
1685
- return h(Element, {
1686
- ref,
1687
- ...elementProps,
1688
- className: classes(),
1689
- })
1690
- })
1691
-
1692
- const name = getDisplayName(__base__)
1693
-
1694
- ${componentName}.displayName = \`${factoryName}.\${name}\`
1695
- ${componentName}.__styles__ = styles
1696
- ${componentName}.__base__ = __base__
1697
-
1698
- return ${componentName}
1699
- }
1700
- }
1701
-
1702
- function createJsxFactory() {
1703
- const cache = new Map()
1704
-
1705
- return new Proxy(createStyledFn, {
1706
- apply(_, __, args) {
1707
- return createStyledFn(...args)
1708
- },
1709
- get(_, el) {
1710
- if (!cache.has(el)) {
1711
- cache.set(el, createStyledFn(el))
1712
- }
1713
- return cache.get(el)
1714
- },
1715
- })
1716
- }
1717
-
1718
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
1719
- ` };
1720
- }
1721
- //#endregion
1722
- //#region src/artifacts/preact-jsx/types.string-literal.ts
1723
- function generatePreactJsxStringLiteralTypes(ctx) {
1724
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1725
- return {
1726
- jsxFactory: outdent`
1727
- ${ctx.file.importType(upperName, "../types/jsx")}
1728
- export declare const ${factoryName}: ${upperName}
1729
- `,
1730
- jsxType: outdent`
1731
- import type { ComponentProps, JSX } from 'preact'
1732
-
1733
- export type ElementType = JSX.ElementType
1734
-
1735
- interface Dict {
1736
- [k: string]: unknown
1737
- }
1738
-
1739
- export interface AsProps {
1740
- /**
1741
- * The element to render as
1742
- */
1743
- as?: ElementType | undefined
1744
- }
1745
-
1746
- export type ${componentName}<T extends ElementType> = {
1747
- (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T> & AsProps) => JSX.Element
1748
- displayName?: string | undefined
1749
- }
1750
-
1751
- export interface JsxFactory {
1752
- <T extends ElementType>(component: T): ${componentName}<T>
1753
- }
1754
-
1755
- export type JsxElements = {
1756
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
1757
- }
1758
-
1759
- export type ${upperName} = JsxFactory & JsxElements
1760
-
1761
- export type ${typeName}<T extends ElementType> = ComponentProps<T>
1762
- `
1763
- };
1764
- }
1765
- //#endregion
1766
- //#region src/artifacts/qwik-jsx/jsx.ts
1767
- function generateQwikJsxFactory(ctx) {
1768
- const { factoryName, componentName } = ctx.jsx;
1769
- return { js: outdent`
1770
- import { h } from '@builder.io/qwik'
1771
- ${ctx.file.import("defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName", "./factory-helper")}
1772
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
1773
- ${ctx.file.import("css, cx, cva", "../css/index")}
1774
- ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
1775
-
1776
- function styledFn(Dynamic, configOrCva = {}, options = {}) {
1777
- const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
1778
-
1779
- const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
1780
- const shouldForwardProp = (prop) => {
1781
- if (options.forwardProps?.includes(prop)) return true
1782
- return forwardFn(prop, cvaFn.variantKeys)
1783
- }
1784
-
1785
- const defaultProps = Object.assign(
1786
- options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
1787
- options.defaultProps,
1788
- )
1789
-
1790
- const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
1791
- const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
1792
- const __base__ = Dynamic.__base__ || Dynamic
1793
-
1794
- const ${componentName} = function ${componentName}(props) {
1795
- const { as: Element = __base__, unstyled, children, className, ...restProps } = props
1796
-
1797
- const combinedProps = Object.assign({}, defaultProps, restProps)
1798
-
1799
- const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] =
1800
- splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
1801
-
1802
- const { css: cssStyles, ...propStyles } = styleProps
1803
-
1804
- function recipeClass() {
1805
- const { css: cssStyles, ...propStyles } = styleProps
1806
- const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
1807
- return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.class, className)
1808
- }
1809
-
1810
- function cvaClass() {
1811
- const { css: cssStyles, ...propStyles } = styleProps
1812
- const cvaStyles = __cvaFn__.raw(variantProps)
1813
- return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.class, className)
1814
- }
1815
-
1816
- const classes = () => {
1817
- if (unstyled) {
1818
- const { css: cssStyles, ...propStyles } = styleProps
1819
- return cx(css(propStyles, cssStyles), combinedProps.class, className)
1820
- }
1821
- return configOrCva.__recipe__ ? recipeClass() : cvaClass()
1822
- }
1823
-
1824
- return h(Element, {
1825
- ...forwardedProps,
1826
- ...elementProps,
1827
- ...normalizeHTMLProps(htmlProps),
1828
- class: classes(),
1829
- }, children ?? combinedProps.children)
1830
- }
1831
-
1832
- const name = getDisplayName(__base__)
1833
-
1834
- ${componentName}.displayName = \`${factoryName}.\${name}\`
1835
- ${componentName}.__cva__ = __cvaFn__
1836
- ${componentName}.__base__ = __base__
1837
- ${componentName}.__shouldForwardProps__ = shouldForwardProp
1838
-
1839
- return ${componentName}
1840
- }
1841
-
1842
- function createJsxFactory() {
1843
- const cache = new Map()
1844
-
1845
- return new Proxy(styledFn, {
1846
- apply(_, __, args) {
1847
- return styledFn(...args)
1848
- },
1849
- get(_, el) {
1850
- if (!cache.has(el)) {
1851
- cache.set(el, styledFn(el))
1852
- }
1853
- return cache.get(el)
1854
- },
1855
- })
1856
- }
1857
-
1858
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
1859
-
1860
- ` };
1861
- }
1862
- //#endregion
1863
- //#region src/artifacts/qwik-jsx/pattern.ts
1864
- function generateQwikJsxPattern(ctx, filters) {
1865
- const { typeName, factoryName, styleProps: jsxStyleProps } = ctx.jsx;
1866
- return ctx.patterns.filterDetails(filters).map((pattern) => {
1867
- const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
1868
- const { description, jsxElement = "div", deprecated } = pattern.config;
1869
- return {
1870
- name: dashName,
1871
- js: outdent`
1872
- import { h } from '@builder.io/qwik'
1873
- ${jsxStyleProps === "minimal" ? ctx.file.import("mergeCss", "../css/css") : ""}
1874
- ${ctx.file.import("splitProps", "../helpers")}
1875
- ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
1876
- ${ctx.file.import(factoryName, "./factory")}
1877
-
1878
- export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
1879
- ${match(jsxStyleProps).with("none", () => outdent`
1880
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1881
-
1882
- const styleProps = ${styleFnName}(patternProps)
1883
- const mergedProps = { ref, ...restProps, css: styleProps }
1884
-
1885
- return h(${factoryName}.${jsxElement}, mergedProps)
1886
- `).with("minimal", () => outdent`
1887
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1888
-
1889
- const styleProps = ${styleFnName}(patternProps)
1890
- const cssProps = { css: mergeCss(styleProps, props.css) }
1891
- const mergedProps = { ...restProps, ...cssProps }
1892
-
1893
- return h(${factoryName}.${jsxElement}, mergedProps)
1894
- `).with("all", () => outdent`
1895
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
1896
-
1897
- const styleProps = ${styleFnName}(patternProps)
1898
- const mergedProps = { ...styleProps, ...restProps }
1899
-
1900
- return h(${factoryName}.${jsxElement}, mergedProps)
1901
- `).exhaustive()}
1902
- }
1903
- `,
1904
- dts: outdent`
1905
- import type { Component } from '@builder.io/qwik'
1906
- ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
1907
- ${ctx.file.importType(typeName, "../types/jsx")}
1908
- ${ctx.file.importType("Assign, DistributiveOmit", "../types/system-types")}
1909
-
1910
- export interface ${upperName}Props extends Assign<${typeName}<'${jsxElement}'>, DistributiveOmit<${upperName}Properties, ${blocklistType || "\"\""}>> {}
1911
-
1912
- ${ctx.file.jsDocComment(description, { deprecated })}
1913
- export declare const ${jsxName}: Component<${upperName}Props>
1914
- `
1915
- };
1916
- });
1917
- }
1918
- //#endregion
1919
- //#region src/artifacts/qwik-jsx/types.ts
1920
- function generateQwikJsxTypes(ctx) {
1921
- const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
1922
- return {
1923
- jsxFactory: outdent`
1924
- ${ctx.file.importType(upperName, "../types/jsx")}
1925
- export declare const ${factoryName}: ${upperName}
1926
- `,
1927
- jsxType: outdent`
1928
- import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
1929
- ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
1930
- ${ctx.file.importType("Assign, DistributiveOmit, DistributiveUnion, JsxStyleProps, PatchedHTMLProps, Pretty", "./system-types")}
1931
-
1932
- export type ElementType = keyof QwikIntrinsicElements | Component<any>
1933
-
1934
- export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
1935
- ? QwikIntrinsicElements[T]
1936
- : T extends Component<infer P>
1937
- ? P
1938
- : never
1939
-
1940
- interface Dict {
1941
- [k: string]: unknown
1942
- }
1943
-
1944
- export type DataAttrs = Record<\`data-\${string}\`, unknown>
1945
-
1946
- export interface UnstyledProps {
1947
- /**
1948
- * Whether to remove recipe styles
1949
- */
1950
- unstyled?: boolean | undefined
1951
- }
1952
-
1953
- export interface AsProps {
1954
- /**
1955
- * The element to render as
1956
- */
1957
- as?: ElementType | undefined
1958
- }
1959
-
1960
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends Component<Assign<ComponentProps<T> & UnstyledProps & AsProps, Assign<PatchedHTMLProps, Assign<JsxStyleProps, P>>>> {}
1961
-
1962
- interface RecipeFn {
1963
- __type: any
1964
- }
1965
-
1966
- export interface JsxFactoryOptions<TProps extends Dict> {
1967
- dataAttr?: boolean
1968
- defaultProps?: Partial<TProps> & DataAttrs
1969
- shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
1970
- forwardProps?: string[]
1971
- }
1972
-
1973
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, P>;
1974
-
1975
- export type JsxElement<T extends ElementType, P extends Dict> = T extends ${componentName}<infer A, infer B>
1976
- ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
1977
- : ${componentName}<T, P>
1978
-
1979
- export interface JsxFactory {
1980
- <T extends ElementType>(component: T): ${componentName}<T, {}>
1981
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
1982
- T,
1983
- RecipeSelection<P>
1984
- >
1985
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
1986
- }
1987
-
1988
- export type JsxElements = {
1989
- [K in keyof QwikIntrinsicElements]: ${componentName}<K, {}>
1990
- }
1991
-
1992
- export type ${upperName} = JsxFactory & JsxElements
1993
-
1994
- export type ${typeName}<T extends ElementType> = Assign<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
1995
-
1996
- export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
1997
- `
1998
- };
1999
- }
2000
- //#endregion
2001
- //#region src/artifacts/qwik-jsx/jsx.string-literal.ts
2002
- function generateQwikJsxStringLiteralFactory(ctx) {
2003
- const { factoryName, componentName } = ctx.jsx;
2004
- return { js: outdent`
2005
- import { h } from '@builder.io/qwik'
2006
- ${ctx.file.import("getDisplayName", "./factory-helper")}
2007
- ${ctx.file.import("css, cx", "../css/index")}
2008
-
2009
- function createStyledFn(Dynamic) {
2010
- const __base__ = Dynamic.__base__ || Dynamic
2011
- return function styledFn(template) {
2012
- const styles = css.raw(Dynamic.__styles__, template)
2013
-
2014
- const ${componentName} = (props) => {
2015
- const { as: Element = __base__, ...elementProps } = props
2016
-
2017
- function classes() {
2018
- return cx(css(styles), elementProps.className)
2019
- }
2020
-
2021
- return h(Element, {
2022
- ...elementProps,
2023
- className: classes(),
2024
- })
2025
- }
2026
-
2027
- const name = getDisplayName(__base__)
2028
-
2029
- ${componentName}.displayName = \`${factoryName}.\${name}\`
2030
- ${componentName}.__styles__ = styles
2031
- ${componentName}.__base__ = __base__
2032
-
2033
- return ${componentName}
2034
- }
2035
- }
2036
-
2037
- function createJsxFactory() {
2038
- const cache = new Map()
2039
-
2040
- return new Proxy(createStyledFn, {
2041
- apply(_, __, args) {
2042
- return createStyledFn(...args)
2043
- },
2044
- get(_, el) {
2045
- if (!cache.has(el)) {
2046
- cache.set(el, createStyledFn(el))
2047
- }
2048
- return cache.get(el)
2049
- },
2050
- })
2051
- }
2052
-
2053
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2054
-
2055
- ` };
2056
- }
2057
- //#endregion
2058
- //#region src/artifacts/qwik-jsx/types.string-literal.ts
2059
- function generateQwikJsxStringLiteralTypes(ctx) {
2060
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2061
- return {
2062
- jsxFactory: outdent`
2063
- ${ctx.file.importType(upperName, "../types/jsx")}
2064
- export declare const ${factoryName}: ${upperName}
2065
- `,
2066
- jsxType: outdent`
2067
- import type { Component, QwikIntrinsicElements } from '@builder.io/qwik'
2068
-
2069
- export type ElementType = keyof QwikIntrinsicElements | Component<any>
2070
-
2071
- export type ComponentProps<T extends ElementType> = T extends keyof QwikIntrinsicElements
2072
- ? QwikIntrinsicElements[T]
2073
- : T extends Component<infer P>
2074
- ? P
2075
- : never
2076
-
2077
- interface Dict {
2078
- [k: string]: unknown
2079
- }
2080
-
2081
- export interface AsProps {
2082
- /**
2083
- * The element to render as
2084
- */
2085
- as?: ElementType | undefined
2086
- }
2087
-
2088
- export type ${componentName}<T extends ElementType> = {
2089
- (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T> & AsProps) => JSX.Element
2090
- }
2091
-
2092
- export interface JsxFactory {
2093
- <T extends ElementType>(component: T): ${componentName}<T>
2094
- }
2095
-
2096
- export type JsxElements = {
2097
- [K in keyof QwikIntrinsicElements]: ${componentName}<K>
2098
- }
2099
-
2100
- export type ${upperName} = JsxFactory & JsxElements
2101
-
2102
- export type ${typeName}<T extends ElementType> = ComponentProps<T>
2103
- `
2104
- };
2105
- }
2106
- //#endregion
2107
- //#region src/artifacts/react-jsx/jsx.ts
2108
- function generateReactJsxFactory(ctx) {
2109
- const { factoryName, componentName } = ctx.jsx;
2110
- return { js: outdent`
2111
- import { createElement, forwardRef } from 'react'
2112
- ${ctx.file.import("css, cx, cva", "../css/index")}
2113
- ${ctx.file.import("defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName", "./factory-helper")}
2114
- ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
2115
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2116
-
2117
- function styledFn(Dynamic, configOrCva = {}, options = {}) {
2118
- const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
2119
-
2120
- const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2121
- const shouldForwardProp = (prop) => {
2122
- if (options.forwardProps?.includes(prop)) return true
2123
- return forwardFn(prop, cvaFn.variantKeys)
2124
- }
2125
-
2126
- const defaultProps = Object.assign(
2127
- options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
2128
- options.defaultProps,
2129
- )
2130
-
2131
- const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
2132
- const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
2133
- const __base__ = Dynamic.__base__ || Dynamic
2134
-
2135
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
2136
- const { as: Element = __base__, unstyled, children, ...restProps } = props
2137
-
2138
- // Not memoized, deliberately. \`restProps\` is rest destructuring, so it is a fresh
2139
- // object on every render and a dependency on it can never match — a memo here is a
2140
- // guaranteed miss that still costs a hook slot, a deps array and a retained cell.
2141
- const combinedProps = Object.assign({}, defaultProps, restProps)
2142
-
2143
- const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] =
2144
- splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
2145
-
2146
- function recipeClass() {
2147
- const { css: cssStyles, ...propStyles } = styleProps
2148
- const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
2149
- return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
2150
- }
2151
-
2152
- function cvaClass() {
2153
- const { css: cssStyles, ...propStyles } = styleProps
2154
- const cvaStyles = __cvaFn__.raw(variantProps)
2155
- return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
2156
- }
2157
-
2158
- const classes = () => {
2159
- if (unstyled) {
2160
- const { css: cssStyles, ...propStyles } = styleProps
2161
- return cx(css(propStyles, cssStyles), combinedProps.className)
2162
- }
2163
- return configOrCva.__recipe__ ? recipeClass() : cvaClass()
2164
- }
2165
-
2166
- return createElement(Element, {
2167
- ref,
2168
- ...forwardedProps,
2169
- ...elementProps,
2170
- ...normalizeHTMLProps(htmlProps),
2171
- className: classes(),
2172
- }, children ?? combinedProps.children)
2173
- })
2174
-
2175
- const name = getDisplayName(__base__)
2176
-
2177
- ${componentName}.displayName = \`${factoryName}.\${name}\`
2178
- ${componentName}.__cva__ = __cvaFn__
2179
- ${componentName}.__base__ = __base__
2180
- ${componentName}.__shouldForwardProps__ = shouldForwardProp
2181
-
2182
- return ${componentName}
2183
- }
2184
-
2185
- function createJsxFactory() {
2186
- const cache = new Map()
2187
-
2188
- return new Proxy(styledFn, {
2189
- apply(_, __, args) {
2190
- return styledFn(...args)
2191
- },
2192
- get(_, el) {
2193
- if (!cache.has(el)) {
2194
- cache.set(el, styledFn(el))
2195
- }
2196
- return cache.get(el)
2197
- },
2198
- })
2199
- }
2200
-
2201
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2202
-
2203
- ` };
2204
- }
2205
- //#endregion
2206
- //#region src/artifacts/react-jsx/pattern.ts
2207
- function generateReactJsxPattern(ctx, filters) {
2208
- const { typeName, factoryName, styleProps: jsxStyleProps } = ctx.jsx;
2209
- return ctx.patterns.filterDetails(filters).map((pattern) => {
2210
- const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
2211
- const { description, jsxElement = "div", deprecated } = pattern.config;
2212
- return {
2213
- name: dashName,
2214
- js: outdent`
2215
- import { createElement, forwardRef } from 'react'
2216
- ${jsxStyleProps === "minimal" ? ctx.file.import("mergeCss", "../css/css") : ""}
2217
- ${ctx.file.import("splitProps", "../helpers")}
2218
- ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2219
- ${ctx.file.import(factoryName, "./factory")}
2220
-
2221
- export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
2222
- ${match(jsxStyleProps).with("none", () => outdent`
2223
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2224
-
2225
- const styleProps = ${styleFnName}(patternProps)
2226
- const mergedProps = { ref, ...restProps, css: styleProps }
2227
-
2228
- return createElement(${factoryName}.${jsxElement}, mergedProps)
2229
- `).with("minimal", () => outdent`
2230
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2231
-
2232
- const styleProps = ${styleFnName}(patternProps)
2233
- const cssProps = { css: mergeCss(styleProps, props.css) }
2234
- const mergedProps = { ref, ...restProps, ...cssProps }
2235
-
2236
- return createElement(${factoryName}.${jsxElement}, mergedProps)
2237
- `).with("all", () => outdent`
2238
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2239
-
2240
- const styleProps = ${styleFnName}(patternProps)
2241
- const mergedProps = { ref, ...styleProps, ...restProps }
2242
-
2243
- return createElement(${factoryName}.${jsxElement}, mergedProps)
2244
- `).exhaustive()}
2245
- })
2246
- `,
2247
- dts: outdent`
2248
- import type { FunctionComponent } from 'react'
2249
- ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2250
- ${ctx.file.importType(typeName, "../types/jsx")}
2251
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
2252
-
2253
- export interface ${upperName}Props extends ${upperName}Properties, DistributiveOmit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}> {}
2254
-
2255
- ${ctx.file.jsDocComment(description, { deprecated })}
2256
- export declare const ${jsxName}: FunctionComponent<${upperName}Props>
2257
- `
2258
- };
2259
- });
2260
- }
2261
- //#endregion
2262
- //#region src/artifacts/react-jsx/types.ts
2263
- function generateReactJsxTypes(ctx) {
2264
- const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2265
- return {
2266
- jsxFactory: outdent`
2267
- ${ctx.file.importType(upperName, "../types/jsx")}
2268
- export declare const ${factoryName}: ${upperName}
2269
- `,
2270
- jsxType: outdent`
2271
- import type { ElementType, JSX, ComponentPropsWithRef, ComponentType, Component } from 'react'
2272
- ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2273
- ${ctx.file.importType("Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty", "./system-types")}
2274
-
2275
- interface Dict {
2276
- [k: string]: unknown
2277
- }
2278
-
2279
- export type DataAttrs = Record<\`data-\${string}\`, unknown>
2280
-
2281
- export interface UnstyledProps {
2282
- /**
2283
- * Whether to remove recipe styles
2284
- */
2285
- unstyled?: boolean | undefined
2286
- }
2287
-
2288
- export interface AsProps {
2289
- /**
2290
- * The element to render as
2291
- */
2292
- as?: ElementType | undefined
2293
- }
2294
-
2295
- export type ComponentProps<T extends ElementType> = T extends ComponentType<infer P> | Component<infer P>
2296
- ? JSX.LibraryManagedAttributes<T, P>
2297
- : ComponentPropsWithRef<T>
2298
-
2299
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2300
- (props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>): JSX.Element
2301
- displayName?: string | undefined
2302
- }
2303
-
2304
- interface RecipeFn {
2305
- __type: any
2306
- }
2307
-
2308
- export interface JsxFactoryOptions<TProps extends Dict> {
2309
- dataAttr?: boolean
2310
- defaultProps?: Partial<TProps> & DataAttrs
2311
- shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
2312
- forwardProps?: string[]
2313
- }
2314
-
2315
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, P>;
2316
-
2317
- export type JsxElement<T extends ElementType, P extends Dict> = T extends ${componentName}<infer A, infer B>
2318
- ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2319
- : ${componentName}<T, P>
2320
-
2321
- export interface JsxFactory {
2322
- <T extends ElementType>(component: T): ${componentName}<T, {}>
2323
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2324
- T,
2325
- RecipeSelection<P>
2326
- >
2327
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
2328
- }
2329
-
2330
- export type JsxElements = {
2331
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2332
- }
2333
-
2334
- export type ${upperName} = JsxFactory & JsxElements
2335
-
2336
- export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
2337
-
2338
- export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2339
- `
2340
- };
2341
- }
2342
- //#endregion
2343
- //#region src/artifacts/react-jsx/create-style-context.ts
2344
- function generateReactCreateStyleContext(ctx) {
2345
- const { factoryName } = ctx.jsx;
2346
- return {
2347
- js: outdent`'use client'\n
2348
- ${ctx.file.import("cx, css, sva", "../css/index")}
2349
- ${ctx.file.import(factoryName, "./factory")}
2350
- ${ctx.file.import("getDisplayName", "./factory-helper")}
2351
- import { createContext, useContext, createElement, forwardRef } from 'react'
2352
-
2353
- function createSafeContext(contextName) {
2354
- const Context = createContext(undefined)
2355
- const useStyleContext = (componentName, slot) => {
2356
- const context = useContext(Context)
2357
- if (context === undefined) {
2358
- const componentInfo = componentName ? \`Component "\${componentName}"\` : 'A component'
2359
- const slotInfo = slot ? \` (slot: "\${slot}")\` : ''
2360
-
2361
- throw new Error(
2362
- \`\${componentInfo}\${slotInfo} cannot access \${contextName} because it's missing its Provider.\`
2363
- )
2364
- }
2365
- return context
2366
- }
2367
- return [Context, useStyleContext]
2368
- }
2369
-
2370
- export function createStyleContext(recipe) {
2371
- const isConfigRecipe = '__recipe__' in recipe
2372
- const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined
2373
- const contextName = recipeName ? \`createStyleContext("\${recipeName}")\` : 'createStyleContext'
2374
-
2375
- const [StyleContext, useStyleContext] = createSafeContext(contextName)
2376
- const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
2377
-
2378
- const getResolvedProps = (props, slotStyles) => {
2379
- const { unstyled, ...restProps } = props
2380
- if (unstyled) return restProps
2381
- if (isConfigRecipe) {
2382
- return { ...restProps, className: cx(slotStyles, restProps.className) }
2383
- }
2384
- ${outdent.string(match(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`))}
2385
- }
2386
-
2387
- const withRootProvider = (Component, options) => {
2388
- const WithRootProvider = (props) => {
2389
- const [variantProps, otherProps] = svaFn.splitVariantProps(props)
2390
-
2391
- const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
2392
- slotStyles._classNameMap = svaFn.classNameMap
2393
-
2394
- const mergedProps = options?.defaultProps
2395
- ? { ...options.defaultProps, ...otherProps }
2396
- : otherProps
2397
-
2398
- return createElement(StyleContext.Provider, {
2399
- value: slotStyles,
2400
- children: createElement(Component, mergedProps)
2401
- })
2402
- }
2403
-
2404
- const componentName = getDisplayName(Component)
2405
- WithRootProvider.displayName = \`withRootProvider(\${componentName})\`
2406
-
2407
- return WithRootProvider
2408
- }
2409
-
2410
- const withProvider = (Component, slot, options) => {
2411
- const StyledComponent = ${factoryName}(Component, {}, options)
2412
-
2413
- const WithProvider = forwardRef((props, ref) => {
2414
- const [variantProps, restProps] = svaFn.splitVariantProps(props)
2415
-
2416
- const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
2417
- slotStyles._classNameMap = svaFn.classNameMap
2418
-
2419
- const propsWithClass = { ...restProps, className: restProps.className ?? options?.defaultProps?.className }
2420
- const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
2421
- return createElement(StyleContext.Provider, {
2422
- value: slotStyles,
2423
- children: createElement(StyledComponent, {
2424
- ...resolvedProps,
2425
- className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
2426
- ref,
2427
- })
2428
- })
2429
- })
2430
-
2431
- const componentName = getDisplayName(Component)
2432
- WithProvider.displayName = \`withProvider(\${componentName})\`
2433
-
2434
- return WithProvider
2435
- }
2436
-
2437
- const withContext = (Component, slot, options) => {
2438
- const StyledComponent = ${factoryName}(Component, {}, options)
2439
- const componentName = getDisplayName(Component)
2440
-
2441
- const WithContext = forwardRef((props, ref) => {
2442
- const slotStyles = useStyleContext(componentName, slot)
2443
-
2444
- const propsWithClass = { ...props, className: props.className ?? options?.defaultProps?.className }
2445
- const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
2446
- return createElement(StyledComponent, {
2447
- ...resolvedProps,
2448
- className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
2449
- ref,
2450
- })
2451
- })
2452
-
2453
- WithContext.displayName = \`withContext(\${componentName})\`
2454
-
2455
- return WithContext
2456
- }
2457
-
2458
- return {
2459
- withRootProvider,
2460
- withProvider,
2461
- withContext,
2462
- }
2463
- }
2464
- `,
2465
- dts: outdent`
2466
- ${ctx.file.importType("SlotRecipeRuntimeFn, RecipeVariantProps", "../types/recipe")}
2467
- ${ctx.file.importType("JsxHTMLProps, JsxStyleProps, Assign", "../types/system-types")}
2468
- ${ctx.file.importType("JsxFactoryOptions, ComponentProps, DataAttrs, AsProps", "../types/jsx")}
2469
- import type { ComponentType, ElementType } from 'react'
2470
-
2471
- interface UnstyledProps {
2472
- unstyled?: boolean | undefined
2473
- }
2474
-
2475
- type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
2476
- interface SlotRecipeFn {
2477
- __type: any
2478
- __slot: string
2479
- (props?: any): any
2480
- }
2481
- type SlotRecipe = SvaFn | SlotRecipeFn
2482
-
2483
- type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
2484
-
2485
- interface WithProviderOptions<P = {}> {
2486
- defaultProps?: (Partial<P> & DataAttrs) | undefined
2487
- }
2488
-
2489
- type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
2490
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
2491
- >
2492
-
2493
- type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
2494
- ComponentProps<T> & UnstyledProps & RecipeVariantProps<R>
2495
- >
2496
-
2497
- type StyleContextConsumer<T extends ElementType> = ComponentType<
2498
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
2499
- >
2500
-
2501
- export interface StyleContext<R extends SlotRecipe> {
2502
- withRootProvider: <T extends ElementType>(
2503
- Component: T,
2504
- options?: WithProviderOptions<ComponentProps<T>> | undefined
2505
- ) => StyleContextRootProvider<T, R>
2506
- withProvider: <T extends ElementType>(
2507
- Component: T,
2508
- slot: InferSlot<R>,
2509
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
2510
- ) => StyleContextProvider<T, R>
2511
- withContext: <T extends ElementType>(
2512
- Component: T,
2513
- slot: InferSlot<R>,
2514
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
2515
- ) => StyleContextConsumer<T>
2516
- }
2517
-
2518
- export declare function createStyleContext<R extends SlotRecipe>(recipe: R): StyleContext<R>
2519
- `
2520
- };
2521
- }
2522
- //#endregion
2523
- //#region src/artifacts/react-jsx/jsx.string-literal.ts
2524
- function generateReactJsxStringLiteralFactory(ctx) {
2525
- const { factoryName, componentName } = ctx.jsx;
2526
- return { js: outdent`
2527
- import { createElement, forwardRef } from 'react'
2528
- ${ctx.file.import("getDisplayName", "./factory-helper")}
2529
- ${ctx.file.import("css, cx", "../css/index")}
2530
-
2531
- function createStyledFn(Dynamic) {
2532
- const __base__ = Dynamic.__base__ || Dynamic
2533
- return function styledFn(template) {
2534
- const styles = css.raw(Dynamic.__styles__, template)
2535
-
2536
- const ${componentName} = /* @__PURE__ */ forwardRef(function ${componentName}(props, ref) {
2537
- const { as: Element = __base__, ...elementProps } = props
2538
-
2539
- function classes() {
2540
- return cx(css(styles), elementProps.className)
2541
- }
2542
-
2543
- return createElement(Element, {
2544
- ref,
2545
- ...elementProps,
2546
- className: classes(),
2547
- })
2548
- })
2549
-
2550
- const name = getDisplayName(__base__)
2551
-
2552
- ${componentName}.displayName = \`${factoryName}.\${name}\`
2553
- ${componentName}.__styles__ = styles
2554
- ${componentName}.__base__ = __base__
2555
-
2556
- return ${componentName}
2557
- }
2558
- }
2559
-
2560
- function createJsxFactory() {
2561
- const cache = new Map()
2562
-
2563
- return new Proxy(createStyledFn, {
2564
- apply(_, __, args) {
2565
- return createStyledFn(...args)
2566
- },
2567
- get(_, el) {
2568
- if (!cache.has(el)) {
2569
- cache.set(el, createStyledFn(el))
2570
- }
2571
- return cache.get(el)
2572
- },
2573
- })
2574
- }
2575
-
2576
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2577
- ` };
2578
- }
2579
- //#endregion
2580
- //#region src/artifacts/react-jsx/types.string-literal.ts
2581
- function generateReactJsxStringLiteralTypes(ctx) {
2582
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
2583
- return {
2584
- jsxFactory: outdent`
2585
- ${ctx.file.importType(upperName, "../types/jsx")}
2586
- export declare const ${factoryName}: ${upperName}
2587
- `,
2588
- jsxType: outdent`
2589
- import type { ComponentPropsWithoutRef, ElementType, ElementRef, JSX, Ref } from 'react'
2590
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
2591
-
2592
- interface Dict {
2593
- [k: string]: unknown
2594
- }
2595
-
2596
- export interface AsProps {
2597
- /**
2598
- * The element to render as
2599
- */
2600
- as?: ElementType | undefined
2601
- }
2602
-
2603
- export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
2604
- ref?: Ref<ElementRef<T>>
2605
- } & AsProps
2606
-
2607
- export type ${componentName}<T extends ElementType> = {
2608
- (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T>) => JSX.Element
2609
- displayName?: string | undefined
2610
- }
2611
-
2612
- export interface JsxFactory {
2613
- <T extends ElementType>(component: T): ${componentName}<T>
2614
- }
2615
-
2616
- export type JsxElements = {
2617
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
2618
- }
2619
-
2620
- export type ${upperName} = JsxFactory & JsxElements
2621
-
2622
- export type ${typeName}<T extends ElementType> = ComponentProps<T>
2623
- `
2624
- };
2625
- }
2626
- //#endregion
2627
- //#region src/artifacts/solid-jsx/jsx.ts
2628
- function generateSolidJsxFactory(ctx) {
2629
- const { componentName, factoryName } = ctx.jsx;
2630
- return { js: outdent`
2631
- import { createMemo, mergeProps, splitProps } from 'solid-js'
2632
- import { Dynamic, createComponent } from 'solid-js/web'
2633
- ${ctx.file.import("css, cx, cva", "../css/index")}
2634
- ${ctx.file.import("normalizeHTMLProps", "../helpers")}
2635
- ${ctx.file.import("composeCvaFn, composeShouldForwardProps, defaultShouldForwardProp, getDisplayName", "./factory-helper")}
2636
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
2637
-
2638
- function styledFn(element, configOrCva = {}, options = {}) {
2639
- const cvaFn =
2640
- configOrCva.__cva__ || configOrCva.__recipe__
2641
- ? configOrCva
2642
- : cva(configOrCva)
2643
-
2644
- const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
2645
- const shouldForwardProp = (prop) => {
2646
- if (options.forwardProps?.includes(prop)) return true
2647
- return forwardFn(prop, cvaFn.variantKeys)
2648
- }
2649
-
2650
- const getDefaultProps = () => {
2651
- const baseDefaults = options.dataAttr && configOrCva.__name__
2652
- ? { 'data-recipe': configOrCva.__name__ }
2653
- : {}
2654
- const defaults = typeof options.defaultProps === 'function'
2655
- ? options.defaultProps()
2656
- : options.defaultProps
2657
- return Object.assign(baseDefaults, defaults)
2658
- }
2659
-
2660
- const __cvaFn__ = composeCvaFn(element.__cva__, cvaFn)
2661
- const __shouldForwardProps__ = composeShouldForwardProps(
2662
- element,
2663
- shouldForwardProp
2664
- )
2665
-
2666
- const ${componentName} = (props) => {
2667
- const mergedProps = mergeProps(
2668
- { as: element.__base__ || element },
2669
- getDefaultProps(),
2670
- props
2671
- )
2672
-
2673
- const [localProps, restProps] = splitProps(mergedProps, [
2674
- 'as',
2675
- 'unstyled',
2676
- 'class',
2677
- 'className',
2678
- ])
2679
-
2680
- const [htmlProps, aProps] = splitProps(restProps, normalizeHTMLProps.keys)
2681
-
2682
- const forwardedKeys = createMemo(() => {
2683
- const keys = Object.keys(aProps)
2684
- return keys.filter((prop) => __shouldForwardProps__(prop))
2685
- })
2686
-
2687
- const [forwardedProps, variantProps, bProps] = splitProps(aProps, forwardedKeys(), __cvaFn__.variantKeys)
2688
-
2689
- const cssPropKeys = createMemo(() => {
2690
- const keys = Object.keys(bProps)
2691
- return keys.filter((prop) => isCssProperty(prop))
2692
- })
2693
-
2694
- const [styleProps, elementProps] = splitProps(bProps, cssPropKeys())
2695
-
2696
- function recipeClass() {
2697
- const { css: cssStyles, ...propStyles } = styleProps
2698
- const compoundVariantStyles =
2699
- __cvaFn__.__getCompoundVariantCss__?.(variantProps)
2700
- return cx(
2701
- __cvaFn__(variantProps, false),
2702
- css(compoundVariantStyles, propStyles, cssStyles),
2703
- localProps.class,
2704
- localProps.className
2705
- )
2706
- }
2707
-
2708
- function cvaClass() {
2709
- const { css: cssStyles, ...propStyles } = styleProps
2710
- const cvaStyles = __cvaFn__.raw(variantProps)
2711
- return cx(
2712
- css(cvaStyles, propStyles, cssStyles),
2713
- localProps.class,
2714
- localProps.className
2715
- )
2716
- }
2717
-
2718
- const classes = () => {
2719
- if (localProps.unstyled) {
2720
- const { css: cssStyles, ...propStyles } = styleProps
2721
- return cx(css(propStyles, cssStyles), localProps.class, localProps.className)
2722
- }
2723
- return configOrCva.__recipe__ ? recipeClass() : cvaClass()
2724
- }
2725
-
2726
- if (forwardedProps.className) {
2727
- delete forwardedProps.className
2728
- }
2729
-
2730
- return createComponent(
2731
- Dynamic,
2732
- mergeProps(forwardedProps, elementProps, normalizeHTMLProps(htmlProps), {
2733
- get component() {
2734
- return localProps.as
2735
- },
2736
- get class() {
2737
- return classes()
2738
- },
2739
- })
2740
- )
2741
- }
2742
-
2743
- const name = getDisplayName(element)
2744
-
2745
- ${componentName}.displayName = \`${factoryName}.\${name}\`
2746
- ${componentName}.__cva__ = __cvaFn__
2747
- ${componentName}.__base__ = element
2748
- ${componentName}.__shouldForwardProps__ = shouldForwardProp
2749
-
2750
- return ${componentName}
2751
- }
2752
-
2753
- function createJsxFactory() {
2754
- const cache = new Map()
2755
-
2756
- return new Proxy(styledFn, {
2757
- apply(_, __, args) {
2758
- return styledFn(...args)
2759
- },
2760
- get(_, el) {
2761
- if (!cache.has(el)) {
2762
- cache.set(el, styledFn(el))
2763
- }
2764
- return cache.get(el)
2765
- },
2766
- })
2767
- }
2768
-
2769
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
2770
- ` };
2771
- }
2772
- //#endregion
2773
- //#region src/artifacts/solid-jsx/pattern.ts
2774
- function generateSolidJsxPattern(ctx, filters) {
2775
- const { typeName, factoryName, styleProps: jsxStyleProps } = ctx.jsx;
2776
- return ctx.patterns.filterDetails(filters).map((pattern) => {
2777
- const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
2778
- const { description, jsxElement = "div", deprecated } = pattern.config;
2779
- return {
2780
- name: dashName,
2781
- js: outdent`
2782
- import { createMemo, mergeProps, splitProps } from 'solid-js'
2783
- import { createComponent } from 'solid-js/web'
2784
- ${jsxStyleProps === "minimal" ? ctx.file.import("mergeCss", "../css/css") : ""}
2785
- ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
2786
- ${ctx.file.import(factoryName, "./factory")}
2787
-
2788
- export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
2789
- ${match(jsxStyleProps).with("none", () => outdent`
2790
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2791
-
2792
- const cssProps = createMemo(() => {
2793
- const styleProps = ${styleFnName}(patternProps)
2794
- return { css: styleProps }
2795
- })
2796
-
2797
- const mergedProps = mergeProps(restProps, cssProps)
2798
-
2799
- return createComponent(${factoryName}.${jsxElement}, mergedProps)
2800
- `).with("minimal", () => outdent`
2801
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2802
-
2803
- const cssProps = createMemo(() => {
2804
- const styleProps = ${styleFnName}(patternProps)
2805
- return { css: mergeCss(styleProps, props.css) }
2806
- })
2807
-
2808
- const mergedProps = mergeProps(restProps, cssProps)
2809
-
2810
- return createComponent(${factoryName}.${jsxElement}, mergedProps)
2811
- `).with("all", () => outdent`
2812
- const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
2813
-
2814
- const styleProps = ${styleFnName}(patternProps)
2815
- const mergedProps = mergeProps(styleProps, restProps)
2816
-
2817
- return createComponent(${factoryName}.${jsxElement}, mergedProps)
2818
- `).exhaustive()}
2819
- }
2820
- `,
2821
- dts: outdent`
2822
- import type { Component } from 'solid-js'
2823
- ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
2824
- ${ctx.file.importType(typeName, "../types/jsx")}
2825
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
2826
-
2827
- export interface ${upperName}Props extends ${upperName}Properties, DistributiveOmit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}> {}
2828
-
2829
- ${ctx.file.jsDocComment(description, { deprecated })}
2830
- export declare const ${jsxName}: Component<${upperName}Props>
2831
- `
2832
- };
2833
- });
2834
- }
2835
- //#endregion
2836
- //#region src/artifacts/solid-jsx/types.ts
2837
- function generateSolidJsxTypes(ctx) {
2838
- const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
2839
- return {
2840
- jsxFactory: outdent`
2841
- ${ctx.file.importType(upperName, "../types/jsx")}
2842
- export declare const ${factoryName}: ${upperName}
2843
- `,
2844
- jsxType: outdent`
2845
- import type { Accessor, ComponentProps, Component, JSX } from 'solid-js'
2846
- ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
2847
- ${ctx.file.importType("Assign, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty", "./system-types")}
2848
-
2849
- interface Dict {
2850
- [k: string]: unknown
2851
- }
2852
-
2853
- export type DataAttrs = Record<\`data-\${string}\`, unknown>
2854
-
2855
- export interface UnstyledProps {
2856
- /**
2857
- * Whether to remove recipe styles
2858
- */
2859
- unstyled?: boolean | undefined
2860
- }
2861
-
2862
- export interface AsProps {
2863
- /**
2864
- * The element to render as
2865
- */
2866
- as?: ElementType | undefined
2867
- }
2868
-
2869
- export type ElementType = keyof JSX.IntrinsicElements | Component<any>
2870
-
2871
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> {
2872
- (props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>): JSX.Element
2873
- displayName?: string | undefined
2874
- }
2875
-
2876
- interface RecipeFn {
2877
- __type: any
2878
- }
2879
-
2880
- export type MaybeAccessor<T> = T | Accessor<T>
2881
-
2882
- export interface JsxFactoryOptions<TProps extends Dict> {
2883
- dataAttr?: boolean
2884
- defaultProps?: MaybeAccessor<Partial<TProps> & DataAttrs>
2885
- shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
2886
- forwardProps?: string[]
2887
- }
2888
-
2889
- export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, P>;
2890
-
2891
- export type JsxElement<T extends ElementType, P extends Dict> = T extends ${componentName}<infer A, infer B>
2892
- ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
2893
- : ${componentName}<T, P>
2894
-
2895
- export interface JsxFactory {
2896
- <T extends ElementType>(component: T): ${componentName}<T, {}>
2897
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
2898
- T,
2899
- RecipeSelection<P>
2900
- >
2901
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
2902
- }
2903
-
2904
- export type JsxElements = {
2905
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}>
2906
- }
2907
-
2908
- export type ${upperName} = JsxFactory & JsxElements
2909
-
2910
- export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
2911
-
2912
- export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
2913
- `
2914
- };
2915
- }
2916
- //#endregion
2917
- //#region src/artifacts/solid-jsx/create-style-context.ts
2918
- function generateSolidCreateStyleContext(ctx) {
2919
- const { factoryName } = ctx.jsx;
2920
- return {
2921
- js: outdent`
2922
- ${ctx.file.import("cx, css, sva", "../css/index")}
2923
- ${ctx.file.import(factoryName, "./factory")}
2924
- ${ctx.file.import("getDisplayName", "./factory-helper")}
2925
- import { createComponent, mergeProps } from 'solid-js/web'
2926
- import { createContext, createMemo, splitProps, useContext } from 'solid-js'
2927
-
2928
- function createSafeContext(contextName) {
2929
- const Context = createContext(undefined)
2930
- const useStyleContext = (componentName, slot) => {
2931
- const context = useContext(Context)
2932
- if (context === undefined) {
2933
- const componentInfo = componentName ? \`Component "\${componentName}"\` : 'A component'
2934
- const slotInfo = slot ? \` (slot: "\${slot}")\` : ''
2935
-
2936
- throw new Error(
2937
- \`\${componentInfo}\${slotInfo} cannot access \${contextName} because it's missing its Provider.\`
2938
- )
2939
- }
2940
- return context
2941
- }
2942
- return [Context, useStyleContext]
2943
- }
2944
-
2945
- export function createStyleContext(recipe) {
2946
- const isConfigRecipe = '__recipe__' in recipe
2947
- const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined
2948
- const contextName = recipeName ? \`createStyleContext("\${recipeName}")\` : 'createStyleContext'
2949
-
2950
- const [StyleContext, useStyleContext] = createSafeContext(contextName)
2951
- const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
2952
-
2953
- const getResolvedProps = (props, slotStyles) => {
2954
- const { unstyled, ...restProps } = props
2955
- if (unstyled) return restProps
2956
- if (isConfigRecipe) {
2957
- return { ...restProps, class: cx(slotStyles, restProps.class) }
2958
- }
2959
- ${outdent.string(match(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`))}
2960
- }
2961
-
2962
- const withRootProvider = (Component, options) => {
2963
- const WithRootProvider = (props) => {
2964
- const [variantProps, otherProps] = svaFn.splitVariantProps(props)
2965
- const [local, propsWithoutChildren] = splitProps(otherProps, ['children'])
2966
-
2967
- const slotStyles = createMemo(() => {
2968
- const styles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
2969
- styles._classNameMap = svaFn.classNameMap
2970
- return styles
2971
- })
2972
-
2973
- const mergedProps = createMemo(() => {
2974
- if (!options?.defaultProps) return propsWithoutChildren
2975
- const defaults = typeof options.defaultProps === 'function'
2976
- ? options.defaultProps()
2977
- : options.defaultProps
2978
- return { ...defaults, ...propsWithoutChildren }
2979
- })
2980
-
2981
- return createComponent(StyleContext.Provider, {
2982
- get value() {
2983
- return slotStyles()
2984
- },
2985
- get children() {
2986
- return createComponent(
2987
- Component,
2988
- mergeProps(mergedProps, {
2989
- get children() {
2990
- return local.children
2991
- },
2992
- }),
2993
- )
2994
- },
2995
- })
2996
- }
2997
-
2998
- const componentName = getDisplayName(Component)
2999
- WithRootProvider.displayName = \`withRootProvider(\${componentName})\`
3000
- return WithRootProvider
3001
- }
3002
-
3003
- const withProvider = (Component, slot, options) => {
3004
- const StyledComponent = ${factoryName}(Component, {}, options)
3005
-
3006
- const WithProvider = (props) => {
3007
- const [variantProps, restProps] = svaFn.splitVariantProps(props)
3008
- const [local, propsWithoutChildren] = splitProps(restProps, ["children"])
3009
-
3010
- const slotStyles = createMemo(() => {
3011
- const styles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
3012
- styles._classNameMap = svaFn.classNameMap
3013
- return styles
3014
- })
3015
-
3016
- const resolvedProps = createMemo(() => {
3017
- const propsWithClass = {
3018
- ...propsWithoutChildren,
3019
- class: propsWithoutChildren.class ?? options?.defaultProps?.class,
3020
- }
3021
- const resolved = getResolvedProps(propsWithClass, slotStyles()[slot])
3022
- resolved.class = cx(resolved.class, slotStyles()._classNameMap[slot])
3023
- return resolved
3024
- })
3025
-
3026
- return createComponent(StyleContext.Provider, {
3027
- get value() {
3028
- return slotStyles()
3029
- },
3030
- get children() {
3031
- return createComponent(
3032
- StyledComponent,
3033
- mergeProps(resolvedProps, {
3034
- get children() {
3035
- return local.children
3036
- },
3037
- })
3038
- )
3039
- },
3040
- })
3041
- }
3042
-
3043
- const componentName = getDisplayName(Component)
3044
- WithProvider.displayName = \`withProvider(\${componentName})\`
3045
- return WithProvider
3046
- }
3047
-
3048
- const withContext = (Component, slot, options) => {
3049
- const StyledComponent = ${factoryName}(Component, {}, options)
3050
- const componentName = getDisplayName(Component)
3051
-
3052
- const WithContext = (props) => {
3053
- const slotStyles = useStyleContext(componentName, slot)
3054
- const [local, propsWithoutChildren] = splitProps(props, ["children"])
3055
-
3056
- const resolvedProps = createMemo(() => {
3057
- const propsWithClass = {
3058
- ...propsWithoutChildren,
3059
- class: propsWithoutChildren.class ?? options?.defaultProps?.class,
3060
- }
3061
- const resolved = getResolvedProps(propsWithClass, slotStyles[slot])
3062
- resolved.class = cx(resolved.class, slotStyles._classNameMap?.[slot])
3063
- return resolved
3064
- })
3065
-
3066
- return createComponent(
3067
- StyledComponent,
3068
- mergeProps(resolvedProps, {
3069
- get children() {
3070
- return local.children
3071
- },
3072
- })
3073
- )
3074
- }
3075
-
3076
- WithContext.displayName = \`withContext(\${componentName})\`
3077
- return WithContext
3078
- }
3079
-
3080
- return {
3081
- withRootProvider,
3082
- withProvider,
3083
- withContext,
3084
- }
3085
- }
3086
- `,
3087
- dts: outdent`
3088
- ${ctx.file.importType("SlotRecipeRuntimeFn, RecipeVariantProps", "../types/recipe")}
3089
- ${ctx.file.importType("JsxHTMLProps, JsxStyleProps, Assign", "../types/system-types")}
3090
- ${ctx.file.importType("JsxFactoryOptions, DataAttrs, MaybeAccessor, AsProps", "../types/jsx")}
3091
- import type { Component, JSX, ComponentProps } from 'solid-js'
3092
-
3093
- interface UnstyledProps {
3094
- unstyled?: boolean | undefined
3095
- }
3096
-
3097
- interface WithProviderOptions<P> {
3098
- defaultProps?: MaybeAccessor<Partial<P> & DataAttrs> | undefined
3099
- }
3100
-
3101
- type ElementType = keyof JSX.IntrinsicElements | Component<any>
3102
-
3103
- type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
3104
- interface SlotRecipeFn {
3105
- __type: any
3106
- __slot: string
3107
- (props?: any): any
3108
- }
3109
- type SlotRecipe = SvaFn | SlotRecipeFn
3110
-
3111
- type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn
3112
- ? R['__slot']
3113
- : R extends SvaFn<infer S>
3114
- ? S
3115
- : never
3116
-
3117
- type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = Component<
3118
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
3119
- >
3120
-
3121
- type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = Component<
3122
- ComponentProps<T> & UnstyledProps & RecipeVariantProps<R>
3123
- >
3124
-
3125
- type StyleContextConsumer<T extends ElementType> = Component<
3126
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
3127
- >
3128
-
3129
- export interface StyleContext<R extends SlotRecipe> {
3130
- withRootProvider: <T extends ElementType>(
3131
- Component: T,
3132
- options?: WithProviderOptions<ComponentProps<T>> | undefined
3133
- ) => StyleContextRootProvider<T, R>
3134
- withProvider: <T extends ElementType>(
3135
- Component: T,
3136
- slot: InferSlot<R>,
3137
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
3138
- ) => StyleContextProvider<T, R>
3139
- withContext: <T extends ElementType>(
3140
- Component: T,
3141
- slot: InferSlot<R>,
3142
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
3143
- ) => StyleContextConsumer<T>
3144
- }
3145
-
3146
- export declare function createStyleContext<R extends SlotRecipe>(recipe: R): StyleContext<R>
3147
- `
3148
- };
3149
- }
3150
- //#endregion
3151
- //#region src/artifacts/solid-jsx/jsx.string-literal.ts
3152
- function generateSolidJsxStringLiteralFactory(ctx) {
3153
- const { componentName, factoryName } = ctx.jsx;
3154
- return { js: outdent`
3155
- import { mergeProps, splitProps } from 'solid-js'
3156
- import { Dynamic, createComponent } from 'solid-js/web'
3157
- ${ctx.file.import("getDisplayName", "./factory-helper")}
3158
- ${ctx.file.import("css, cx", "../css/index")}
3159
-
3160
- function createStyled(element) {
3161
- const __base__ = element.__base__ || element
3162
- return function styledFn(template) {
3163
- const styles = css.raw(element.__styles__, template)
3164
-
3165
- const ${componentName} = (props) => {
3166
- const mergedProps = mergeProps({ as: __base__ }, props)
3167
- const [localProps, elementProps] = splitProps(mergedProps, ['as', 'class'])
3168
-
3169
- return createComponent(
3170
- Dynamic,
3171
- mergeProps(
3172
- {
3173
- get component() {
3174
- return localProps.as
3175
- },
3176
- get class() {
3177
- return cx(css(styles), localProps.class)
3178
- },
3179
- },
3180
- elementProps,
3181
- ),
3182
- )
3183
- }
3184
-
3185
- const name = getDisplayName(__base__)
3186
-
3187
- ${componentName}.displayName = \`${factoryName}.\${name}\`
3188
- ${componentName}.__styles__ = styles
3189
- ${componentName}.__base__ = __base__
3190
-
3191
- return ${componentName}
3192
- }
3193
- }
3194
-
3195
- function createJsxFactory() {
3196
- const cache = new Map()
3197
-
3198
- return new Proxy(createStyled, {
3199
- apply(_, __, args) {
3200
- return createStyled(...args)
3201
- },
3202
- get(_, el) {
3203
- if (!cache.has(el)) {
3204
- cache.set(el, createStyled(el))
3205
- }
3206
- return cache.get(el)
3207
- },
3208
- })
3209
- }
3210
-
3211
- export const ${factoryName} = /* @__PURE__ */ createJsxFactory()
3212
- ` };
3213
- }
3214
- //#endregion
3215
- //#region src/artifacts/solid-jsx/types.string-literal.ts
3216
- function generateSolidJsxStringLiteralTypes(ctx) {
3217
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
3218
- return {
3219
- jsxFactory: outdent`
3220
- ${ctx.file.importType(upperName, "../types/jsx")}
3221
- export declare const ${factoryName}: ${upperName}
3222
- `,
3223
- jsxType: outdent`
3224
- import type { Component, ComponentProps, JSX } from 'solid-js'
3225
-
3226
- interface Dict {
3227
- [k: string]: unknown
3228
- }
3229
-
3230
- export interface AsProps {
3231
- /**
3232
- * The element to render as
3233
- */
3234
- as?: ElementType | undefined
3235
- }
3236
-
3237
- export type ElementType<P = any> = keyof JSX.IntrinsicElements | Component<P>
3238
-
3239
- export type ${componentName}<T extends ElementType> = {
3240
- (args: { raw: readonly string[] | ArrayLike<string> }): (props: ComponentProps<T> & AsProps) => JSX.Element
3241
- displayName?: string | undefined
3242
- }
3243
-
3244
- export interface JsxFactory {
3245
- <T extends ElementType>(component: T): ${componentName}<T>
3246
- }
3247
-
3248
- export type JsxElements = {
3249
- [K in keyof JSX.IntrinsicElements]: ${componentName}<K>
3250
- }
3251
-
3252
- export type ${upperName} = JsxFactory & JsxElements
3253
-
3254
- export type ${typeName}<T extends ElementType> = ComponentProps<T>
3255
- `
3256
- };
3257
- }
3258
- //#endregion
3259
- //#region src/artifacts/vue-jsx/jsx.ts
3260
- function generateVueJsxFactory(ctx) {
3261
- const { factoryName, componentName } = ctx.jsx;
3262
- return { js: outdent`
3263
- import { defineComponent, h, computed } from 'vue'
3264
- ${ctx.file.import("defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName", "./factory-helper")}
3265
- ${ctx.file.import("isCssProperty", "./is-valid-prop")}
3266
- ${ctx.file.import("css, cx, cva", "../css/index")}
3267
- ${ctx.file.import("splitProps, normalizeHTMLProps", "../helpers")}
3268
-
3269
- function styledFn(Dynamic, configOrCva = {}, options = {}) {
3270
- const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
3271
-
3272
- const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
3273
- const shouldForwardProp = (prop) => {
3274
- if (options.forwardProps?.includes(prop)) return true
3275
- return forwardFn(prop, cvaFn.variantKeys)
3276
- }
3277
-
3278
- const defaultProps = Object.assign(
3279
- options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
3280
- options.defaultProps,
3281
- )
3282
-
3283
- const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
3284
- const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
3285
-
3286
- const __base__ = Dynamic.__base__ || Dynamic
3287
- const name = getDisplayName(__base__)
3288
-
3289
- const ${componentName} = defineComponent({
3290
- name: \`${factoryName}.\${name}\`,
3291
- inheritAttrs: false,
3292
- props: {
3293
- modelValue: null,
3294
- unstyled: { type: Boolean, default: false },
3295
- as: { type: [String, Object], default: __base__ }
3296
- },
3297
- setup(props, { slots, attrs, emit }) {
3298
- const combinedProps = computed(() => Object.assign({}, defaultProps, attrs))
3299
-
3300
- const splittedProps = computed(() => {
3301
- return splitProps(combinedProps.value, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
3302
- })
3303
-
3304
- const recipeClass = computed(() => {
3305
- const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
3306
- const { css: cssStyles, ...propStyles } = styleProps
3307
- const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps);
3308
- return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.value.className, combinedProps.value.class)
3309
- })
3310
-
3311
- const cvaClass = computed(() => {
3312
- const [_htmlProps, _forwardedProps, variantProps, styleProps, _elementProps] = splittedProps.value
3313
- const { css: cssStyles, ...propStyles } = styleProps
3314
- const cvaStyles = __cvaFn__.raw(variantProps)
3315
- return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.value.className, combinedProps.value.class)
3316
- })
3317
-
3318
- const classes = computed(() => {
3319
- if (props.unstyled) {
3320
- const [_htmlProps, _forwardedProps, _variantProps, styleProps, _elementProps] = splittedProps.value
3321
- const { css: cssStyles, ...propStyles } = styleProps
3322
- return cx(css(propStyles, cssStyles), combinedProps.value.className, combinedProps.value.class)
3323
- }
3324
- return configOrCva.__recipe__ ? recipeClass.value : cvaClass.value
3325
- })
3326
-
3327
- const vModelProps = computed(() => {
3328
- const result = {};
3329
-
3330
- if (
3331
- props.as === 'input' &&
3332
- (props.type === 'checkbox' || props.type === 'radio')
3333
- ) {
3334
- result.checked = props.modelValue;
3335
- result.onChange = (event) => {
3336
- const checked = !event.currentTarget.checked;
3337
- emit('change', checked, event);
3338
- emit('update:modelValue', checked, event);
3339
- };
3340
- } else if (
3341
- props.as === 'input' ||
3342
- props.as === 'textarea' ||
3343
- props.as === 'select'
3344
- ) {
3345
- result.value = props.modelValue;
3346
- result.onInput = (event) => {
3347
- const value = event.currentTarget.value;
3348
- emit('input', value, event);
3349
- emit('update:modelValue', value, event);
3350
- };
3351
- }
3352
-
3353
- return result;
3354
- });
3355
-
3356
- return () => {
3357
- const [htmlProps, forwardedProps, _variantProps, _styleProps, elementProps] = splittedProps.value
3358
-
3359
- return h(
3360
- props.as,
3361
- {
3362
- ...forwardedProps,
3363
- ...elementProps,
3364
- ...normalizeHTMLProps(htmlProps),
3365
- ...vModelProps.value,
3366
- class: classes.value,
3367
- },
3368
- slots,
3369
- )
3370
- }
3371
- },
3372
- })
3373
-
3374
- ${componentName}.displayName = \`${factoryName}.\${name}\`
3375
- ${componentName}.__cva__ = __cvaFn__
3376
- ${componentName}.__base__ = __base__
3377
- ${componentName}.__shouldForwardProps__ = shouldForwardProp
3378
-
3379
- return ${componentName}
3380
- }
3381
-
3382
- const tags = 'a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, big, blockquote, body, br, button, canvas, caption, cite, code, col, colgroup, data, datalist, dd, del, details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, input, ins, kbd, keygen, label, legend, li, link, main, map, mark, marquee, menu, menuitem, meta, meter, nav, noscript, object, ol, optgroup, option, output, p, param, picture, pre, progress, q, rp, rt, ruby, s, samp, script, section, select, small, source, span, strong, style, sub, summary, sup, table, tbody, td, textarea, tfoot, th, thead, time, title, tr, track, u, ul, var, video, wbr, circle, clipPath, defs, ellipse, foreignObject, g, image, line, linearGradient, mask, path, pattern, polygon, polyline, radialGradient, rect, stop, svg, text, tspan';
3383
-
3384
- export const ${factoryName} = /* @__PURE__ */ styledFn.bind();
3385
-
3386
- tags.split(', ').forEach((tag) => {
3387
- ${factoryName}[tag] = ${factoryName}(tag);
3388
- });
3389
- ` };
3390
- }
3391
- //#endregion
3392
- //#region src/artifacts/vue-jsx/pattern.ts
3393
- function generateVueJsxPattern(ctx, filters) {
3394
- const { typeName, factoryName, styleProps: jsxStyleProps } = ctx.jsx;
3395
- return ctx.patterns.filterDetails(filters).map((pattern) => {
3396
- const { upperName, styleFnName, dashName, jsxName, props, blocklistType } = pattern;
3397
- const { description, jsxElement = "div", deprecated } = pattern.config;
3398
- return {
3399
- name: dashName,
3400
- js: outdent`
3401
- import { defineComponent, h, computed } from 'vue'
3402
- ${jsxStyleProps === "minimal" ? ctx.file.import("mergeCss", "../css/css") : ""}
3403
- ${ctx.file.import(styleFnName, `../patterns/${dashName}`)}
3404
- ${ctx.file.import(factoryName, "./factory")}
3405
-
3406
- export const ${jsxName} = /* @__PURE__ */ defineComponent({
3407
- name: '${jsxName}',
3408
- inheritAttrs: false,
3409
- props: ${JSON.stringify(props)},
3410
- setup(props, { attrs, slots }) {
3411
- ${match(jsxStyleProps).with("none", () => outdent`
3412
- const cssProps = computed(() => {
3413
- const styleProps = ${styleFnName}(props)
3414
- return { css: styleProps }
3415
- })
3416
-
3417
- return () => {
3418
- const mergedProps = { ...attrs, ...cssProps.value }
3419
- return h(${factoryName}.${jsxElement}, mergedProps, slots)
3420
- }
3421
- `).with("minimal", () => outdent`
3422
- const cssProps = computed(() => {
3423
- const styleProps = ${styleFnName}(props)
3424
- return { css: mergeCss(styleProps, attrs.css) }
3425
- })
3426
-
3427
- return () => {
3428
- const mergedProps = { ...attrs, ...cssProps.value }
3429
- return h(${factoryName}.${jsxElement}, mergedProps, slots)
3430
- }
3431
- `).with("all", () => outdent`
3432
- const styleProps = computed(() => ${styleFnName}(props))
3433
-
3434
- return () => {
3435
- const mergedProps = { ...styleProps.value, ...attrs }
3436
- return h(${factoryName}.${jsxElement}, mergedProps, slots)
3437
- }
3438
- `).exhaustive()}
3439
- }
3440
- })
3441
- `,
3442
- dts: outdent`
3443
- import type { FunctionalComponent } from 'vue'
3444
- ${ctx.file.importType(`${upperName}Properties`, `../patterns/${dashName}`)}
3445
- ${ctx.file.importType(typeName, "../types/jsx")}
3446
- ${ctx.file.importType("DistributiveOmit", "../types/system-types")}
3447
-
3448
- export interface ${upperName}Props extends ${upperName}Properties, DistributiveOmit<${typeName}<'${jsxElement}'>, keyof ${upperName}Properties ${blocklistType}> {}
3449
-
3450
- ${ctx.file.jsDocComment(description, { deprecated })}
3451
- export declare const ${jsxName}: FunctionalComponent<${upperName}Props>
3452
- `
3453
- };
3454
- });
3455
- }
3456
- //#endregion
3457
- //#region src/artifacts/vue-jsx/types.ts
3458
- function generateVueJsxTypes(ctx) {
3459
- const { factoryName, componentName, upperName, typeName, variantName } = ctx.jsx;
3460
- return {
3461
- jsxFactory: outdent`
3462
- ${ctx.file.importType(upperName, "../types/jsx")}
3463
-
3464
- export declare const ${factoryName}: ${upperName}
3465
- `,
3466
- jsxType: outdent`
3467
- import type { Component, FunctionalComponent, NativeElements } from 'vue'
3468
-
3469
- ${ctx.file.importType("RecipeDefinition, RecipeSelection, RecipeVariantRecord", "./recipe")}
3470
- ${ctx.file.importType("Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty", "./system-types")}
3471
-
3472
- export type IntrinsicElement = keyof NativeElements
3473
-
3474
- export type ElementType = IntrinsicElement | Component
3475
-
3476
- export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
3477
- ? NativeElements[T]
3478
- : T extends Component<infer Props>
3479
- ? Props
3480
- : never
3481
-
3482
- interface Dict {
3483
- [k: string]: unknown
3484
- }
3485
-
3486
- export type DataAttrs = Record<\`data-\${string}\`, unknown>
911
+ // The slots that enclose other slots, matching \`Recipes.getScopeRoots\`. Their variant
912
+ // styles anchor \`@scope\` rules for every other slot, so only they take variants — a
913
+ // variant class on any other slot would name a rule that was never emitted.
914
+ //
915
+ // A list, because a component can span a portal and so occupy more than one subtree.
916
+ const declaredSlots = config.slots ?? []
917
+ const anchors = config.scopeRoots
918
+ ? config.scopeRoots.filter((slot) => declaredSlots.includes(slot))
919
+ : declaredSlots.includes('root') ? ['root'] : []
920
+
921
+ // \`classNameMap[slot]\` used to be joined on here, because the slot's classes were
922
+ // atomic and nothing else carried the name to target it in the DOM. The slot's cva is
923
+ // now named \`name__slot\` and returns that as its base class, so joining it again
924
+ // would just repeat it.
925
+ function svaFn(props) {
926
+ const result = slots.map(([slot, cvaFn]) => [
927
+ slot,
928
+ anchors.length && !anchors.includes(slot) ? cvaFn.config.className : cvaFn(props),
929
+ ])
930
+ return Object.fromEntries(result)
931
+ }
3487
932
 
3488
- export interface UnstyledProps {
3489
- /**
3490
- * Whether to remove recipe styles
3491
- */
3492
- unstyled?: boolean | undefined
3493
- }
933
+ function raw(props) {
934
+ const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
935
+ return Object.fromEntries(result)
936
+ }
3494
937
 
3495
- export interface AsProps {
3496
- /**
3497
- * The element to render as
3498
- */
3499
- as?: ElementType | undefined
3500
- }
938
+ const variants = config.variants ?? {};
939
+ const variantKeys = Object.keys(variants);
3501
940
 
3502
- export interface ${componentName}<T extends ElementType, P extends Dict = {}> extends FunctionalComponent<
3503
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>
3504
- > {}
941
+ function splitVariantProps(props) {
942
+ return splitProps(props, variantKeys);
943
+ }
944
+ const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
3505
945
 
3506
- interface RecipeFn {
3507
- __type: any
3508
- }
946
+ const variantMap = Object.fromEntries(
947
+ Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
948
+ );
3509
949
 
3510
- export interface JsxFactoryOptions<TProps extends Dict> {
3511
- dataAttr?: boolean
3512
- defaultProps?: Partial<TProps> & DataAttrs
3513
- shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
3514
- forwardProps?: string[]
3515
- }
950
+ // Which slots each variant writes styles for.
951
+ //
952
+ // A scope reaches every slot inside an anchor's subtree. A slot under no anchor is
953
+ // not reached, and nothing at build time can detect that — reachability is a fact
954
+ // about the DOM. This is what says which slots a variant has to get to, so the
955
+ // component layer can thread the ones a scope cannot. Config slot recipes have always
956
+ // exposed it; an inline \`sva\` had no way to answer the question at all.
957
+ const slotsAffectedBy = Object.fromEntries(
958
+ Object.entries(variants).map(([variant, values]) => [
959
+ variant,
960
+ [...new Set(Object.values(values ?? {}).flatMap((slotStyles) => Object.keys(slotStyles ?? {})))],
961
+ ])
962
+ );
3516
963
 
3517
- export type JsxRecipeProps<T extends ElementType, P extends RecipeFn> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P['__type']>>;
964
+ return Object.assign(memo(svaFn), {
965
+ __cva__: false,
966
+ raw,
967
+ config,
968
+ variantMap,
969
+ variantKeys,
970
+ classNameMap,
971
+ /** The slots that enclose other slots, and so anchor their variant rules. */
972
+ scopeRoots: anchors,
973
+ slotsAffectedBy,
974
+ splitVariantProps,
975
+ getVariantProps,
976
+ })
977
+ }
3518
978
 
3519
- export type JsxElement<T extends ElementType, P> = T extends ${componentName}<infer A, infer B>
3520
- ? ${componentName}<A, Pretty<DistributiveUnion<P, B>>>
3521
- : ${componentName}<T, P>
979
+ /**
980
+ * Report slots whose variant styles can never reach them.
981
+ *
982
+ * A scoped slot is styled through an \`@scope\` rule opened at an anchor, so it has to be
983
+ * rendered inside one. A slot moved out of every anchor's subtree — through a portal,
984
+ * with no second anchor named in \`scopeRoots\` — keeps its base styles and silently
985
+ * loses its variant styles. That renders *nearly* right, which is harder to notice than
986
+ * a total failure, and no build step can catch it: whether one element is inside another
987
+ * is a fact about the DOM.
988
+ *
989
+ * Checks for the anchor's *base* class rather than its variant class. An anchor always
990
+ * carries the base one; the variant class is absent whenever no variant is selected, and
991
+ * matching on it would report a slot that is correctly placed and simply unstyled.
992
+ *
993
+ * Development only — call it behind \`process.env.NODE_ENV !== 'production'\` so bundlers
994
+ * drop it, along with this function, from your production build.
995
+ *
996
+ * \`\`\`js
997
+ * import { auditSlotScopes, select } from '../styled-system/css'
998
+ *
999
+ * if (process.env.NODE_ENV !== 'production') auditSlotScopes([select], { observe: true })
1000
+ * \`\`\`
1001
+ */
1002
+ export function auditSlotScopes(recipes, options = {}) {
1003
+ const { root = typeof document === 'undefined' ? undefined : document, observe = false, onReport } = options
1004
+ if (!root) return () => {}
3522
1005
 
3523
- export interface JsxFactory {
3524
- <T extends ElementType>(component: T): ${componentName}<T, {}>
3525
- <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
3526
- T,
3527
- RecipeSelection<P>
3528
- >
3529
- <T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>> ): JsxElement<T, P['__type']>
3530
- }
1006
+ const escape = (value) =>
1007
+ typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(value) : value.replace(/[^\\w-]/g, '\\\\$&')
3531
1008
 
3532
- export type JsxElements = {
3533
- [K in IntrinsicElement]: ${componentName}<K, {}>
3534
- }
1009
+ const audit = () => {
1010
+ const found = []
3535
1011
 
3536
- export type ${upperName} = JsxFactory & JsxElements
1012
+ for (const recipe of recipes) {
1013
+ const anchors = recipe?.scopeRoots ?? []
1014
+ // Nothing is scoped, so every slot carries its own variant class and none of them
1015
+ // depends on where it is rendered.
1016
+ if (!anchors.length) continue
3537
1017
 
3538
- export type ${typeName}<T extends ElementType> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
1018
+ const classNameMap = recipe.classNameMap ?? {}
1019
+ const anchorSelector = anchors
1020
+ .map((slot) => classNameMap[slot])
1021
+ .filter(Boolean)
1022
+ .map((className) => '.' + escape(className))
1023
+ .join(', ')
1024
+ if (!anchorSelector) continue
3539
1025
 
3540
- export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${componentName}<any, infer Props> ? Props : never
3541
- `
3542
- };
3543
- }
3544
- //#endregion
3545
- //#region src/artifacts/vue-jsx/create-style-context.ts
3546
- function generateVueCreateStyleContext(ctx) {
3547
- const { factoryName } = ctx.jsx;
3548
- return {
3549
- js: outdent`
3550
- ${ctx.file.import("cx, css, sva", "../css/index")}
3551
- ${ctx.file.import(factoryName, "./factory")}
3552
- ${ctx.file.import("getDisplayName", "./factory-helper")}
3553
- import { defineComponent, provide, inject, computed, h } from 'vue'
3554
-
3555
- export function createStyleContext(recipe) {
3556
- const StyleContext = Symbol('StyleContext')
3557
- const isConfigRecipe = '__recipe__' in recipe
3558
- const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined
3559
- const contextName = recipeName ? \`createStyleContext("\${recipeName}")\` : 'createStyleContext'
3560
- const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
3561
-
3562
- function useStyleContext(componentName, slot) {
3563
- const context = inject(StyleContext)
3564
- if (context === undefined) {
3565
- const componentInfo = componentName ? \`Component "\${componentName}"\` : 'A component'
3566
- const slotInfo = slot ? \` (slot: "\${slot}")\` : ''
3567
-
3568
- throw new Error(
3569
- \`\${componentInfo}\${slotInfo} cannot access \${contextName} because it's missing its Provider.\`
3570
- )
3571
- }
3572
- return context
3573
- }
3574
-
3575
- const getResolvedProps = (props, slotStyles) => {
3576
- const { unstyled, ...restProps } = props
3577
- if (unstyled) return restProps
3578
- if (isConfigRecipe) {
3579
- return { ...restProps, class: cx(slotStyles, restProps.class) }
3580
- }
3581
- ${outdent.string(match(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`))}
3582
- }
1026
+ const scoped = new Set(Object.values(recipe.slotsAffectedBy ?? {}).flat())
3583
1027
 
3584
- const withRootProvider = (Component, options) => {
3585
- const WithRootProvider = defineComponent({
3586
- props: svaFn.variantKeys,
3587
- setup(props, { slots }) {
3588
- const [variantProps, otherProps] = svaFn.splitVariantProps(props)
1028
+ for (const slot of scoped) {
1029
+ if (anchors.includes(slot)) continue
3589
1030
 
3590
- const slotStyles = computed(() => {
3591
- const styles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
3592
- styles._classNameMap = svaFn.classNameMap
3593
- return styles
3594
- })
1031
+ const className = classNameMap[slot]
1032
+ if (!className) continue
3595
1033
 
3596
- provide(StyleContext, slotStyles)
1034
+ for (const element of root.querySelectorAll('.' + escape(className))) {
1035
+ if (element.closest(anchorSelector)) continue
1036
+ found.push({ recipe: recipe.__name__, slot, className, element, anchors })
1037
+ }
1038
+ }
1039
+ }
3597
1040
 
3598
- const mergedProps = computed(() => {
3599
- if (!options?.defaultProps) return otherProps
3600
- return { ...options.defaultProps, ...otherProps }
3601
- })
1041
+ if (!found.length) return found
1042
+
1043
+ if (onReport) {
1044
+ onReport(found)
1045
+ } else {
1046
+ for (const problem of found) {
1047
+ console.warn(
1048
+ \`[bamboo] \${problem.recipe ?? 'slot recipe'}: the \\\`\${problem.slot}\\\` slot is rendered outside every \` +
1049
+ \`anchor (\${problem.anchors.join(', ')}), so its variant styles cannot reach it. \` +
1050
+ \`Add the enclosing slot to \\\`scopeRoots\\\`, or deliver the variant to this slot by hand.\`,
1051
+ problem.element,
1052
+ )
1053
+ }
1054
+ }
3602
1055
 
3603
- return () => h(Component, mergedProps.value, slots)
3604
- },
3605
- })
3606
-
3607
- const componentName = getDisplayName(Component)
3608
- WithRootProvider.displayName = \`withRootProvider(\${componentName})\`
3609
-
3610
- return WithRootProvider
1056
+ return found
3611
1057
  }
3612
1058
 
3613
- const withProvider = (Component, slot, options) => {
3614
- const StyledComponent = ${factoryName}(Component, {}, options)
3615
-
3616
- const WithProvider = defineComponent({
3617
- props: ["unstyled", ...svaFn.variantKeys],
3618
- inheritAttrs: false,
3619
- setup(inProps, { slots, attrs }) {
3620
- const props = computed(() => {
3621
- const propsWithClass = { ...inProps, ...attrs }
3622
- propsWithClass.class = propsWithClass.class ?? options?.defaultProps?.class
3623
- return propsWithClass
3624
- })
3625
- const res = computed(() => {
3626
- const [variantProps, restProps] = svaFn.splitVariantProps(props.value)
3627
- return { variantProps, restProps }
3628
- })
3629
-
3630
- const slotStyles = computed(() => {
3631
- const styles = isConfigRecipe ? svaFn(res.value.variantProps) : svaFn.raw(res.value.variantProps)
3632
- styles._classNameMap = svaFn.classNameMap
3633
- return styles
3634
- })
3635
-
3636
- provide(StyleContext, slotStyles)
3637
-
3638
- return () => {
3639
- const resolvedProps = getResolvedProps(res.value.restProps, slotStyles.value[slot])
3640
- resolvedProps.class = cx(resolvedProps.class, slotStyles.value._classNameMap[slot], attrs.class)
3641
- return h(StyledComponent, resolvedProps, slots)
3642
- }
3643
- },
3644
- })
3645
-
3646
- const componentName = getDisplayName(Component)
3647
- WithProvider.displayName = \`withProvider(\${componentName})\`
3648
-
3649
- return WithProvider
3650
- }
1059
+ audit()
3651
1060
 
3652
- const withContext = (Component, slot, options) => {
3653
- const StyledComponent = ${factoryName}(Component, {}, options)
3654
- const componentName = getDisplayName(Component)
3655
-
3656
- const WithContext = defineComponent({
3657
- props: ["unstyled"],
3658
- inheritAttrs: false,
3659
- setup(inProps, { slots, attrs }) {
3660
- const props = computed(() => {
3661
- const propsWithClass = { ...inProps, ...attrs }
3662
- propsWithClass.class = propsWithClass.class ?? options?.defaultProps?.class
3663
- return propsWithClass
3664
- })
3665
- const slotStyles = useStyleContext(componentName, slot)
3666
-
3667
- return () => {
3668
- const resolvedProps = getResolvedProps(props.value, slotStyles.value[slot])
3669
- resolvedProps.class = cx(resolvedProps.class, slotStyles.value._classNameMap[slot], attrs.class)
3670
- return h(StyledComponent, resolvedProps, slots)
3671
- }
3672
- },
1061
+ if (!observe || typeof MutationObserver === 'undefined') return () => {}
1062
+
1063
+ // Portaled content mounts after the first sweep, which is exactly the case this
1064
+ // exists to catch, so a one-shot pass would miss it.
1065
+ let queued = false
1066
+ const observer = new MutationObserver(() => {
1067
+ if (queued) return
1068
+ queued = true
1069
+ queueMicrotask(() => {
1070
+ queued = false
1071
+ audit()
3673
1072
  })
3674
-
3675
- WithContext.displayName = \`withContext(\${componentName})\`
3676
-
3677
- return WithContext
3678
- }
1073
+ })
1074
+ observer.observe(root === document ? document.documentElement : root, { childList: true, subtree: true })
3679
1075
 
3680
- return {
3681
- withRootProvider,
3682
- withProvider,
3683
- withContext,
3684
- }
1076
+ return () => observer.disconnect()
3685
1077
  }
3686
1078
  `,
3687
1079
  dts: outdent`
3688
- ${ctx.file.importType("SlotRecipeRuntimeFn, RecipeVariantProps", "../types/recipe")}
3689
- ${ctx.file.importType("JsxHTMLProps, JsxStyleProps, Assign", "../types/system-types")}
3690
- ${ctx.file.importType("JsxFactoryOptions, DataAttrs, AsProps", "../types/jsx")}
3691
- import type { Component, FunctionalComponent, NativeElements } from 'vue'
3692
-
3693
- interface UnstyledProps {
3694
- unstyled?: boolean | undefined
3695
- }
1080
+ ${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
3696
1081
 
3697
- interface WithProviderOptions<P = {}> {
3698
- defaultProps?: (Partial<P> & DataAttrs) | undefined
3699
- }
1082
+ export declare const sva: SlotRecipeCreatorFn
3700
1083
 
3701
- // Add v-model support types
3702
- interface VModelProps {
3703
- modelValue?: any
3704
- 'onUpdate:modelValue'?: (value: any) => void
1084
+ export interface SlotScopeProblem {
1085
+ /** The recipe the slot belongs to, when it has a name. */
1086
+ recipe?: string
1087
+ /** The slot whose variant styles cannot reach it. */
1088
+ slot: string
1089
+ /** The constant class that slot carries. */
1090
+ className: string
1091
+ /** The element found outside every anchor. */
1092
+ element: Element
1093
+ /** The anchors that were looked for. */
1094
+ anchors: string[]
3705
1095
  }
3706
1096
 
3707
- type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
3708
- interface SlotRecipeFn {
3709
- __type: any
3710
- __slot: string
3711
- (props?: any): any
3712
- }
3713
- type SlotRecipe = SvaFn | SlotRecipeFn
3714
-
3715
- type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
3716
-
3717
- type IntrinsicElement = keyof NativeElements
3718
- type ElementType = IntrinsicElement | Component
3719
-
3720
- type ComponentProps<T extends ElementType> = T extends IntrinsicElement
3721
- ? NativeElements[T]
3722
- : T extends Component<infer Props>
3723
- ? Props
3724
- : never
3725
-
3726
- type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = FunctionalComponent<
3727
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps & VModelProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
3728
- >
3729
-
3730
- type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = FunctionalComponent<
3731
- ComponentProps<T> & UnstyledProps & VModelProps & RecipeVariantProps<R>
3732
- >
3733
-
3734
- type StyleContextConsumer<T extends ElementType> = FunctionalComponent<
3735
- JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps & VModelProps, JsxStyleProps>
3736
- >
3737
-
3738
- export interface StyleContext<R extends SlotRecipe> {
3739
- withRootProvider: <T extends ElementType>(
3740
- Component: T,
3741
- options?: WithProviderOptions<ComponentProps<T>> | undefined
3742
- ) => StyleContextRootProvider<T, R>
3743
- withProvider: <T extends ElementType>(
3744
- Component: T,
3745
- slot: InferSlot<R>,
3746
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
3747
- ) => StyleContextProvider<T, R>
3748
- withContext: <T extends ElementType>(
3749
- Component: T,
3750
- slot: InferSlot<R>,
3751
- options?: JsxFactoryOptions<ComponentProps<T>> | undefined
3752
- ) => StyleContextConsumer<T>
1097
+ export interface AuditSlotScopesOptions {
1098
+ /** Where to look. Defaults to \`document\`. */
1099
+ root?: ParentNode
1100
+ /** Re-check as the DOM changes, for content that mounts through a portal. */
1101
+ observe?: boolean
1102
+ /** Handle the findings yourself instead of warning to the console. */
1103
+ onReport?: (problems: SlotScopeProblem[]) => void
3753
1104
  }
3754
1105
 
3755
- export declare function createStyleContext<R extends SlotRecipe>(recipe: R): StyleContext<R>
1106
+ /**
1107
+ * Report slots whose variant styles can never reach them, in development.
1108
+ *
1109
+ * A scoped slot is styled through an \`@scope\` rule opened at an anchor, so it has to be
1110
+ * rendered inside one. A slot moved out of every anchor's subtree keeps its base styles
1111
+ * and silently loses its variant styles — which no build step can catch, because whether
1112
+ * one element is inside another is a fact about the DOM.
1113
+ *
1114
+ * Returns a function that stops observing.
1115
+ */
1116
+ export declare function auditSlotScopes(
1117
+ recipes: ReadonlyArray<unknown>,
1118
+ options?: AuditSlotScopesOptions,
1119
+ ): () => void
3756
1120
  `
3757
1121
  };
3758
1122
  }
3759
1123
  //#endregion
3760
- //#region src/artifacts/vue-jsx/jsx.string-literal.ts
3761
- function generateVueJsxStringLiteralFactory(ctx) {
3762
- const { componentName, factoryName } = ctx.jsx;
3763
- return { js: outdent`
3764
- import { defineComponent, h, computed } from 'vue'
3765
- ${ctx.file.import("getDisplayName", "./factory-helper")}
3766
- ${ctx.file.import("css, cx", "../css/index")}
3767
-
3768
- function createStyled(Dynamic) {
3769
- const name = getDisplayName(Dynamic)
3770
- const __base__ = Dynamic.__base__ || Dynamic
3771
-
3772
- function styledFn(template) {
3773
- const styles = css.raw(Dynamic.__styles__, template)
3774
-
3775
- const ${componentName} = defineComponent({
3776
- name: \`${factoryName}.\${name}\`,
3777
- inheritAttrs: false,
3778
- props: {
3779
- modelValue: null,
3780
- as: { type: [String, Object], default: __base__ }
3781
- },
3782
- setup(props, { slots, attrs, emit }) {
3783
- const classes = computed(() => {
3784
- return cx(css(styles), attrs.className)
3785
- })
3786
-
3787
- const vModelProps = computed(() => {
3788
- const result = {};
3789
-
3790
- if (
3791
- props.as === 'input' &&
3792
- (props.type === 'checkbox' || props.type === 'radio')
3793
- ) {
3794
- result.checked = props.modelValue;
3795
- result.onChange = (event) => {
3796
- const checked = !event.currentTarget.checked;
3797
- emit('change', checked, event);
3798
- emit('update:modelValue', checked, event);
3799
- };
3800
- } else if (
3801
- props.as === 'input' ||
3802
- props.as === 'textarea' ||
3803
- props.as === 'select'
3804
- ) {
3805
- result.value = props.modelValue;
3806
- result.onInput = (event) => {
3807
- const value = event.currentTarget.value;
3808
- emit('input', value, event);
3809
- emit('update:modelValue', value, event);
3810
- };
3811
- }
3812
-
3813
- return result;
3814
- });
3815
-
3816
- return () => {
3817
- return h(
3818
- props.as,
3819
- {
3820
- class: classes.value,
3821
- ...attrs,
3822
- ...vModelProps.value,
3823
- },
3824
- slots
3825
- )
3826
- }
3827
- },
3828
- })
3829
-
3830
- ${componentName}.__styles__ = styles
3831
- ${componentName}.__base__ = __base__
3832
-
3833
- return ${componentName}
3834
- }
3835
-
3836
- return styledFn
3837
- }
3838
-
3839
- const tags = 'a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, big, blockquote, body, br, button, canvas, caption, cite, code, col, colgroup, data, datalist, dd, del, details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, input, ins, kbd, keygen, label, legend, li, link, main, map, mark, marquee, menu, menuitem, meta, meter, nav, noscript, object, ol, optgroup, option, output, p, param, picture, pre, progress, q, rp, rt, ruby, s, samp, script, section, select, small, source, span, strong, style, sub, summary, sup, table, tbody, td, textarea, tfoot, th, thead, time, title, tr, track, u, ul, var, video, wbr, circle, clipPath, defs, ellipse, foreignObject, g, image, line, linearGradient, mask, path, pattern, polygon, polyline, radialGradient, rect, stop, svg, text, tspan';
3840
-
3841
- export const ${factoryName} = /* @__PURE__ */ createStyled.bind();
3842
-
3843
- tags.split(', ').forEach((tag) => {
3844
- ${factoryName}[tag] = createStyled(tag);
3845
- });
3846
- ` };
3847
- }
3848
- //#endregion
3849
- //#region src/artifacts/vue-jsx/types.string-literal.ts
3850
- function generateVueJsxStringLiteralTypes(ctx) {
3851
- const { factoryName, componentName, upperName, typeName } = ctx.jsx;
1124
+ //#region src/artifacts/js/token.ts
1125
+ function generateTokenJs(ctx) {
1126
+ const { tokens } = ctx;
1127
+ const map = /* @__PURE__ */ new Map();
1128
+ tokens.allTokens.forEach((token) => {
1129
+ const { varRef, isVirtual } = token.extensions;
1130
+ const value = isVirtual || token.extensions.condition !== "base" ? varRef : token.value;
1131
+ map.set(token.name, {
1132
+ value,
1133
+ variable: varRef
1134
+ });
1135
+ });
1136
+ const obj = Object.fromEntries(map);
3852
1137
  return {
3853
- jsxFactory: outdent`
3854
- ${ctx.file.importType(upperName, "../types/jsx")}
3855
-
3856
- export declare const ${factoryName}: ${upperName}
3857
- `,
3858
- jsxType: outdent`
3859
- import type { Component, FunctionalComponent, NativeElements } from 'vue'
3860
-
3861
- export type IntrinsicElement = keyof NativeElements
3862
-
3863
- export type ElementType = IntrinsicElement | Component
3864
-
3865
- export type ComponentProps<T extends ElementType> = T extends IntrinsicElement
3866
- ? NativeElements[T]
3867
- : T extends Component<infer Props>
3868
- ? Props
3869
- : never
3870
-
3871
- export interface AsProps {
3872
- /**
3873
- * The element to render as
3874
- */
3875
- as?: ElementType | undefined
3876
- }
1138
+ js: outdent$1`
1139
+ const tokens = ${JSON.stringify(obj, null, 2)}
3877
1140
 
3878
- export type ${componentName}<T extends ElementType> = {
3879
- (args: { raw: readonly string[] | ArrayLike<string> }): FunctionalComponent<ComponentProps<T> & AsProps>
3880
- }
1141
+ export function token(path, fallback) {
1142
+ return tokens[path]?.value || fallback
1143
+ }
3881
1144
 
3882
- export interface JsxFactory {
3883
- <T extends ElementType>(component: T): ${componentName}<T>
3884
- }
1145
+ function tokenVar(path, fallback) {
1146
+ return tokens[path]?.variable || fallback
1147
+ }
3885
1148
 
3886
- export type JsxElements = {
3887
- [K in IntrinsicElement]: ${componentName}<K>
3888
- }
1149
+ token.var = tokenVar
1150
+ `,
1151
+ dts: outdent$1`
1152
+ ${ctx.file.importType("Token", "./tokens")}
3889
1153
 
3890
- export type ${upperName} = JsxFactory & JsxElements
1154
+ export declare const token: {
1155
+ (path: Token, fallback?: string): string
1156
+ var: (path: Token, fallback?: string) => string
1157
+ }
3891
1158
 
3892
- export type ${typeName}<T extends ElementType> = ComponentProps<T>
1159
+ ${ctx.file.exportTypeStar("./tokens")}
3893
1160
  `
3894
1161
  };
3895
1162
  }
3896
1163
  //#endregion
3897
- //#region src/artifacts/jsx.ts
3898
- const typesMap = {
3899
- react: generateReactJsxTypes,
3900
- preact: generatePreactJsxTypes,
3901
- solid: generateSolidJsxTypes,
3902
- vue: generateVueJsxTypes,
3903
- qwik: generateQwikJsxTypes
3904
- };
3905
- const typesStringLiteralMap = {
3906
- react: generateReactJsxStringLiteralTypes,
3907
- solid: generateSolidJsxStringLiteralTypes,
3908
- qwik: generateQwikJsxStringLiteralTypes,
3909
- preact: generatePreactJsxStringLiteralTypes,
3910
- vue: generateVueJsxStringLiteralTypes
3911
- };
3912
- const isKnownFramework = (framework) => Boolean(typesMap[framework]);
3913
- function generateJsxTypes(ctx) {
3914
- if (!ctx.jsx.framework) return;
3915
- if (!isKnownFramework(ctx.jsx.framework)) return;
3916
- return (ctx.isTemplateLiteralSyntax ? typesStringLiteralMap[ctx.jsx.framework] : typesMap[ctx.jsx.framework])?.(ctx);
3917
- }
3918
- const factoryMap = {
3919
- react: generateReactJsxFactory,
3920
- solid: generateSolidJsxFactory,
3921
- preact: generatePreactJsxFactory,
3922
- vue: generateVueJsxFactory,
3923
- qwik: generateQwikJsxFactory
3924
- };
3925
- const factoryStringLiteralMap = {
3926
- react: generateReactJsxStringLiteralFactory,
3927
- solid: generateSolidJsxStringLiteralFactory,
3928
- qwik: generateQwikJsxStringLiteralFactory,
3929
- preact: generatePreactJsxStringLiteralFactory,
3930
- vue: generateVueJsxStringLiteralFactory
3931
- };
3932
- function generateJsxFactory(ctx) {
3933
- if (!ctx.jsx.framework) return;
3934
- if (!isKnownFramework(ctx.jsx.framework)) return;
3935
- return (ctx.isTemplateLiteralSyntax ? factoryStringLiteralMap[ctx.jsx.framework] : factoryMap[ctx.jsx.framework])?.(ctx);
3936
- }
3937
- const patternMap = {
3938
- react: generateReactJsxPattern,
3939
- solid: generateSolidJsxPattern,
3940
- preact: generatePreactJsxPattern,
3941
- vue: generateVueJsxPattern,
3942
- qwik: generateQwikJsxPattern
3943
- };
3944
- function generateJsxPatterns(ctx, filters) {
3945
- if (ctx.isTemplateLiteralSyntax || ctx.patterns.isEmpty() || !ctx.jsx.framework) return [];
3946
- if (!isKnownFramework(ctx.jsx.framework)) return;
3947
- return patternMap[ctx.jsx.framework](ctx, filters);
3948
- }
3949
- const createStyleContextMap = {
3950
- react: generateReactCreateStyleContext,
3951
- preact: generatePreactCreateStyleContext,
3952
- solid: generateSolidCreateStyleContext,
3953
- vue: generateVueCreateStyleContext
3954
- };
3955
- function generateJsxCreateStyleContext(ctx) {
3956
- if (ctx.isTemplateLiteralSyntax || !ctx.jsx.framework) return;
3957
- if (!isKnownFramework(ctx.jsx.framework)) return;
3958
- const generator = createStyleContextMap[ctx.jsx.framework];
3959
- return generator?.(ctx);
3960
- }
3961
- //#endregion
3962
1164
  //#region src/artifacts/generated/composition.d.ts.json
3963
1165
  var content$7 = "import type { CompositionStyleObject } from './system-types'\n\ninterface Token<T> {\n value: T\n description?: string\n}\n\ninterface Recursive<T> {\n [key: string]: Recursive<T> | T\n}\n\n/* -----------------------------------------------------------------------------\n * Text styles\n * -----------------------------------------------------------------------------*/\n\ntype TextStyleProperty =\n | 'color'\n | 'direction'\n | 'font'\n | 'fontFamily'\n | 'fontFeatureSettings'\n | 'fontKerning'\n | 'fontLanguageOverride'\n | 'fontOpticalSizing'\n | 'fontPalette'\n | 'fontSize'\n | 'fontSizeAdjust'\n | 'fontStretch'\n | 'fontStyle'\n | 'fontSynthesis'\n | 'fontVariant'\n | 'fontVariantAlternates'\n | 'fontVariantCaps'\n | 'fontVariantLigatures'\n | 'fontVariantNumeric'\n | 'fontVariantPosition'\n | 'fontVariationSettings'\n | 'fontWeight'\n | 'hangingPunctuation'\n | 'hypens'\n | 'hyphenateCharacter'\n | 'hyphenateLimitChars'\n | 'letterSpacing'\n | 'lineBreak'\n | 'lineHeight'\n | 'quotes'\n | 'overflowWrap'\n | 'tabSize'\n | 'textAlign'\n | 'textAlignLast'\n | 'textBox'\n | 'textBoxEdge'\n | 'textBoxTrim'\n | 'textCombineUpright'\n | 'textDecoration'\n | 'textDecorationColor'\n | 'textDecorationLine'\n | 'textDecorationSkip'\n | 'textDecorationSkipBox'\n | 'textDecorationSkipInk'\n | 'textDecorationSkipInset'\n | 'textDecorationStyle'\n | 'textDecorationThickness'\n | 'textEmphasis'\n | 'textEmphasisColor'\n | 'textEmphasisPosition'\n | 'textEmphasisStyle'\n | 'textIndent'\n | 'textJustify'\n | 'textOrientation'\n | 'textOverflow'\n | 'textRendering'\n | 'textShadow'\n | 'textStroke'\n | 'textStrokeColor'\n | 'textStrokeWidth'\n | 'textTransform'\n | 'textUnderlineOffset'\n | 'textUnderlinePosition'\n | 'textWrap'\n | 'textWrapMode'\n | 'textWrapStyle'\n | 'unicodeBidi'\n | 'verticalAlign'\n | 'whiteSpace'\n | 'wordBreak'\n | 'wordSpacing'\n | 'writingMode'\n\nexport type TextStyle = CompositionStyleObject<TextStyleProperty>\n\nexport type TextStyles = Recursive<Token<TextStyle>>\n\n/* -----------------------------------------------------------------------------\n * Layer styles\n * -----------------------------------------------------------------------------*/\n\ntype LogicalPlacement = 'Inline' | 'Block' | 'InlineStart' | 'InlineEnd' | 'BlockStart' | 'BlockEnd'\n\ntype PhysicalPlacement = 'Top' | 'Right' | 'Bottom' | 'Left'\n\ntype Placement = PhysicalPlacement | LogicalPlacement\n\ntype Radius =\n | `Top${'Right' | 'Left'}`\n | `Bottom${'Right' | 'Left'}`\n | `Start${'Start' | 'End'}`\n | `End${'Start' | 'End'}`\n\ntype LayerStyleProperty =\n | 'aspectRatio'\n | 'background'\n | 'backgroundColor'\n | 'backgroundImage'\n | 'border'\n | 'borderColor'\n | 'borderImage'\n | 'borderImageOutset'\n | 'borderImageRepeat'\n | 'borderImageSlice'\n | 'borderImageSource'\n | 'borderImageWidth'\n | 'borderRadius'\n | 'borderStyle'\n | 'borderWidth'\n | `border${Placement}`\n | `border${Placement}Color`\n | `border${Placement}Style`\n | `border${Placement}Width`\n | 'borderRadius'\n | `border${Radius}Radius`\n | 'boxShadow'\n | 'boxShadowColor'\n | 'clipPath'\n | 'color'\n | 'contain'\n | 'content'\n | 'contentVisibility'\n | 'cursor'\n | 'display'\n | 'filter'\n | 'backdropFilter'\n | 'height'\n | 'width'\n | 'minHeight'\n | 'minWidth'\n | 'maxHeight'\n | 'maxWidth'\n | `margin${Placement}`\n | 'inset'\n | `inset${LogicalPlacement}`\n | Lowercase<PhysicalPlacement>\n | 'isolation'\n | 'mask'\n | 'maskClip'\n | 'maskComposite'\n | 'maskImage'\n | 'maskMode'\n | 'maskOrigin'\n | 'maskPosition'\n | 'maskRepeat'\n | 'maskSize'\n | 'mixBlendMode'\n | 'objectFit'\n | 'objectPosition'\n | 'opacity'\n | 'outline'\n | 'outlineColor'\n | 'outlineOffset'\n | 'outlineStyle'\n | 'outlineWidth'\n | 'overflow'\n | 'overflowX'\n | 'overflowY'\n | 'padding'\n | `padding${Placement}`\n | 'pointerEvents'\n | 'position'\n | 'resize'\n | 'transform'\n | 'transition'\n | 'visibility'\n | 'willChange'\n | 'zIndex'\n | 'backgroundBlendMode'\n | 'backgroundAttachment'\n | 'backgroundClip'\n | 'backgroundOrigin'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundSize'\n\nexport type LayerStyle = CompositionStyleObject<LayerStyleProperty>\n\nexport type LayerStyles = Recursive<Token<LayerStyle>>\n\n/* -----------------------------------------------------------------------------\n * Motion styles\n * -----------------------------------------------------------------------------*/\n\ntype AnimationStyleProperty =\n | 'animation'\n | 'animationComposition'\n | 'animationDelay'\n | 'animationDirection'\n | 'animationDuration'\n | 'animationFillMode'\n | 'animationIterationCount'\n | 'animationName'\n | 'animationPlayState'\n | 'animationTimingFunction'\n | 'animationRange'\n | 'animationRangeStart'\n | 'animationRangeEnd'\n | 'animationTimeline'\n | 'transformOrigin'\n\nexport type AnimationStyle = CompositionStyleObject<AnimationStyleProperty>\n\nexport type AnimationStyles = Recursive<Token<AnimationStyle>>\n\nexport interface CompositionStyles {\n textStyles: TextStyles\n layerStyles: LayerStyles\n animationStyles: AnimationStyles\n}\n";
3964
1166
  //#endregion
@@ -4718,10 +1920,10 @@ var comments = {
4718
1920
  var content$5 = "export interface Part {\n selector: string\n}\n\nexport interface Parts {\n [key: string]: Part\n}\n";
4719
1921
  //#endregion
4720
1922
  //#region src/artifacts/generated/pattern.d.ts.json
4721
- var content$4 = "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; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface 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 default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n";
1923
+ var content$4 = "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; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface 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 properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | 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";
4722
1924
  //#endregion
4723
1925
  //#region src/artifacts/generated/recipe.d.ts.json
4724
- var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The class name of the recipe.\n */\n className: string\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * An optional class name that can be used to target slots in the DOM.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> & RecipeConfigMeta\n";
1926
+ var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * The prefix every class this recipe emits is built from — `button` gives `button` for\n * the base styles and `button--size_sm` for a variant.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`, which is otherwise named by hashing its own\n * config: `cva_a1b2c3--size_sm`. Setting it buys readable class names and nothing else —\n * the CSS is identical either way.\n *\n * It has to be unique across every recipe in the build. Two recipes sharing a name emit\n * rules under the same selectors, and the later one wins for any variant they both\n * declare.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {\n /** Optional on `RecipeDefinition`, where an inline `cva` falls back to hashing its config. A recipe declared in `theme.recipes` always has one — the key it is declared under. */\n className: string\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n variantKeys: (keyof T)[]\n variantMap: RecipeVariantMap<T>\n /** The config this recipe was created from. */\n config: SlotRecipeDefinition<S, T>\n /** Each slot's constant class, for targeting a slot in the DOM. */\n classNameMap: Partial<Record<S, string>>\n /**\n * Which slots each variant writes styles for.\n *\n * A variant's styles reach a slot through a scope opened at an anchor, which covers every\n * slot in that anchor's subtree. A slot under no anchor — moved out by a portal, with no\n * second anchor named in `scopeRoots` — is not reached, and nothing at build time can\n * detect that. This says which slots a variant has to get to, so whatever a scope cannot\n * reach can be threaded by hand.\n */\n slotsAffectedBy: Record<keyof T, S[]>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * The prefix every class this recipe emits is built from, and the name to target its\n * slots in the DOM by — `checkbox` gives `checkbox__control` for a slot and\n * `checkbox__control--size_md` for that slot under a variant.\n *\n * Required for a recipe declared in `theme.slotRecipes`, where it is the key it is\n * declared under. Optional for an inline `sva`, which is otherwise named by hashing its\n * own config. Setting it buys readable class names and nothing else — the CSS is\n * identical either way.\n *\n * It has to be unique across every recipe in the build.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The slots that enclose other slots, used to scope their variant styles.\n *\n * A slot recipe's variants are chosen once, at the top, but the slots that react to them\n * are authored by the consumer somewhere below. Naming the enclosing slots lets the build\n * emit their variant styles as rules scoped by a class those slots already carry, so\n * nothing has to be delivered to a slot at runtime and every other slot's class is a\n * constant.\n *\n * A list, because a portal is a real discontinuity in the tree and no CSS mechanism\n * crosses one. A `<Select>` occupies two disjoint subtrees — the trigger side under\n * `root`, the listbox side under a portaled `positioner` — and a variant writes styles\n * into both. One anchor can only ever reach one of them.\n *\n * ```ts\n * scopeRoots: ['root', 'positioner']\n * ```\n *\n * Each named slot takes variant props; every other slot's class is a constant. The build\n * emits each non-anchor slot's variant rules under *every* anchor, and only the anchor\n * that is genuinely an ancestor matches — so the DOM shape never has to be declared.\n *\n * Defaults to `['root']` when a slot by that name exists. Set `[]` to turn scoping off\n * and give every slot a variant class of its own, which is what a recipe whose slots are\n * siblings wants.\n *\n * A slot under *no* anchor is still unreachable, and nothing at build time can detect\n * that — reachability is a fact about the DOM. `recipe.slotsAffectedBy` says which slots\n * a variant writes to, for whatever still needs threading by hand.\n */\n scopeRoots?: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> &\n RecipeConfigMeta & {\n /** Optional on `SlotRecipeDefinition`, where an inline `sva` falls back to hashing its config. A recipe declared in `theme.slotRecipes` always has one — the key it is declared under. */\n className: string\n }\n";
4725
1927
  //#endregion
4726
1928
  //#region src/artifacts/generated/selectors.d.ts.json
4727
1929
  var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes =\n | '[aria-disabled]'\n | '[aria-hidden]'\n | '[aria-invalid]'\n | '[aria-readonly]'\n | '[aria-required]'\n | '[aria-selected]'\n | '[aria-checked]'\n | '[aria-expanded]'\n | '[aria-pressed]'\n | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`\n | '[aria-invalid]'\n | `[aria-sort=${'ascending' | 'descending'}]`\n\ntype DataAttributes =\n | '[data-selected]'\n | '[data-highlighted]'\n | '[data-hover]'\n | '[data-active]'\n | '[data-checked]'\n | '[data-disabled]'\n | '[data-readonly]'\n | '[data-focus]'\n | '[data-focus-visible]'\n | '[data-focus-visible-added]'\n | '[data-invalid]'\n | '[data-pressed]'\n | '[data-expanded]'\n | '[data-grabbed]'\n | '[data-dragged]'\n | '[data-orientation=horizontal]'\n | '[data-orientation=vertical]'\n | '[data-in-range]'\n | '[data-out-of-range]'\n | '[data-placeholder-shown]'\n | `[data-part=${string}]`\n | `[data-attr=${string}]`\n | `[data-placement=${string}]`\n | `[data-theme=${string}]`\n | `[data-size=${string}]`\n | `[data-state=${string}]`\n | '[data-empty]'\n | '[data-loading]'\n | '[data-loaded]'\n | '[data-enter]'\n | '[data-entering]'\n | '[data-exited]'\n | '[data-exiting]'\n\ntype AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`\ntype ParentSelector = `${DataAttributes | AriaAttributes} &`\n\ntype AtRuleType = 'media' | 'layer' | 'container' | 'supports' | 'page' | 'scope' | 'starting-style'\n\nexport type AnySelector = `${string}&` | `&${string}` | `@${AtRuleType}${string}`\nexport type Selectors = AttributeSelector | ParentSelector\n";
@@ -4744,20 +1946,18 @@ function getGeneratedTypes(ctx) {
4744
1946
  selectors: ctx.file.rewriteTypeImport(content$2)
4745
1947
  };
4746
1948
  }
4747
- const jsxStyleProps = "export type JsxStyleProps = SystemStyleObject & WithCss";
4748
1949
  function getGeneratedSystemTypes(ctx) {
4749
- return { system: ctx.file.rewriteTypeImport(match(ctx.jsx.styleProps).with("all", () => content).with("minimal", () => content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")).with("none", () => content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = {}")).exhaustive()) };
1950
+ return { system: ctx.file.rewriteTypeImport(content) };
4750
1951
  }
4751
1952
  //#endregion
4752
1953
  //#region src/artifacts/types/main.ts
4753
- const generateTypesEntry = (ctx, isJsxRequired) => {
1954
+ const generateTypesEntry = (ctx) => {
4754
1955
  const indexExports = [
4755
1956
  `import '${ctx.file.extDts("./global")}'`,
4756
1957
  ctx.file.exportTypeStar("./conditions"),
4757
1958
  ctx.file.exportTypeStar("./pattern"),
4758
1959
  ctx.file.exportTypeStar("./recipe"),
4759
1960
  ctx.file.exportTypeStar("./system-types"),
4760
- isJsxRequired && ctx.file.exportTypeStar("./jsx"),
4761
1961
  ctx.file.exportTypeStar("./style-props")
4762
1962
  ].filter(Boolean);
4763
1963
  return {
@@ -5262,7 +2462,7 @@ function generateThemesIndex(ctx, files) {
5262
2462
  //#endregion
5263
2463
  //#region src/artifacts/setup-artifacts.ts
5264
2464
  function setupHelpers(ctx) {
5265
- const code = generateHelpers(ctx);
2465
+ const code = generateHelpers();
5266
2466
  return {
5267
2467
  id: "helpers",
5268
2468
  files: [{
@@ -5301,21 +2501,8 @@ function setupDesignTokens(ctx) {
5301
2501
  ]
5302
2502
  };
5303
2503
  }
5304
- function setupJsxTypes(ctx) {
5305
- if (!ctx.jsx.framework) return;
5306
- const jsx = generateJsxTypes(ctx);
5307
- if (!jsx) return;
5308
- return {
5309
- id: "types-jsx",
5310
- dir: ctx.paths.types,
5311
- files: [{
5312
- file: ctx.file.extDts("jsx"),
5313
- code: jsx.jsxType
5314
- }]
5315
- };
5316
- }
5317
2504
  function setupEntryTypes(ctx) {
5318
- const entry = generateTypesEntry(ctx, Boolean(ctx.jsx.framework));
2505
+ const entry = generateTypesEntry(ctx);
5319
2506
  return {
5320
2507
  id: "types-entry",
5321
2508
  dir: ctx.paths.types,
@@ -5401,29 +2588,29 @@ function setupGeneratedSystemTypes(ctx) {
5401
2588
  };
5402
2589
  }
5403
2590
  function setupCss(ctx) {
5404
- const code = ctx.isTemplateLiteralSyntax ? generateStringLiteralCssFn(ctx) : generateCssFn(ctx);
5405
- const conditions = ctx.isTemplateLiteralSyntax ? generateStringLiteralConditions(ctx) : generateConditions(ctx);
2591
+ const code = generateCssFn(ctx);
2592
+ const conditions = generateConditions(ctx);
2593
+ const files = [
2594
+ {
2595
+ file: ctx.file.ext("conditions"),
2596
+ code: conditions.js
2597
+ },
2598
+ {
2599
+ file: ctx.file.ext("css"),
2600
+ code: code.js
2601
+ },
2602
+ {
2603
+ file: ctx.file.extDts("css"),
2604
+ code: code.dts
2605
+ }
2606
+ ];
5406
2607
  return {
5407
2608
  id: "css-fn",
5408
2609
  dir: ctx.paths.css,
5409
- files: [
5410
- {
5411
- file: ctx.file.ext("conditions"),
5412
- code: conditions.js
5413
- },
5414
- {
5415
- file: ctx.file.ext("css"),
5416
- code: code.js
5417
- },
5418
- {
5419
- file: ctx.file.extDts("css"),
5420
- code: code.dts
5421
- }
5422
- ]
2610
+ files
5423
2611
  };
5424
2612
  }
5425
2613
  function setupCva(ctx) {
5426
- if (ctx.isTemplateLiteralSyntax) return;
5427
2614
  const code = generateCvaFn(ctx);
5428
2615
  return {
5429
2616
  id: "cva",
@@ -5438,7 +2625,6 @@ function setupCva(ctx) {
5438
2625
  };
5439
2626
  }
5440
2627
  function setupSva(ctx) {
5441
- if (ctx.isTemplateLiteralSyntax) return;
5442
2628
  const code = generateSvaFn(ctx);
5443
2629
  return {
5444
2630
  id: "sva",
@@ -5453,7 +2639,7 @@ function setupSva(ctx) {
5453
2639
  };
5454
2640
  }
5455
2641
  function setupCx(ctx) {
5456
- const code = generateCx(ctx);
2642
+ const code = generateCx();
5457
2643
  return {
5458
2644
  id: "cx",
5459
2645
  dir: ctx.paths.css,
@@ -5518,7 +2704,6 @@ function setupRecipes(ctx, filters) {
5518
2704
  };
5519
2705
  }
5520
2706
  function setupPatternsIndex(ctx) {
5521
- if (ctx.isTemplateLiteralSyntax) return;
5522
2707
  const fileNames = ctx.patterns.details.map((pattern) => pattern.dashName);
5523
2708
  const index = {
5524
2709
  js: outdent$1.string(fileNames.map((file) => ctx.file.exportStar(`./${file}`)).join("\n")),
@@ -5537,7 +2722,6 @@ function setupPatternsIndex(ctx) {
5537
2722
  };
5538
2723
  }
5539
2724
  function setupPatterns(ctx, filters) {
5540
- if (ctx.isTemplateLiteralSyntax) return;
5541
2725
  const files = generatePattern(ctx, filters);
5542
2726
  if (!files) return;
5543
2727
  return {
@@ -5552,127 +2736,19 @@ function setupPatterns(ctx, filters) {
5552
2736
  }])
5553
2737
  };
5554
2738
  }
5555
- function setupJsxIsValidProp(ctx) {
5556
- if (!ctx.jsx.framework || ctx.isTemplateLiteralSyntax) return;
5557
- const isValidProp = generateIsValidProp(ctx);
5558
- return {
5559
- id: "jsx-is-valid-prop",
5560
- dir: ctx.paths.jsx,
5561
- files: [{
5562
- file: ctx.file.ext("is-valid-prop"),
5563
- code: isValidProp?.js
5564
- }, {
5565
- file: ctx.file.extDts("is-valid-prop"),
5566
- code: isValidProp?.dts
5567
- }]
5568
- };
5569
- }
5570
- function setupJsxFactory(ctx) {
5571
- if (!ctx.jsx.framework) return;
5572
- const types = generateJsxTypes(ctx);
5573
- if (!types) return;
5574
- const factory = generateJsxFactory(ctx);
5575
- if (!factory) return;
5576
- return {
5577
- id: "jsx-factory",
5578
- dir: ctx.paths.jsx,
5579
- files: [{
5580
- file: ctx.file.ext("factory"),
5581
- code: factory?.js
5582
- }, {
5583
- file: ctx.file.extDts("factory"),
5584
- code: types.jsxFactory
5585
- }]
5586
- };
5587
- }
5588
- function setupJsxHelpers(ctx) {
5589
- if (!ctx.jsx.framework) return;
5590
- const helpers = generatedJsxHelpers(ctx);
5591
- return {
5592
- id: "jsx-helpers",
5593
- dir: ctx.paths.jsx,
5594
- files: [{
5595
- file: ctx.file.ext("factory-helper"),
5596
- code: helpers.js
5597
- }]
5598
- };
5599
- }
5600
- function setupJsxPatterns(ctx, filters) {
5601
- if (!ctx.jsx.framework || ctx.isTemplateLiteralSyntax) return;
5602
- const patterns = generateJsxPatterns(ctx, filters);
5603
- if (!patterns) return;
5604
- return {
5605
- id: "jsx-patterns",
5606
- dir: ctx.paths.jsx,
5607
- files: [...patterns.flatMap((file) => [{
5608
- file: ctx.file.ext(file.name),
5609
- code: file.js
5610
- }, {
5611
- file: ctx.file.extDts(file.name),
5612
- code: file.dts
5613
- }])]
5614
- };
5615
- }
5616
- function setupJsxCreateStyleContext(ctx) {
5617
- if (!ctx.jsx.framework || ctx.isTemplateLiteralSyntax) return;
5618
- const createStyleContext = generateJsxCreateStyleContext(ctx);
5619
- if (!createStyleContext) return;
5620
- return {
5621
- id: "jsx-create-style-context",
5622
- dir: ctx.paths.jsx,
5623
- files: [{
5624
- file: ctx.file.ext("create-style-context"),
5625
- code: createStyleContext.js
5626
- }, {
5627
- file: ctx.file.extDts("create-style-context"),
5628
- code: createStyleContext.dts
5629
- }]
5630
- };
5631
- }
5632
- function setupJsxPatternsIndex(ctx) {
5633
- if (!ctx.jsx.framework) return;
5634
- const isStyleProp = !ctx.isTemplateLiteralSyntax;
5635
- const patternNames = ctx.patterns.details.map((pattern) => pattern.dashName);
5636
- const index = {
5637
- js: outdent$1`
5638
- ${ctx.file.exportStar("./factory")}
5639
- ${isStyleProp ? ctx.file.exportStar("./is-valid-prop") : ""}
5640
- ${isStyleProp && !["qwik", "svelte"].includes(ctx.jsx.framework) ? ctx.file.exportStar("./create-style-context") : ""}
5641
- ${isStyleProp ? outdent$1.string(patternNames.map((file) => ctx.file.exportStar(`./${file}`)).join("\n")) : ""}
5642
- `,
5643
- dts: outdent$1`
5644
- ${ctx.file.exportTypeStar("./factory")}
5645
- ${isStyleProp ? ctx.file.exportTypeStar("./is-valid-prop") : ""}
5646
- ${isStyleProp ? ctx.file.exportTypeStar("./create-style-context") : ""}
5647
- ${isStyleProp ? outdent$1.string(patternNames.map((file) => ctx.file.exportTypeStar(`./${file}`)).join("\n")) : ""}
5648
- ${ctx.file.exportType([ctx.jsx.typeName, ctx.jsx.componentName].join(", "), "../types/jsx")}
5649
- `
5650
- };
5651
- return {
5652
- id: "jsx-patterns-index",
5653
- dir: ctx.paths.jsx,
5654
- files: [{
5655
- file: ctx.file.ext("index"),
5656
- code: index.js
5657
- }, {
5658
- file: ctx.file.extDts("index"),
5659
- code: index.dts
5660
- }]
5661
- };
5662
- }
5663
2739
  function setupCssIndex(ctx) {
5664
2740
  const index = {
5665
2741
  js: outdent$1`
5666
2742
  ${ctx.file.exportStar("./css")}
5667
2743
  ${ctx.file.exportStar("./cx")}
5668
- ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./cva")}
5669
- ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportStar("./sva")}
2744
+ ${ctx.file.exportStar("./cva")}
2745
+ ${ctx.file.exportStar("./sva")}
5670
2746
  `,
5671
2747
  dts: outdent$1`
5672
2748
  ${ctx.file.exportTypeStar("./css")}
5673
2749
  ${ctx.file.exportTypeStar("./cx")}
5674
- ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./cva")}
5675
- ${ctx.isTemplateLiteralSyntax ? "" : ctx.file.exportTypeStar("./sva")}
2750
+ ${ctx.file.exportTypeStar("./cva")}
2751
+ ${ctx.file.exportTypeStar("./sva")}
5676
2752
  `
5677
2753
  };
5678
2754
  return {
@@ -5723,7 +2799,7 @@ const filterArtifactsFiles = (artifacts, filters) => {
5723
2799
  if (affected.recipes && !item.file.includes("index") && artifact?.dir?.includes("recipes")) {
5724
2800
  if (!affected.recipes.some((recipe) => item.file.includes(recipe))) return;
5725
2801
  }
5726
- if (affected.patterns && !item.file.includes("index") && (artifact?.dir?.includes("patterns") || artifact?.dir?.includes("jsx"))) {
2802
+ if (affected.patterns && !item.file.includes("index") && artifact?.dir?.includes("patterns")) {
5727
2803
  if (!affected.patterns.some((pattern) => item.file.includes(pattern))) return;
5728
2804
  }
5729
2805
  return true;
@@ -5738,7 +2814,6 @@ const entries = [
5738
2814
  ["package.json", setupPackageJson],
5739
2815
  ["helpers", setupHelpers],
5740
2816
  ["design-tokens", setupDesignTokens],
5741
- ["types-jsx", setupJsxTypes],
5742
2817
  ["types-entry", setupEntryTypes],
5743
2818
  ["types-styles", setupStyleTypes],
5744
2819
  ["types-conditions", setupConditionsTypes],
@@ -5753,12 +2828,6 @@ const entries = [
5753
2828
  ["recipes", setupRecipes],
5754
2829
  ["patterns-index", setupPatternsIndex],
5755
2830
  ["patterns", setupPatterns],
5756
- ["jsx-is-valid-prop", setupJsxIsValidProp],
5757
- ["jsx-factory", setupJsxFactory],
5758
- ["jsx-helpers", setupJsxHelpers],
5759
- ["jsx-patterns", setupJsxPatterns],
5760
- ["jsx-create-style-context", setupJsxCreateStyleContext],
5761
- ["jsx-patterns-index", setupJsxPatternsIndex],
5762
2831
  ["css-index", setupCssIndex],
5763
2832
  ["themes", setupThemes]
5764
2833
  ];
@@ -5808,6 +2877,61 @@ const generateGlobalCss = (ctx, sheet) => {
5808
2877
  sheet.processGlobalCss(globalCss);
5809
2878
  };
5810
2879
  //#endregion
2880
+ //#region src/artifacts/js/group-registry.ts
2881
+ /**
2882
+ * The grouped class names an encoder has accumulated.
2883
+ *
2884
+ * Derived through `groupClassName`, the same function the browser runtime calls — a
2885
+ * registry built any other way would be a third spelling of a name that already has two.
2886
+ * Unescaped, unlike `StyleDecoder`'s class names: this is compared against what `css()`
2887
+ * returns into a `class` attribute, not against a selector.
2888
+ *
2889
+ * Reads from the encoder rather than the decoder so it is available as soon as extraction
2890
+ * is, and so `codegen` can emit whatever is already known instead of blanking the file.
2891
+ */
2892
+ function collectGroupClassNames(ctx) {
2893
+ const names = [];
2894
+ ctx.encoder.grouped.forEach((_hashes, groupId) => {
2895
+ names.push(groupClassName(groupId, ctx.utility.toHash, ctx.utility.formatClassName));
2896
+ });
2897
+ return names.sort();
2898
+ }
2899
+ /**
2900
+ * The grouped classes the build emitted a rule for.
2901
+ *
2902
+ * Under `cssMode: 'grouped'` a class names a whole `css()` call, so the build has to have
2903
+ * seen that exact call to emit its rule. This is how the runtime tells the difference: a
2904
+ * class in here has CSS behind it, and one that is not falls back to naming its
2905
+ * declarations atomically as well.
2906
+ *
2907
+ * Written by two passes. `codegen` emits whatever the encoder already holds — usually
2908
+ * nothing, since it runs on config change before anything is extracted, but not blank when
2909
+ * it runs after a build. The CSS build then rewrites it with the set it emitted.
2910
+ *
2911
+ * An empty or stale registry is safe by construction: the runtime *adds* to the group class
2912
+ * rather than replacing it, so the worst a miss can do is name a class that matches nothing.
2913
+ */
2914
+ function generateGroupRegistry(ctx, classNames) {
2915
+ const names = classNames ?? collectGroupClassNames(ctx);
2916
+ return {
2917
+ js: outdent`
2918
+ // Generated by bamboo. Rewritten on every CSS build — do not edit.
2919
+ const packed = ${JSON.stringify(names.slice().sort().join(","))}
2920
+
2921
+ export const groups = /* @__PURE__ */ new Set(packed ? packed.split(',') : [])
2922
+ `,
2923
+ dts: outdent`
2924
+ /**
2925
+ * The grouped classes this build emitted a rule for. Internal — the generated \`css\`
2926
+ * consults it to decide whether a grouped class has CSS behind it.
2927
+ */
2928
+ export declare const groups: Set<string>;
2929
+ `
2930
+ };
2931
+ }
2932
+ /** Where the registry lives, so the writer and the importer cannot disagree about it. */
2933
+ const GROUP_REGISTRY_FILE = "groups";
2934
+ //#endregion
5811
2935
  //#region src/artifacts/css/keyframe-css.ts
5812
2936
  function generateKeyframeCss(ctx, sheet) {
5813
2937
  const { keyframes = {} } = ctx.config.theme ?? {};
@@ -5972,7 +3096,7 @@ const generateStaticCss = (ctx, sheet) => {
5972
3096
  //#endregion
5973
3097
  //#region src/spec/animation-styles.ts
5974
3098
  const generateAnimationStylesSpec = (ctx) => {
5975
- return generateCompositionStyleSpec("animation-styles", ctx.config.theme, ctx.config.jsxStyleProps);
3099
+ return generateCompositionStyleSpec("animation-styles", ctx.config.theme);
5976
3100
  };
5977
3101
  //#endregion
5978
3102
  //#region src/spec/color-palette.ts
@@ -5997,16 +3121,12 @@ const getColorPaletteExampleValues = (ctx, paletteValues) => {
5997
3121
  };
5998
3122
  const generateColorPaletteSpec = (ctx) => {
5999
3123
  if ((ctx.config.theme?.colorPalette)?.enabled === false) return null;
6000
- const jsxStyleProps = ctx.config.jsxStyleProps;
6001
3124
  const values = Array.from(ctx.tokens.view.colorPalettes.keys()).sort();
6002
3125
  if (!values.length) return null;
6003
3126
  const { examplePalette, bgToken, colorToken } = getColorPaletteExampleValues(ctx, values);
6004
3127
  const functionExamples = [];
6005
- const jsxExamples = [];
6006
3128
  const basicProps = { colorPalette: examplePalette };
6007
3129
  functionExamples.push(`css({ ${formatProps(basicProps)} })`);
6008
- const basicJsx = generateJsxExample(basicProps, jsxStyleProps);
6009
- if (basicJsx) jsxExamples.push(basicJsx);
6010
3130
  if (bgToken || colorToken) {
6011
3131
  const extendedProps = {
6012
3132
  colorPalette: examplePalette,
@@ -6014,25 +3134,17 @@ const generateColorPaletteSpec = (ctx) => {
6014
3134
  color: colorToken
6015
3135
  };
6016
3136
  functionExamples.push(`css({ ${formatProps(extendedProps)} })`);
6017
- const extendedJsx = generateJsxExample(extendedProps, jsxStyleProps);
6018
- if (extendedJsx) jsxExamples.push(extendedJsx);
6019
3137
  }
6020
3138
  return {
6021
3139
  type: "color-palette",
6022
3140
  data: {
6023
3141
  values,
6024
- functionExamples,
6025
- jsxExamples
3142
+ functionExamples
6026
3143
  }
6027
3144
  };
6028
3145
  };
6029
3146
  //#endregion
6030
3147
  //#region src/spec/conditions.ts
6031
- const generateConditionJsxExamples = (conditionName, jsxStyleProps = "all") => {
6032
- if (jsxStyleProps === "all") return [`<Box margin={{ base: '2', ${conditionName}: '4' }} />`, `<Box margin="2" ${conditionName}={{ margin: '4' }} />`];
6033
- if (jsxStyleProps === "minimal") return [`<Box css={{ margin: { base: '2', ${conditionName}: '4' } }} />`, `<Box css={{ margin: '2', ${conditionName}: { margin: '4' } }} />`];
6034
- return [];
6035
- };
6036
3148
  /**
6037
3149
  * Walk an object condition collecting every path that ends in `@slot`.
6038
3150
  * Each path is joined with spaces; multiple paths are joined with `; ` so the
@@ -6048,7 +3160,6 @@ const formatObjectCondition = (raw) => {
6048
3160
  return blocks.join("; ");
6049
3161
  };
6050
3162
  const generateConditionsSpec = (ctx) => {
6051
- const jsxStyleProps = ctx.config.jsxStyleProps;
6052
3163
  const breakpointKeys = new Set(Object.keys(ctx.conditions.breakpoints.conditions));
6053
3164
  return {
6054
3165
  type: "conditions",
@@ -6059,37 +3170,26 @@ const generateConditionsSpec = (ctx) => {
6059
3170
  return {
6060
3171
  name: conditionName,
6061
3172
  value: value ?? "",
6062
- functionExamples: [`css({ margin: { base: '2', ${conditionName}: '4' } })`, `css({ margin: '2', ${conditionName}: { margin: '4' } })`],
6063
- jsxExamples: generateConditionJsxExamples(conditionName, jsxStyleProps)
3173
+ functionExamples: [`css({ margin: { base: '2', ${conditionName}: '4' } })`, `css({ margin: '2', ${conditionName}: { margin: '4' } })`]
6064
3174
  };
6065
3175
  })
6066
3176
  };
6067
3177
  };
6068
3178
  //#endregion
6069
3179
  //#region src/spec/keyframes.ts
6070
- const generateKeyframeJsxExamples = (name, jsxStyleProps = "all") => {
6071
- const jsxExamples = [];
6072
- const example1 = generateJsxExample({ animationName: name }, jsxStyleProps);
6073
- if (example1) jsxExamples.push(example1);
6074
- const example2 = generateJsxExample({ animation: `${name} 1s ease-in-out infinite` }, jsxStyleProps);
6075
- if (example2) jsxExamples.push(example2);
6076
- return jsxExamples;
6077
- };
6078
3180
  const generateKeyframesSpec = (ctx) => {
6079
- const jsxStyleProps = ctx.config.jsxStyleProps;
6080
3181
  return {
6081
3182
  type: "keyframes",
6082
3183
  data: Object.keys(ctx.config.theme?.keyframes ?? {}).map((name) => ({
6083
3184
  name,
6084
- functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`],
6085
- jsxExamples: generateKeyframeJsxExamples(name, jsxStyleProps)
3185
+ functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`]
6086
3186
  }))
6087
3187
  };
6088
3188
  };
6089
3189
  //#endregion
6090
3190
  //#region src/spec/layer-styles.ts
6091
3191
  const generateLayerStylesSpec = (ctx) => {
6092
- return generateCompositionStyleSpec("layer-styles", ctx.config.theme, ctx.config.jsxStyleProps);
3192
+ return generateCompositionStyleSpec("layer-styles", ctx.config.theme);
6093
3193
  };
6094
3194
  //#endregion
6095
3195
  //#region src/spec/patterns.ts
@@ -6101,22 +3201,16 @@ const getExampleValue = (prop) => {
6101
3201
  return "<value>";
6102
3202
  };
6103
3203
  const generatePatternsSpec = (ctx) => {
6104
- const jsxStyleProps = ctx.config.jsxStyleProps;
6105
3204
  return {
6106
3205
  type: "patterns",
6107
3206
  data: ctx.patterns.details.map((node) => {
6108
3207
  const patternName = node.baseName;
6109
- const jsxName = node.jsxName;
6110
3208
  const properties = Object.entries(node.config.properties ?? {});
6111
3209
  const functionExamples = [];
6112
- const jsxExamples = [];
6113
- if (properties.length === 0) {
6114
- functionExamples.push(`${patternName}()`);
6115
- if (jsxStyleProps !== "none") jsxExamples.push(`<${jsxName} />`);
6116
- } else properties.forEach(([propName, prop]) => {
3210
+ if (properties.length === 0) functionExamples.push(`${patternName}()`);
3211
+ else properties.forEach(([propName, prop]) => {
6117
3212
  const exampleValue = getExampleValue(prop);
6118
3213
  functionExamples.push(`${patternName}({ ${propName}: ${exampleValue} })`);
6119
- if (jsxStyleProps !== "none") jsxExamples.push(`<${jsxName} ${propName}={${exampleValue}} />`);
6120
3214
  });
6121
3215
  const defaultValues = typeof node.config.defaultValues === "object" ? node.config.defaultValues : {};
6122
3216
  return {
@@ -6128,9 +3222,7 @@ const generatePatternsSpec = (ctx) => {
6128
3222
  description: prop.description,
6129
3223
  defaultValue: defaultValues[name]
6130
3224
  })),
6131
- jsx: jsxName,
6132
- functionExamples,
6133
- jsxExamples
3225
+ functionExamples
6134
3226
  };
6135
3227
  })
6136
3228
  };
@@ -6152,28 +3244,17 @@ const generateRecipesSpec = (ctx) => {
6152
3244
  type: "recipes",
6153
3245
  data: ctx.recipes.details.map((node) => {
6154
3246
  const recipeName = node.baseName;
6155
- const jsxName = node.jsxName;
6156
3247
  const variantKeys = Object.keys(node.variantKeyMap);
6157
3248
  const functionExamples = [];
6158
- const jsxExamples = [];
6159
- if (variantKeys.length === 0) {
6160
- functionExamples.push(`${recipeName}()`);
6161
- jsxExamples.push(`<${jsxName} />`);
6162
- } else {
3249
+ if (variantKeys.length === 0) functionExamples.push(`${recipeName}()`);
3250
+ else {
6163
3251
  variantKeys.forEach((variantKey) => {
6164
3252
  const firstValue = getFirstVariantValue(node.variantKeyMap, variantKey);
6165
- if (firstValue) {
6166
- functionExamples.push(`${recipeName}({ ${variantKey}: ${formatFunctionValue(firstValue)} })`);
6167
- jsxExamples.push(`<${jsxName} ${variantKey}=${formatJsxValue(firstValue)} />`);
6168
- }
3253
+ if (firstValue) functionExamples.push(`${recipeName}({ ${variantKey}: ${formatFunctionValue(firstValue)} })`);
6169
3254
  });
6170
3255
  if (variantKeys.length > 1) {
6171
3256
  const props = buildVariantProps(variantKeys, node.variantKeyMap, buildFunctionProps, ", ");
6172
- const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap, buildJsxProps, " ");
6173
- if (props && jsxProps) {
6174
- functionExamples.push(`${recipeName}({ ${props} })`);
6175
- jsxExamples.push(`<${jsxName} ${jsxProps} />`);
6176
- }
3257
+ if (props) functionExamples.push(`${recipeName}({ ${props} })`);
6177
3258
  }
6178
3259
  }
6179
3260
  return {
@@ -6181,8 +3262,7 @@ const generateRecipesSpec = (ctx) => {
6181
3262
  description: node.config.description,
6182
3263
  variants: node.variantKeyMap,
6183
3264
  defaultVariants: node.config.defaultVariants ?? {},
6184
- functionExamples,
6185
- jsxExamples
3265
+ functionExamples
6186
3266
  };
6187
3267
  })
6188
3268
  };
@@ -6190,7 +3270,7 @@ const generateRecipesSpec = (ctx) => {
6190
3270
  //#endregion
6191
3271
  //#region src/spec/text-styles.ts
6192
3272
  const generateTextStylesSpec = (ctx) => {
6193
- return generateCompositionStyleSpec("text-styles", ctx.config.theme, ctx.config.jsxStyleProps);
3273
+ return generateCompositionStyleSpec("text-styles", ctx.config.theme);
6194
3274
  };
6195
3275
  //#endregion
6196
3276
  //#region src/spec/token-examples.ts
@@ -6219,26 +3299,21 @@ const CATEGORY_PROPERTY_MAP = {
6219
3299
  const getCategoryProperty = (category) => {
6220
3300
  return category ? CATEGORY_PROPERTY_MAP[category] ?? "color" : "color";
6221
3301
  };
6222
- const generateTokenExamples = (token, jsxStyleProps = "all") => {
3302
+ const generateTokenExamples = (token) => {
6223
3303
  const prop = getCategoryProperty(token.extensions?.category);
6224
3304
  const tokenName = token.extensions.prop;
6225
3305
  const fullTokenName = token.name;
6226
3306
  const functionExamples = [`css({ ${prop}: '${tokenName}' })`];
6227
3307
  const tokenFunctionExamples = [`token('${fullTokenName}')`];
6228
- const jsxExamples = [];
6229
- const jsxExample = generateJsxExample({ [prop]: tokenName }, jsxStyleProps);
6230
- if (jsxExample) jsxExamples.push(jsxExample);
6231
3308
  if (token.extensions.varRef) tokenFunctionExamples.push(`token.var('${fullTokenName}')`);
6232
3309
  return {
6233
3310
  functionExamples,
6234
- tokenFunctionExamples,
6235
- jsxExamples
3311
+ tokenFunctionExamples
6236
3312
  };
6237
3313
  };
6238
3314
  //#endregion
6239
3315
  //#region src/spec/themes.ts
6240
3316
  const generateThemeTokenGroups = (ctx, themeName, filterFn) => {
6241
- const jsxStyleProps = ctx.config.jsxStyleProps;
6242
3317
  const condName = "_theme" + capitalize(themeName);
6243
3318
  const themeTokens = ctx.tokens.allTokens.filter((token) => token.extensions.isVirtual && token.extensions.theme === themeName && filterFn(token));
6244
3319
  const byCategory = /* @__PURE__ */ new Map();
@@ -6251,7 +3326,7 @@ const generateThemeTokenGroups = (ctx, themeName, filterFn) => {
6251
3326
  return Array.from(byCategory.entries()).map(([category, typeTokens]) => {
6252
3327
  if (!typeTokens.length) return null;
6253
3328
  const firstToken = typeTokens[0];
6254
- const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps);
3329
+ const { functionExamples, tokenFunctionExamples } = generateTokenExamples(firstToken);
6255
3330
  return {
6256
3331
  type: category,
6257
3332
  values: typeTokens.map((token) => {
@@ -6271,8 +3346,7 @@ const generateThemeTokenGroups = (ctx, themeName, filterFn) => {
6271
3346
  };
6272
3347
  }),
6273
3348
  tokenFunctionExamples,
6274
- functionExamples,
6275
- jsxExamples
3349
+ functionExamples
6276
3350
  };
6277
3351
  }).filter(Boolean);
6278
3352
  };
@@ -6293,14 +3367,13 @@ const generateThemesSpec = (ctx) => {
6293
3367
  //#endregion
6294
3368
  //#region src/spec/tokens.ts
6295
3369
  const generateTokensSpec = (ctx) => {
6296
- const jsxStyleProps = ctx.config.jsxStyleProps;
6297
3370
  return {
6298
3371
  type: "tokens",
6299
3372
  data: Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
6300
3373
  const typeTokens = Array.from(tokenMap.values()).filter((token) => !token.extensions.isSemantic && !token.extensions.isVirtual && !token.extensions.conditions && !token.extensions.isNegative);
6301
3374
  if (!typeTokens.length) return null;
6302
3375
  const firstToken = typeTokens[0];
6303
- const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps);
3376
+ const { functionExamples, tokenFunctionExamples } = generateTokenExamples(firstToken);
6304
3377
  return {
6305
3378
  type: category,
6306
3379
  values: typeTokens.map((token) => ({
@@ -6311,21 +3384,19 @@ const generateTokensSpec = (ctx) => {
6311
3384
  cssVar: token.extensions.varRef
6312
3385
  })),
6313
3386
  tokenFunctionExamples,
6314
- functionExamples,
6315
- jsxExamples
3387
+ functionExamples
6316
3388
  };
6317
3389
  }).filter(Boolean)
6318
3390
  };
6319
3391
  };
6320
3392
  const generateSemanticTokensSpec = (ctx) => {
6321
- const jsxStyleProps = ctx.config.jsxStyleProps;
6322
3393
  return {
6323
3394
  type: "semantic-tokens",
6324
3395
  data: Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
6325
3396
  const typeTokens = Array.from(tokenMap.values()).filter((token) => (token.extensions.isSemantic || token.extensions.conditions) && !token.extensions.isVirtual);
6326
3397
  if (!typeTokens.length) return null;
6327
3398
  const firstToken = typeTokens[0];
6328
- const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps);
3399
+ const { functionExamples, tokenFunctionExamples } = generateTokenExamples(firstToken);
6329
3400
  return {
6330
3401
  type: category,
6331
3402
  values: typeTokens.map((token) => {
@@ -6345,8 +3416,7 @@ const generateSemanticTokensSpec = (ctx) => {
6345
3416
  };
6346
3417
  }),
6347
3418
  tokenFunctionExamples,
6348
- functionExamples,
6349
- jsxExamples
3419
+ functionExamples
6350
3420
  };
6351
3421
  }).filter(Boolean)
6352
3422
  };
@@ -6512,6 +3582,20 @@ var Generator = class extends Context {
6512
3582
  getParserCss = (decoder) => {
6513
3583
  return generateParserCss(this, decoder);
6514
3584
  };
3585
+ /**
3586
+ * The grouped class names this build emitted a rule for.
3587
+ *
3588
+ * Derived from the encoder rather than the decoder, so it is available as soon as
3589
+ * extraction finishes and before a stylesheet exists. Both sides go through
3590
+ * `groupClassName`, which is the same function the browser runtime calls — a registry
3591
+ * built any other way would be a third spelling of a name that already has two.
3592
+ *
3593
+ * Unescaped, unlike `StyleDecoder`'s class names: this is compared against what `css()`
3594
+ * returns into a `class` attribute, not against a selector. A grouped class is an opaque
3595
+ * hash, so the two only differ in principle, but the principle is the one that matters
3596
+ * here — the registry is only useful if it holds exactly what the runtime will ask about.
3597
+ */
3598
+ getGroupRegistry = () => collectGroupClassNames(this);
6515
3599
  getCss = (stylesheet) => {
6516
3600
  let css = (stylesheet ?? this.createSheet()).toCss({ minify: this.config.minify });
6517
3601
  if (this.hooks["cssgen:done"]) css = this.hooks["cssgen:done"]({
@@ -6655,4 +3739,4 @@ var Generator = class extends Context {
6655
3739
  };
6656
3740
  };
6657
3741
  //#endregion
6658
- export { Generator, getThemeCss };
3742
+ export { GROUP_REGISTRY_FILE, Generator, generateGroupRegistry, getThemeCss };