clava 0.7.1 → 0.7.3

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import clsx from "clsx";
2
- //#region src/utils.ts
2
+ // src/utils.ts
3
3
  const hasOwn = Object.hasOwn;
4
4
  function getOwn(record, key) {
5
5
  if (!hasOwn(record, key)) return void 0;
@@ -224,8 +224,32 @@ function styleValueToHTMLObjStyle(style) {
224
224
  }
225
225
  return result;
226
226
  }
227
- //#endregion
228
- //#region src/refine-warning.ts
227
+ // src/debug.ts
228
+ const DEBUG_ATTRIBUTE = "data-clava-debug";
229
+ function isDebugEnabled(option) {
230
+ return option ?? process.env.NODE_ENV === "development";
231
+ }
232
+ function formatDebugValue(value) {
233
+ if (typeof value === "string") return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
234
+ if (typeof value === "bigint") return `${value}n`;
235
+ if (typeof value === "function") return "{...}";
236
+ if (typeof value === "object" && value != null) return "{...}";
237
+ return String(value);
238
+ }
239
+ function formatDebugAttribute({ variantKeys, variants, incoming }) {
240
+ const parts = [];
241
+ for (let i = 0; i < variantKeys.length; i++) {
242
+ const key = variantKeys[i];
243
+ if (key === void 0) continue;
244
+ if (!hasOwn(variants, key)) continue;
245
+ const value = variants[key];
246
+ if (value === void 0) continue;
247
+ parts.push(`${key}=${formatDebugValue(value)}`);
248
+ }
249
+ if (typeof incoming === "string" && incoming) parts.push(incoming);
250
+ return parts.join(" ");
251
+ }
252
+ // src/refine-warning.ts
229
253
  function captureCreationFrame(skipFn) {
230
254
  if (process.env.NODE_ENV === "production") return void 0;
231
255
  if (typeof Error.captureStackTrace === "function") {
@@ -314,8 +338,7 @@ function warnRefineLimit({ creationFrame, unstableChanges }) {
314
338
  }
315
339
  console.warn(message);
316
340
  }
317
- //#endregion
318
- //#region src/index.ts
341
+ // src/index.ts
319
342
  const META_KEY = "__meta";
320
343
  const EMPTY_DEFAULTS = {};
321
344
  function deduplicateExtensions(extensions, seen = /* @__PURE__ */ new Set()) {
@@ -364,6 +387,24 @@ function mergeProtectedIntoBase(baseResolved, protection) {
364
387
  if (!protectedVariants) return baseResolved;
365
388
  return Object.assign({}, baseResolved, protectedVariants);
366
389
  }
390
+ function isPendingKey(frames, key) {
391
+ for (let i = 0; i < frames.length; i++) if (frames[i]?.keys?.has(key)) return true;
392
+ return false;
393
+ }
394
+ function isDisabledOnPath(frames, key, value) {
395
+ for (let i = 0; i < frames.length; i++) if (frames[i]?.isDisabled?.(key, value)) return true;
396
+ return false;
397
+ }
398
+ const NO_KEYS = /* @__PURE__ */ new Set();
399
+ function getActiveComputedDefaultKeys(meta) {
400
+ return getOwn(meta, "activeComputedDefaultKeys") ?? NO_KEYS;
401
+ }
402
+ function withVariant(variants, key, value) {
403
+ const copy = Object.assign({}, variants);
404
+ if (value === void 0) delete copy[key];
405
+ else copy[key] = value;
406
+ return copy;
407
+ }
367
408
  function identityClass(className) {
368
409
  return className;
369
410
  }
@@ -414,6 +455,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
414
455
  const sourcesLength = sources.length;
415
456
  const results = [];
416
457
  let stylingClaimed = selfIsRecipe;
458
+ let stylingResult = null;
417
459
  const selfResult = {};
418
460
  const selfKeysLength = selfKeys.length;
419
461
  for (let i = 0; i < selfKeysLength; i++) {
@@ -421,6 +463,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
421
463
  if (key !== void 0 && hasOwn(props, key)) selfResult[key] = props[key];
422
464
  }
423
465
  results.push(selfResult);
466
+ if (selfIsRecipe) stylingResult = selfResult;
424
467
  const effectiveKeyArrays = [selfKeys];
425
468
  for (let s = 0; s < sourcesLength; s++) {
426
469
  const source = sources[s];
@@ -439,7 +482,10 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
439
482
  }
440
483
  results.push(sourceResult);
441
484
  effectiveKeyArrays.push(effectiveKeys);
442
- if (sourceIsRecipe && !stylingClaimed) stylingClaimed = true;
485
+ if (sourceIsRecipe && !stylingClaimed) {
486
+ stylingClaimed = true;
487
+ stylingResult = sourceResult;
488
+ }
443
489
  }
444
490
  const rest = {};
445
491
  const propKeys = Object.keys(props);
@@ -448,6 +494,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
448
494
  outer: for (let i = 0; i < propKeysLength; i++) {
449
495
  const key = propKeys[i];
450
496
  if (key === void 0) continue;
497
+ if (key === "data-clava-debug" && stylingResult) stylingResult[key] = props[key];
451
498
  for (let g = 0; g < groupCount; g++) {
452
499
  const arr = effectiveKeyArrays[g];
453
500
  if (arr === void 0) continue;
@@ -490,7 +537,10 @@ function buildPrebuiltVariant(variantDef) {
490
537
  }
491
538
  function create(params = {}) {
492
539
  const transformClass = getOwn(params, "transformClass") ?? identityClass;
493
- const cx = (...classes) => transformClass(clsx(classes));
540
+ const debug = process.env.NODE_ENV !== "production" && isDebugEnabled(getOwn(params, "debug"));
541
+ const transformedCx = (...classes) => {
542
+ return transformClass(clsx(classes));
543
+ };
494
544
  const buildRecipe = (config = {}) => {
495
545
  const extend = getOwn(config, "extend");
496
546
  const variants = getOwn(config, "variants");
@@ -521,6 +571,7 @@ function create(params = {}) {
521
571
  const variantEntryDefs = [];
522
572
  const functionVariantNames = [];
523
573
  const functionVariantFns = [];
574
+ const ownVariantDefs = /* @__PURE__ */ new Map();
524
575
  if (variants) for (const name in variants) {
525
576
  if (!hasOwn(variants, name)) continue;
526
577
  const variant = variants[name];
@@ -533,9 +584,11 @@ function create(params = {}) {
533
584
  if (typeof variant === "function") {
534
585
  functionVariantNames.push(name);
535
586
  functionVariantFns.push(variant);
587
+ ownVariantDefs.set(name, null);
536
588
  continue;
537
589
  }
538
590
  const prebuiltVariant = buildPrebuiltVariant(variant);
591
+ ownVariantDefs.set(name, prebuiltVariant);
539
592
  variantEntryNames.push(name);
540
593
  variantEntryDefs.push(prebuiltVariant);
541
594
  if (prebuiltVariant.disabledValues) {
@@ -544,6 +597,15 @@ function create(params = {}) {
544
597
  }
545
598
  if (prebuiltVariant.values?.has("false") && !initialExtensions.some((meta) => hasOwn(meta.staticDefaults, name))) ownStaticDefaults[name] = false;
546
599
  }
600
+ const definesOwnValue = (key, value) => {
601
+ const variant = ownVariantDefs.get(key);
602
+ if (variant === void 0) return false;
603
+ if (variant === null) return true;
604
+ if (!variant.values) return typeof value === "boolean";
605
+ if (value === false && variant.values.has("true")) return true;
606
+ const valueKey = getVariantValueKey(value);
607
+ return valueKey != null && variant.values.has(valueKey);
608
+ };
547
609
  const variantKeys = Array.from(variantKeySet);
548
610
  const variantKeysLength = variantKeys.length;
549
611
  const variantEntryCount = variantEntryNames.length;
@@ -605,12 +667,10 @@ function create(params = {}) {
605
667
  if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) delete staticDefaults[key];
606
668
  }
607
669
  }
608
- const extMetasWithRefine = [];
609
- for (let i = 0; i < extCount; i++) {
610
- const meta = extMetas[i];
611
- if (meta.resolveRefine) extMetasWithRefine.push(meta);
612
- }
613
- const extMetasWithRefineCount = extMetasWithRefine.length;
670
+ let extMetasWithRefineCount = 0;
671
+ for (let i = 0; i < extCount; i++) if (extMetas[i].resolveRefine) extMetasWithRefineCount += 1;
672
+ const extResolvers = extMetas.map((meta) => getOwn(meta, "resolveVariants") ?? meta.resolveRefine);
673
+ const canResolveVariants = hasExtend && hasAnyDisabled || !!refine || computedDefaultCount > 0 || extResolvers.some(Boolean);
614
674
  const canProtectVariants = !!refine || extMetasWithRefineCount > 0;
615
675
  const needsUserVariantProps = computedDefaultCount > 0 || inheritedComputedDefaultKeys.size > 0;
616
676
  const functionVariantKeys = /* @__PURE__ */ new Set();
@@ -660,6 +720,53 @@ function create(params = {}) {
660
720
  }
661
721
  return false;
662
722
  };
723
+ const isDisabledValue = (key, value) => {
724
+ if (isOwnDisabledValue(key, value)) return true;
725
+ if (definesOwnValue(key, value)) return false;
726
+ return extMetas.some((meta) => getOwn(meta, "isDisabledValue")?.(key, value));
727
+ };
728
+ const disabledKeys = new Set(disabledVariantKeys);
729
+ for (const key in disabledVariantValues) {
730
+ if (!hasOwn(disabledVariantValues, key)) continue;
731
+ disabledKeys.add(key);
732
+ }
733
+ const restorableKeys = [];
734
+ for (const meta of extMetas) {
735
+ const extDisabledKeys = getOwn(meta, "disabledKeys");
736
+ if (!extDisabledKeys) continue;
737
+ for (const key of extDisabledKeys) {
738
+ disabledKeys.add(key);
739
+ if (ownVariantDefs.has(key) && !restorableKeys.includes(key)) restorableKeys.push(key);
740
+ }
741
+ }
742
+ const restoreOwnValues = (before, after, extMeta, fallback, protection) => {
743
+ let restored = after;
744
+ for (const key of restorableKeys) {
745
+ const value = getOwn(before, key);
746
+ if (value === void 0) continue;
747
+ if (!definesOwnValue(key, value)) continue;
748
+ if (!getOwn(extMeta, "isDisabledValue")?.(key, value)) continue;
749
+ const current = getOwn(after, key);
750
+ if (Object.is(current, value)) continue;
751
+ const protectedVariants = protection?.variants;
752
+ if (protectedVariants && hasOwn(protectedVariants, key) && !Object.is(protectedVariants[key], value)) continue;
753
+ if (current !== void 0 && !Object.is(current, getOwn(fallback, key))) continue;
754
+ if (restored === after) restored = Object.assign({}, after);
755
+ restored[key] = value;
756
+ }
757
+ return restored;
758
+ };
759
+ const extPendingFrames = [];
760
+ const laterComputedDefaultKeys = new Set(computedDefaultNames);
761
+ for (let i = extCount - 1; i >= 0; i--) {
762
+ const keys = laterComputedDefaultKeys.size > 0 ? new Set(laterComputedDefaultKeys) : null;
763
+ extPendingFrames.unshift(keys || hasAnyDisabled ? {
764
+ keys,
765
+ isDisabled: hasAnyDisabled ? isOwnDisabledValue : null
766
+ } : null);
767
+ for (const key of getActiveComputedDefaultKeys(extMetas[i])) laterComputedDefaultKeys.add(key);
768
+ }
769
+ const activeComputedDefaultKeys = laterComputedDefaultKeys;
663
770
  const filterOwnDisabledVariants = (input, fallback) => {
664
771
  if (!hasAnyDisabled) return input;
665
772
  let hasOwnDisabledValue = false;
@@ -685,6 +792,14 @@ function create(params = {}) {
685
792
  }
686
793
  return filtered;
687
794
  };
795
+ const filterOwnDisabledChainValues = (chainValues, fallback) => {
796
+ if (!hasAnyDisabled) return;
797
+ for (const [key, value] of chainValues) {
798
+ if (!isOwnDisabledValue(key, value)) continue;
799
+ const fallbackValue = getOwn(fallback, key);
800
+ chainValues.set(key, fallbackValue !== void 0 && !isOwnDisabledValue(key, fallbackValue) ? fallbackValue : void 0);
801
+ }
802
+ };
688
803
  function resolveVariantsHot(propsVariants) {
689
804
  const defaults = Object.assign({}, staticDefaults);
690
805
  for (let i = 0; i < variantKeysLength; i++) {
@@ -699,7 +814,7 @@ function create(params = {}) {
699
814
  filterDisabledInto(defaults, result);
700
815
  return result;
701
816
  }
702
- const runComputedDefaults = (resolved, defaultResolved, userVariantProps, filterOwnVariants, protection) => {
817
+ const runComputedDefaults = (resolved, defaultResolved, userVariantProps, filterOwnVariants, protection, pass) => {
703
818
  const protectedVariants = protection?.variants;
704
819
  let ownVariants = filterOwnVariants ? null : resolved;
705
820
  const getOwnVariants = () => {
@@ -726,21 +841,33 @@ function create(params = {}) {
726
841
  }
727
842
  if (protectedVariants && hasOwn(protectedVariants, key)) continue;
728
843
  const variantSnapshot = getOwnVariants();
729
- const defaultValue = inheritedComputedDefaultKeys.has(key) ? getOwn(variantSnapshot, key) : getOwn(defaultResolved, key);
730
- const value = computedDefaultFns[i](defaultValue, variantSnapshot);
731
- if (hasAnyDisabled) {
732
- if (disabledVariantKeys.has(key)) continue;
733
- if (disabledVariantValues) {
734
- const valueKey = getVariantValueKey(value);
735
- if (valueKey != null && getOwn(disabledVariantValues, key)?.has(valueKey)) continue;
844
+ const currentValue = getOwn(variantSnapshot, key);
845
+ const chainValues = pass?.chainValues;
846
+ const latestValue = chainValues && chainValues.has(key) ? chainValues.get(key) : currentValue;
847
+ const defaultValue = inheritedComputedDefaultKeys.has(key) ? latestValue : getOwn(defaultResolved, key);
848
+ let value = computedDefaultFns[i](defaultValue, Object.is(latestValue, currentValue) ? variantSnapshot : withVariant(variantSnapshot, key, latestValue));
849
+ if (hasAnyDisabled && isOwnDisabledValue(key, value)) {
850
+ if (Object.is(latestValue, currentValue)) continue;
851
+ if (pass && isPendingKey(pass.frames, key)) continue;
852
+ value = latestValue;
853
+ } else if (pass) {
854
+ if (Object.is(value, currentValue)) {
855
+ chainValues?.delete(key);
856
+ continue;
857
+ }
858
+ if (isPendingKey(pass.frames, key) && !isDisabledOnPath(pass.frames, key, value)) {
859
+ pass.chainValues ??= /* @__PURE__ */ new Map();
860
+ pass.chainValues.set(key, value);
861
+ continue;
736
862
  }
737
863
  }
864
+ chainValues?.delete(key);
738
865
  if (value === void 0) {
739
866
  if (!hasOwn(variantSnapshot, key)) continue;
740
867
  delete ensureUpdated()[key];
741
868
  continue;
742
869
  }
743
- if (Object.is(getOwn(variantSnapshot, key), value)) continue;
870
+ if (Object.is(currentValue, value)) continue;
744
871
  ensureUpdated()[key] = value;
745
872
  }
746
873
  return updatedVariants ?? resolved;
@@ -816,7 +943,7 @@ function create(params = {}) {
816
943
  style: cStyle
817
944
  };
818
945
  };
819
- const computeOnce = (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved = resolved, renderOnly = false) => {
946
+ const computeOnce = (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved = resolved, renderOnly = false, pass) => {
820
947
  let workingResolved = resolved;
821
948
  let cClasses = null;
822
949
  let cStyle = null;
@@ -849,18 +976,24 @@ function create(params = {}) {
849
976
  }
850
977
  }
851
978
  for (let i = 0; i < extCount; i++) {
979
+ const pendingFrame = pass ? extPendingFrames[i] : null;
980
+ if (pass && pendingFrame) pass.frames.push(pendingFrame);
981
+ const beforeExtend = workingResolved;
852
982
  if (hasIsolatedExt && extIsolated[i]) {
853
983
  const extClasses = [];
854
- workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, extClasses, styleOut, protection, defaultResolved, renderOnly);
984
+ workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, extClasses, styleOut, protection, defaultResolved, renderOnly, pass);
855
985
  if (extClasses.length > 0) {
856
986
  const joined = clsx(extClasses);
857
987
  if (joined.length > 0) classesOut.push(extMetas[i].transformClass(joined));
858
988
  }
859
- } else workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, classesOut, styleOut, protection, defaultResolved, renderOnly);
989
+ } else workingResolved = extMetas[i].compute(workingResolved, userVariantProps, extSkipKeys, extSkipVals, classesOut, styleOut, protection, defaultResolved, renderOnly, pass);
990
+ if (pass && pendingFrame) pass.frames.pop();
991
+ if (restorableKeys.length > 0) workingResolved = restoreOwnValues(beforeExtend, workingResolved, extMetas[i], defaultResolved, protection);
860
992
  workingResolved = filterOwnDisabledVariants(workingResolved, defaultResolved);
993
+ if (pass?.chainValues) filterOwnDisabledChainValues(pass.chainValues, defaultResolved);
861
994
  }
862
995
  }
863
- if (!renderOnly && computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, true, protection);
996
+ if (!renderOnly && computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, true, protection, pass);
864
997
  if (refine) {
865
998
  const refineResult = runRefineContext(workingResolved, true, true, !renderOnly, protection);
866
999
  workingResolved = refineResult.workingResolved;
@@ -917,6 +1050,7 @@ function create(params = {}) {
917
1050
  let lastClasses = [];
918
1051
  let lastStyle = {};
919
1052
  let isFirstRun = true;
1053
+ let pass = null;
920
1054
  while (remaining > 0) {
921
1055
  remaining -= 1;
922
1056
  const useDirectOutput = isFirstRun;
@@ -924,15 +1058,17 @@ function create(params = {}) {
924
1058
  const nextClasses = useDirectOutput ? classesOut : [];
925
1059
  const nextStyle = useDirectOutput ? styleOut : {};
926
1060
  const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
927
- const nextResolved = computeOnce(workingResolved, userVariantProps, skipKeys, skipValues, nextClasses, nextStyle, protection, defaultResolved);
928
- if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) {
929
- if (nextResolved !== workingResolved) {
930
- if (useDirectOutput) {
931
- classesOut.length = classCount;
932
- for (const key in styleOut) if (hasOwn(styleOut, key)) Reflect.deleteProperty(styleOut, key);
933
- }
934
- computeOnce(nextResolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved, true);
935
- } else if (!useDirectOutput) {
1061
+ if (!isFirstRun) {
1062
+ pass ??= {
1063
+ frames: [],
1064
+ chainValues: null
1065
+ };
1066
+ pass.chainValues?.clear();
1067
+ }
1068
+ const nextResolved = computeOnce(workingResolved, userVariantProps, skipKeys, skipValues, nextClasses, nextStyle, protection, defaultResolved, false, pass);
1069
+ if (nextResolved === workingResolved || !isFirstRun && areVariantsEqual(workingResolved, nextResolved)) {
1070
+ if (nextResolved !== workingResolved) computeOnce(nextResolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, protection, defaultResolved, true);
1071
+ else if (!useDirectOutput) {
936
1072
  for (let i = 0; i < nextClasses.length; i++) classesOut.push(nextClasses[i]);
937
1073
  Object.assign(styleOut, nextStyle);
938
1074
  }
@@ -960,15 +1096,23 @@ function create(params = {}) {
960
1096
  Object.assign(styleOut, lastStyle);
961
1097
  return workingResolved;
962
1098
  };
963
- const resolveRefineOnce = (resolved, userVariantProps, filterOwnVariants = true, protection, defaultResolved = resolved) => {
1099
+ const resolveRefineOnce = (resolved, userVariantProps, filterOwnVariants = true, protection, defaultResolved = resolved, pass, renderOnly = false) => {
964
1100
  let workingResolved = resolved;
965
- for (let i = 0; i < extMetasWithRefineCount; i++) {
966
- const resolveRefine = extMetasWithRefine[i].resolveRefine;
967
- if (!resolveRefine) continue;
968
- workingResolved = resolveRefine(workingResolved, userVariantProps, true, protection, defaultResolved);
1101
+ for (let i = 0; i < extCount; i++) {
1102
+ const resolveExtend = extResolvers[i];
1103
+ const beforeExtend = workingResolved;
1104
+ if (resolveExtend) {
1105
+ const pendingFrame = pass ? extPendingFrames[i] : null;
1106
+ if (pass && pendingFrame) pass.frames.push(pendingFrame);
1107
+ workingResolved = resolveExtend(workingResolved, userVariantProps, true, protection, defaultResolved, pass, renderOnly);
1108
+ if (pass && pendingFrame) pass.frames.pop();
1109
+ if (restorableKeys.length > 0) workingResolved = restoreOwnValues(beforeExtend, workingResolved, extMetas[i], defaultResolved, protection);
1110
+ }
969
1111
  workingResolved = filterOwnDisabledVariants(workingResolved, defaultResolved);
1112
+ if (pass?.chainValues) filterOwnDisabledChainValues(pass.chainValues, defaultResolved);
970
1113
  }
971
- if (computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, filterOwnVariants, protection);
1114
+ if (renderOnly) return workingResolved;
1115
+ if (computedDefaultCount > 0) workingResolved = runComputedDefaults(workingResolved, defaultResolved, userVariantProps, filterOwnVariants, protection, pass);
972
1116
  if (refine) workingResolved = runRefineContext(workingResolved, filterOwnVariants, false, true, protection).workingResolved;
973
1117
  return workingResolved;
974
1118
  };
@@ -978,16 +1122,23 @@ function create(params = {}) {
978
1122
  const incomingDefaultResolved = resolved;
979
1123
  let workingResolved = resolved;
980
1124
  let unstableChanges = null;
1125
+ let pass = null;
981
1126
  while (remaining > 0) {
982
1127
  remaining -= 1;
983
1128
  const defaultResolved = mergeProtectedIntoBase(incomingDefaultResolved, protection);
984
- const nextResolved = resolveRefineOnce(workingResolved, userVariantProps, filterOwnVariants, protection, defaultResolved);
985
- if (nextResolved === workingResolved || areVariantsEqual(workingResolved, nextResolved)) return nextResolved;
1129
+ const nextResolved = resolveRefineOnce(workingResolved, userVariantProps, filterOwnVariants, protection, defaultResolved, pass);
1130
+ if (nextResolved === workingResolved) return nextResolved;
1131
+ if (pass && areVariantsEqual(workingResolved, nextResolved)) return resolveRefineOnce(nextResolved, userVariantProps, filterOwnVariants, protection, defaultResolved, null, true);
986
1132
  if (remaining < 10 && process.env.NODE_ENV !== "production") {
987
1133
  if (!unstableChanges) unstableChanges = /* @__PURE__ */ new Map();
988
1134
  accumulateUnstableVariantChanges(unstableChanges, workingResolved, nextResolved);
989
1135
  }
990
1136
  workingResolved = nextResolved;
1137
+ pass ??= {
1138
+ frames: [],
1139
+ chainValues: null
1140
+ };
1141
+ pass.chainValues?.clear();
991
1142
  }
992
1143
  if (process.env.NODE_ENV !== "production") warnRefineLimit({
993
1144
  creationFrame,
@@ -1028,7 +1179,7 @@ function create(params = {}) {
1028
1179
  }
1029
1180
  const allClasses = [computedBaseClass];
1030
1181
  const style = {};
1031
- compute(resolved, userVariantProps, null, null, allClasses, style);
1182
+ const variants = compute(resolved, userVariantProps, null, null, allClasses, style);
1032
1183
  if (hasOwn(propsRecord, "class")) allClasses.push(propsRecord.class);
1033
1184
  if (hasOwn(propsRecord, "className")) allClasses.push(propsRecord.className);
1034
1185
  const psv = propsRecord.style;
@@ -1039,9 +1190,17 @@ function create(params = {}) {
1039
1190
  }
1040
1191
  return {
1041
1192
  className: transformClass(clsx(allClasses)),
1042
- style
1193
+ style,
1194
+ variants
1043
1195
  };
1044
1196
  };
1197
+ const setDebugAttribute = (result, props, variants) => {
1198
+ result[DEBUG_ATTRIBUTE] = formatDebugAttribute({
1199
+ variantKeys,
1200
+ variants,
1201
+ incoming: getOwn(props, DEBUG_ATTRIBUTE)
1202
+ });
1203
+ };
1045
1204
  const getVariants = (variants) => {
1046
1205
  const variantsRecord = variants ?? EMPTY_DEFAULTS;
1047
1206
  let variantProps = variantsRecord;
@@ -1054,6 +1213,7 @@ function create(params = {}) {
1054
1213
  }
1055
1214
  let resolvedVariants = resolveVariantsHot(variantProps);
1056
1215
  if (resolveRefine) resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);
1216
+ else if (canResolveVariants) resolvedVariants = resolveRefineOnce(resolvedVariants, variantProps);
1057
1217
  return resolvedVariants;
1058
1218
  };
1059
1219
  const computedBaseClass = hasExtend ? clsx(extBaseClassesArr, baseClass) : baseClass;
@@ -1068,9 +1228,13 @@ function create(params = {}) {
1068
1228
  staticDefaults,
1069
1229
  compute: computeOnce,
1070
1230
  resolveRefine: resolveRefine ? resolveRefineOnce : null,
1231
+ resolveVariants: canResolveVariants ? resolveRefineOnce : void 0,
1071
1232
  transformClass,
1072
1233
  functionVariantKeys,
1073
- computedDefaultKeys
1234
+ computedDefaultKeys,
1235
+ activeComputedDefaultKeys,
1236
+ disabledKeys,
1237
+ isDisabledValue
1074
1238
  };
1075
1239
  const initRecipe = (recipe, propKeys, style) => {
1076
1240
  recipe.class = classFn;
@@ -1082,21 +1246,25 @@ function create(params = {}) {
1082
1246
  return recipe;
1083
1247
  };
1084
1248
  const defaultRecipe = ((props = {}) => {
1085
- const { className, style } = computeResult(props);
1086
- return {
1249
+ const { className, style, variants } = computeResult(props);
1250
+ const result = {
1087
1251
  class: className,
1088
1252
  style
1089
1253
  };
1254
+ if (debug) setDebugAttribute(result, props, variants);
1255
+ return result;
1090
1256
  });
1091
1257
  initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
1092
1258
  return computeResult(props).style;
1093
1259
  });
1094
1260
  const jsxRecipe = ((props = {}) => {
1095
- const { className, style } = computeResult(props);
1096
- return {
1261
+ const { className, style, variants } = computeResult(props);
1262
+ const result = {
1097
1263
  className,
1098
1264
  style
1099
1265
  };
1266
+ if (debug) setDebugAttribute(result, props, variants);
1267
+ return result;
1100
1268
  });
1101
1269
  initRecipe(jsxRecipe, [
1102
1270
  "className",
@@ -1104,11 +1272,13 @@ function create(params = {}) {
1104
1272
  ...variantKeys
1105
1273
  ], (props = {}) => computeResult(props).style);
1106
1274
  const htmlRecipe = ((props = {}) => {
1107
- const { className, style } = computeResult(props);
1108
- return {
1275
+ const { className, style, variants } = computeResult(props);
1276
+ const result = {
1109
1277
  class: className,
1110
1278
  style: styleValueToHTMLStyle(style)
1111
1279
  };
1280
+ if (debug) setDebugAttribute(result, props, variants);
1281
+ return result;
1112
1282
  });
1113
1283
  initRecipe(htmlRecipe, [
1114
1284
  "class",
@@ -1116,11 +1286,13 @@ function create(params = {}) {
1116
1286
  ...variantKeys
1117
1287
  ], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
1118
1288
  const htmlObjRecipe = ((props = {}) => {
1119
- const { className, style } = computeResult(props);
1120
- return {
1289
+ const { className, style, variants } = computeResult(props);
1290
+ const result = {
1121
1291
  class: className,
1122
1292
  style: styleValueToHTMLObjStyle(style)
1123
1293
  };
1294
+ if (debug) setDebugAttribute(result, props, variants);
1295
+ return result;
1124
1296
  });
1125
1297
  initRecipe(htmlObjRecipe, [
1126
1298
  "class",
@@ -1140,14 +1312,13 @@ function create(params = {}) {
1140
1312
  const cv = (config = {}) => buildRecipe(config).recipe;
1141
1313
  return {
1142
1314
  cv,
1143
- cx
1315
+ cx: transformedCx
1144
1316
  };
1145
1317
  }
1146
1318
  const cv = /* @__PURE__ */ (() => create().cv)();
1147
1319
  function cx(...classes) {
1148
1320
  return clsx(classes);
1149
1321
  }
1150
- //#endregion
1151
1322
  export { create, cv, cx, splitProps };
1152
1323
 
1153
1324
  //# sourceMappingURL=index.js.map