clava 0.3.0 → 0.4.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/CHANGELOG.md +66 -0
- package/README.md +38 -38
- package/dist/index.d.ts +17 -25
- package/dist/index.js +94 -78
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +187 -149
- package/src/types.ts +36 -44
- package/tests/_utils.ts +1 -3
- package/tests/component-api.test.ts +28 -28
- package/tests/extend.test.ts +6 -6
- package/tests/{computed-variants.test.ts → function-variants.test.ts} +105 -25
- package/tests/prototype-pollution.test.ts +6 -6
- package/tests/{computed.test.ts → refine.test.ts} +145 -151
- package/tests/variants-inference.test.ts +252 -0
package/dist/index.js
CHANGED
|
@@ -223,7 +223,7 @@ function isHTMLObjStyle(style) {
|
|
|
223
223
|
//#region src/index.ts
|
|
224
224
|
const META_KEY = "__meta";
|
|
225
225
|
const EMPTY_DEFAULTS = Object.freeze({});
|
|
226
|
-
const
|
|
226
|
+
const MAX_REFINE_RUNS = 50;
|
|
227
227
|
function areVariantsEqual(a, b) {
|
|
228
228
|
for (const key in a) {
|
|
229
229
|
if (!Object.hasOwn(a, key)) continue;
|
|
@@ -235,10 +235,10 @@ function areVariantsEqual(a, b) {
|
|
|
235
235
|
}
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function warnRefineLimit(runState) {
|
|
239
239
|
if (runState.warned) return;
|
|
240
240
|
runState.warned = true;
|
|
241
|
-
if (process.env.NODE_ENV !== "production") console.warn("Clava: Maximum
|
|
241
|
+
if (process.env.NODE_ENV !== "production") console.warn("Clava: Maximum refine iterations exceeded. This can happen when a refine callback calls setVariants or setDefaultVariants, but one of the variants changes on every run.");
|
|
242
242
|
}
|
|
243
243
|
function getExtUserVariantProps(userVariantProps, protectedVariants, changedVariants) {
|
|
244
244
|
const extUserVariantProps = {};
|
|
@@ -334,10 +334,6 @@ function collectVariantKeys(config) {
|
|
|
334
334
|
}
|
|
335
335
|
keys.add(key);
|
|
336
336
|
}
|
|
337
|
-
if (config.computedVariants) for (const key in config.computedVariants) {
|
|
338
|
-
if (!Object.hasOwn(config.computedVariants, key)) continue;
|
|
339
|
-
keys.add(key);
|
|
340
|
-
}
|
|
341
337
|
return Array.from(keys);
|
|
342
338
|
}
|
|
343
339
|
function isVariantDisabled(config, key) {
|
|
@@ -514,28 +510,27 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
514
510
|
const extend = config.extend;
|
|
515
511
|
const hasExtend = !!extend && extend.length > 0;
|
|
516
512
|
const variants = config.variants;
|
|
517
|
-
const
|
|
518
|
-
const computed = config.computed;
|
|
513
|
+
const refine = config.refine;
|
|
519
514
|
const baseStyle = config.style;
|
|
520
515
|
const hasBaseStyle = !!baseStyle;
|
|
521
516
|
const variantEntryNames = [];
|
|
522
517
|
const variantEntryDefs = [];
|
|
518
|
+
const functionVariantNames = [];
|
|
519
|
+
const functionVariantFns = [];
|
|
523
520
|
if (variants) for (const name in variants) {
|
|
524
521
|
if (!Object.hasOwn(variants, name)) continue;
|
|
525
522
|
const variant = variants[name];
|
|
526
523
|
if (variant === null) continue;
|
|
524
|
+
if (typeof variant === "function") {
|
|
525
|
+
functionVariantNames.push(name);
|
|
526
|
+
functionVariantFns.push(variant);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
527
529
|
variantEntryNames.push(name);
|
|
528
530
|
variantEntryDefs.push(buildPrebuiltVariant(variant));
|
|
529
531
|
}
|
|
530
532
|
const variantEntryCount = variantEntryNames.length;
|
|
531
|
-
const
|
|
532
|
-
const computedVariantFns = [];
|
|
533
|
-
if (computedVariantsCfg) for (const name in computedVariantsCfg) {
|
|
534
|
-
if (!Object.hasOwn(computedVariantsCfg, name)) continue;
|
|
535
|
-
computedVariantNames.push(name);
|
|
536
|
-
computedVariantFns.push(computedVariantsCfg[name]);
|
|
537
|
-
}
|
|
538
|
-
const computedVariantCount = computedVariantNames.length;
|
|
533
|
+
const functionVariantCount = functionVariantNames.length;
|
|
539
534
|
const staticDefaults = {};
|
|
540
535
|
if (extend) for (const ext of extend) {
|
|
541
536
|
const meta = getComponentMeta(ext);
|
|
@@ -576,18 +571,38 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
576
571
|
} else extBaseClassesArr.push(meta.baseClass);
|
|
577
572
|
}
|
|
578
573
|
const extCount = extMetas.length;
|
|
579
|
-
const
|
|
574
|
+
const extMetasWithRefine = [];
|
|
580
575
|
for (let i = 0; i < extCount; i++) {
|
|
581
576
|
const meta = extMetas[i];
|
|
582
|
-
if (meta.resolveDefaults)
|
|
577
|
+
if (meta.resolveDefaults) extMetasWithRefine.push(meta);
|
|
578
|
+
}
|
|
579
|
+
const extMetasWithRefineCount = extMetasWithRefine.length;
|
|
580
|
+
const shouldCollectChangedVariants = extMetasWithRefineCount > 0;
|
|
581
|
+
const functionVariantKeys = /* @__PURE__ */ new Set();
|
|
582
|
+
for (let i = 0; i < extCount; i++) {
|
|
583
|
+
const fnKeys = extMetas[i].functionVariantKeys;
|
|
584
|
+
for (const k of fnKeys) {
|
|
585
|
+
if (disabledVariantKeys.has(k)) continue;
|
|
586
|
+
functionVariantKeys.add(k);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
for (let i = 0; i < functionVariantCount; i++) functionVariantKeys.add(functionVariantNames[i]);
|
|
590
|
+
for (let i = 0; i < variantEntryCount; i++) functionVariantKeys.delete(variantEntryNames[i]);
|
|
591
|
+
let staticVariantsOverridingExtFn = null;
|
|
592
|
+
if (variantEntryCount > 0 && extCount > 0) for (let i = 0; i < variantEntryCount; i++) {
|
|
593
|
+
const name = variantEntryNames[i];
|
|
594
|
+
for (let j = 0; j < extCount; j++) if (extMetas[j].functionVariantKeys.has(name)) {
|
|
595
|
+
if (!staticVariantsOverridingExtFn) staticVariantsOverridingExtFn = [];
|
|
596
|
+
staticVariantsOverridingExtFn.push(name);
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
583
599
|
}
|
|
584
|
-
const extMetasWithComputedCount = extMetasWithComputed.length;
|
|
585
|
-
const shouldCollectChangedVariants = extMetasWithComputedCount > 0;
|
|
586
600
|
let staticExtSkipKeys = null;
|
|
587
|
-
if (hasDisabledVariantKeys ||
|
|
601
|
+
if (hasDisabledVariantKeys || functionVariantCount > 0 || staticVariantsOverridingExtFn !== null) {
|
|
588
602
|
staticExtSkipKeys = /* @__PURE__ */ new Set();
|
|
589
603
|
for (const k of disabledVariantKeys) staticExtSkipKeys.add(k);
|
|
590
|
-
for (let i = 0; i <
|
|
604
|
+
for (let i = 0; i < functionVariantCount; i++) staticExtSkipKeys.add(functionVariantNames[i]);
|
|
605
|
+
if (staticVariantsOverridingExtFn) for (const k of staticVariantsOverridingExtFn) staticExtSkipKeys.add(k);
|
|
591
606
|
}
|
|
592
607
|
const staticExtSkipValues = hasDisabledVariantValues ? disabledVariantValues : null;
|
|
593
608
|
function filterDisabledInto(input, out) {
|
|
@@ -606,7 +621,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
606
621
|
out[key] = value;
|
|
607
622
|
}
|
|
608
623
|
}
|
|
609
|
-
const resolveDefaultsFn =
|
|
624
|
+
const resolveDefaultsFn = refine || extMetasWithRefineCount > 0 ? (childDefaults, userProps = EMPTY_DEFAULTS) => {
|
|
610
625
|
const resolvedVariants = {};
|
|
611
626
|
Object.assign(resolvedVariants, staticDefaults);
|
|
612
627
|
for (const key in childDefaults) {
|
|
@@ -621,21 +636,21 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
621
636
|
if (v === void 0) continue;
|
|
622
637
|
resolvedVariants[key] = v;
|
|
623
638
|
}
|
|
624
|
-
const
|
|
625
|
-
for (let i = 0; i <
|
|
626
|
-
const extDefaults =
|
|
639
|
+
const refineDefaults = {};
|
|
640
|
+
for (let i = 0; i < extMetasWithRefineCount; i++) {
|
|
641
|
+
const extDefaults = extMetasWithRefine[i].resolveDefaults(childDefaults, userProps);
|
|
627
642
|
for (const k in extDefaults) {
|
|
628
643
|
if (!Object.hasOwn(extDefaults, k)) continue;
|
|
629
|
-
|
|
644
|
+
refineDefaults[k] = extDefaults[k];
|
|
630
645
|
}
|
|
631
646
|
}
|
|
632
|
-
if (
|
|
647
|
+
if (refine) {
|
|
633
648
|
const ownVariants = {};
|
|
634
649
|
for (let i = 0; i < variantKeysLength; i++) {
|
|
635
650
|
const k = variantKeys[i];
|
|
636
651
|
if (Object.hasOwn(resolvedVariants, k)) ownVariants[k] = resolvedVariants[k];
|
|
637
652
|
}
|
|
638
|
-
|
|
653
|
+
refine({
|
|
639
654
|
variants: ownVariants,
|
|
640
655
|
setVariants: noop,
|
|
641
656
|
setDefaultVariants: (newDefaults) => {
|
|
@@ -645,23 +660,23 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
645
660
|
if (userProps[key] !== void 0) continue;
|
|
646
661
|
if (isVariantDisabled(config, key)) continue;
|
|
647
662
|
if (isVariantValueDisabled(config, key, value)) continue;
|
|
648
|
-
|
|
663
|
+
refineDefaults[key] = value;
|
|
649
664
|
}
|
|
650
665
|
},
|
|
651
666
|
addClass: noop,
|
|
652
667
|
addStyle: noop
|
|
653
668
|
});
|
|
654
669
|
}
|
|
655
|
-
return
|
|
670
|
+
return refineDefaults;
|
|
656
671
|
} : null;
|
|
657
672
|
function resolveVariantsHot(propsVariants) {
|
|
658
673
|
const defaults = {};
|
|
659
674
|
Object.assign(defaults, staticDefaults);
|
|
660
|
-
for (let i = 0; i <
|
|
661
|
-
const
|
|
662
|
-
for (const k in
|
|
663
|
-
if (!Object.hasOwn(
|
|
664
|
-
defaults[k] =
|
|
675
|
+
for (let i = 0; i < extMetasWithRefineCount; i++) {
|
|
676
|
+
const extDefaults = extMetasWithRefine[i].resolveDefaults(defaults, propsVariants);
|
|
677
|
+
for (const k in extDefaults) {
|
|
678
|
+
if (!Object.hasOwn(extDefaults, k)) continue;
|
|
679
|
+
defaults[k] = extDefaults[k];
|
|
665
680
|
}
|
|
666
681
|
}
|
|
667
682
|
for (const k in propsVariants) {
|
|
@@ -675,12 +690,12 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
675
690
|
filterDisabledInto(defaults, result);
|
|
676
691
|
return result;
|
|
677
692
|
}
|
|
678
|
-
const
|
|
693
|
+
const runRefineContext = (resolved, userVariantProps, filterOwnVariants, collectOutput, protectedVariants, pendingProtectedVariants, protectedVariantKeys) => {
|
|
679
694
|
let workingResolved = resolved;
|
|
680
695
|
let cClasses = null;
|
|
681
696
|
let cStyle = null;
|
|
682
697
|
let changedVariants = null;
|
|
683
|
-
if (
|
|
698
|
+
if (refine) {
|
|
684
699
|
let ownVariants = resolved;
|
|
685
700
|
if (filterOwnVariants) {
|
|
686
701
|
const filteredVariants = {};
|
|
@@ -713,7 +728,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
713
728
|
const getCurrentVariantValue = (key) => {
|
|
714
729
|
return updatedVariants ? updatedVariants[key] : ownVariants[key];
|
|
715
730
|
};
|
|
716
|
-
const result =
|
|
731
|
+
const result = refine({
|
|
717
732
|
variants: ownVariants,
|
|
718
733
|
setVariants: (newVariants) => {
|
|
719
734
|
if (!hasAnyDisabled) {
|
|
@@ -798,12 +813,12 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
798
813
|
let cClasses = null;
|
|
799
814
|
let cStyle = null;
|
|
800
815
|
let changedVariants = null;
|
|
801
|
-
if (
|
|
802
|
-
const
|
|
803
|
-
workingResolved =
|
|
804
|
-
cClasses =
|
|
805
|
-
cStyle =
|
|
806
|
-
changedVariants =
|
|
816
|
+
if (refine) {
|
|
817
|
+
const refineResult = runRefineContext(resolved, userVariantProps, true, true, protectedVariants, pendingProtectedVariants, protectedVariantKeys);
|
|
818
|
+
workingResolved = refineResult.workingResolved;
|
|
819
|
+
cClasses = refineResult.classes;
|
|
820
|
+
cStyle = refineResult.style;
|
|
821
|
+
changedVariants = refineResult.changedVariants;
|
|
807
822
|
}
|
|
808
823
|
if (hasExtend) {
|
|
809
824
|
let extSkipKeys;
|
|
@@ -828,7 +843,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
828
843
|
} else extSkipVals[k] = staticExtSkipValues[k];
|
|
829
844
|
}
|
|
830
845
|
}
|
|
831
|
-
const extUserVariantProps =
|
|
846
|
+
const extUserVariantProps = extMetasWithRefineCount > 0 ? getExtUserVariantProps(userVariantProps, protectedVariants ?? null, changedVariants) : userVariantProps;
|
|
832
847
|
for (let i = 0; i < extCount; i++) {
|
|
833
848
|
if (hasIsolatedExt && extIsolated[i]) {
|
|
834
849
|
const extClasses = [];
|
|
@@ -838,7 +853,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
838
853
|
if (joined.length > 0) classesOut.push(extMetas[i].transformClass(joined));
|
|
839
854
|
}
|
|
840
855
|
} else workingResolved = extMetas[i].compute(workingResolved, extUserVariantProps, extSkipKeys, extSkipVals, classesOut, styleOut, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys);
|
|
841
|
-
if (protectedVariants &&
|
|
856
|
+
if (protectedVariants && extMetasWithRefineCount > 0) Object.assign(extUserVariantProps, protectedVariants);
|
|
842
857
|
}
|
|
843
858
|
}
|
|
844
859
|
if (hasBaseStyle) Object.assign(styleOut, baseStyle);
|
|
@@ -865,14 +880,14 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
865
880
|
if (v.style) Object.assign(styleOut, v.style);
|
|
866
881
|
}
|
|
867
882
|
}
|
|
868
|
-
for (let i = 0; i <
|
|
869
|
-
const variantName =
|
|
883
|
+
for (let i = 0; i < functionVariantCount; i++) {
|
|
884
|
+
const variantName = functionVariantNames[i];
|
|
870
885
|
if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;
|
|
871
886
|
const selectedValue = workingResolved[variantName];
|
|
872
887
|
if (selectedValue === void 0) continue;
|
|
873
888
|
const selectedKey = getVariantValueKey(selectedValue);
|
|
874
889
|
if (ownSkipValues && selectedKey != null && ownSkipValues[variantName]?.has(selectedKey)) continue;
|
|
875
|
-
const fn =
|
|
890
|
+
const fn = functionVariantFns[i];
|
|
876
891
|
const computedResult = fn(selectedValue);
|
|
877
892
|
if (computedResult == null) continue;
|
|
878
893
|
const r = extractClassAndStylePrebuilt(computedResult);
|
|
@@ -883,11 +898,11 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
883
898
|
if (cStyle) Object.assign(styleOut, cStyle);
|
|
884
899
|
return workingResolved;
|
|
885
900
|
};
|
|
886
|
-
const compute = !
|
|
901
|
+
const compute = !refine && extMetasWithRefineCount === 0 ? (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys) => {
|
|
887
902
|
return computeOnce(resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys);
|
|
888
903
|
} : (resolved, userVariantProps, skipKeys, skipValues, classesOut, styleOut, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys) => {
|
|
889
904
|
runState ??= {
|
|
890
|
-
remaining:
|
|
905
|
+
remaining: MAX_REFINE_RUNS,
|
|
891
906
|
warned: false
|
|
892
907
|
};
|
|
893
908
|
protectedVariants ??= {};
|
|
@@ -921,7 +936,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
921
936
|
return nextResolved;
|
|
922
937
|
}
|
|
923
938
|
if (useDirectOutput && runState.remaining === 0) {
|
|
924
|
-
|
|
939
|
+
warnRefineLimit(runState);
|
|
925
940
|
return nextResolved;
|
|
926
941
|
}
|
|
927
942
|
if (useDirectOutput) {
|
|
@@ -934,33 +949,33 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
934
949
|
workingResolved = nextResolved;
|
|
935
950
|
isFirstRun = false;
|
|
936
951
|
}
|
|
937
|
-
|
|
952
|
+
warnRefineLimit(runState);
|
|
938
953
|
for (let i = 0; i < lastClasses.length; i++) classesOut.push(lastClasses[i]);
|
|
939
954
|
Object.assign(styleOut, lastStyle);
|
|
940
955
|
return workingResolved;
|
|
941
956
|
};
|
|
942
|
-
const
|
|
957
|
+
const resolveRefineOnce = (resolved, userVariantProps, filterOwnVariants = true, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys) => {
|
|
943
958
|
let workingResolved = resolved;
|
|
944
959
|
let changedVariants = null;
|
|
945
|
-
if (
|
|
946
|
-
const
|
|
947
|
-
workingResolved =
|
|
948
|
-
changedVariants =
|
|
960
|
+
if (refine) {
|
|
961
|
+
const refineResult = runRefineContext(resolved, userVariantProps, filterOwnVariants, false, protectedVariants, pendingProtectedVariants, protectedVariantKeys);
|
|
962
|
+
workingResolved = refineResult.workingResolved;
|
|
963
|
+
changedVariants = refineResult.changedVariants;
|
|
949
964
|
}
|
|
950
|
-
if (
|
|
965
|
+
if (extMetasWithRefineCount > 0) {
|
|
951
966
|
const extUserVariantProps = getExtUserVariantProps(userVariantProps, protectedVariants ?? null, changedVariants);
|
|
952
|
-
for (let i = 0; i <
|
|
953
|
-
const
|
|
954
|
-
if (!
|
|
955
|
-
workingResolved =
|
|
967
|
+
for (let i = 0; i < extMetasWithRefineCount; i++) {
|
|
968
|
+
const resolveRefine = extMetasWithRefine[i].resolveRefine;
|
|
969
|
+
if (!resolveRefine) continue;
|
|
970
|
+
workingResolved = resolveRefine(workingResolved, extUserVariantProps, true, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys);
|
|
956
971
|
if (protectedVariants) Object.assign(extUserVariantProps, protectedVariants);
|
|
957
972
|
}
|
|
958
973
|
}
|
|
959
974
|
return workingResolved;
|
|
960
975
|
};
|
|
961
|
-
const
|
|
976
|
+
const resolveRefine = refine || extMetasWithRefineCount > 0 ? (resolved, userVariantProps, filterOwnVariants = true, runState, protectedVariants, pendingProtectedVariants, protectedVariantKeys) => {
|
|
962
977
|
runState ??= {
|
|
963
|
-
remaining:
|
|
978
|
+
remaining: MAX_REFINE_RUNS,
|
|
964
979
|
warned: false
|
|
965
980
|
};
|
|
966
981
|
protectedVariants ??= {};
|
|
@@ -970,7 +985,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
970
985
|
while (runState.remaining > 0) {
|
|
971
986
|
runState.remaining -= 1;
|
|
972
987
|
const nextPendingProtectedVariants = {};
|
|
973
|
-
const nextResolved =
|
|
988
|
+
const nextResolved = resolveRefineOnce(workingResolved, userVariantProps, filterOwnVariants, runState, protectedVariants, nextPendingProtectedVariants, protectedVariantKeys);
|
|
974
989
|
let protectedChanged;
|
|
975
990
|
if (pendingProtectedVariants) protectedChanged = mergeVariants(pendingProtectedVariants, nextPendingProtectedVariants, protectedVariantKeys);
|
|
976
991
|
else protectedChanged = mergeVariants(protectedVariants, nextPendingProtectedVariants, protectedVariantKeys);
|
|
@@ -981,7 +996,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
981
996
|
}
|
|
982
997
|
workingResolved = nextResolved;
|
|
983
998
|
}
|
|
984
|
-
if (reachedLimit)
|
|
999
|
+
if (reachedLimit) warnRefineLimit(runState);
|
|
985
1000
|
return workingResolved;
|
|
986
1001
|
} : null;
|
|
987
1002
|
const computeResult = (props = EMPTY_DEFAULTS) => {
|
|
@@ -989,17 +1004,17 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
989
1004
|
let resolved = {};
|
|
990
1005
|
Object.assign(resolved, staticDefaults);
|
|
991
1006
|
let userVariantProps;
|
|
992
|
-
if (
|
|
1007
|
+
if (extMetasWithRefineCount > 0) {
|
|
993
1008
|
const variantProps = {};
|
|
994
1009
|
for (let i = 0; i < variantKeysLength; i++) {
|
|
995
1010
|
const key = variantKeys[i];
|
|
996
1011
|
if (Object.hasOwn(propsRecord, key)) variantProps[key] = propsRecord[key];
|
|
997
1012
|
}
|
|
998
|
-
for (let i = 0; i <
|
|
999
|
-
const
|
|
1000
|
-
for (const k in
|
|
1001
|
-
if (!Object.hasOwn(
|
|
1002
|
-
resolved[k] =
|
|
1013
|
+
for (let i = 0; i < extMetasWithRefineCount; i++) {
|
|
1014
|
+
const extDefaults = extMetasWithRefine[i].resolveDefaults(resolved, variantProps);
|
|
1015
|
+
for (const k in extDefaults) {
|
|
1016
|
+
if (!Object.hasOwn(extDefaults, k)) continue;
|
|
1017
|
+
resolved[k] = extDefaults[k];
|
|
1003
1018
|
}
|
|
1004
1019
|
}
|
|
1005
1020
|
for (const k in variantProps) {
|
|
@@ -1050,7 +1065,7 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
1050
1065
|
const getVariants = (variants) => {
|
|
1051
1066
|
const variantProps = variants ?? EMPTY_DEFAULTS;
|
|
1052
1067
|
let resolvedVariants = resolveVariantsHot(variantProps);
|
|
1053
|
-
if (
|
|
1068
|
+
if (resolveRefine) resolvedVariants = resolveRefine(resolvedVariants, variantProps, false);
|
|
1054
1069
|
return resolvedVariants;
|
|
1055
1070
|
};
|
|
1056
1071
|
const computedBaseClass = hasExtend ? clsx(...extBaseClassesArr, config.class) : clsx(config.class);
|
|
@@ -1062,8 +1077,9 @@ function create({ transformClass = (className) => className } = {}) {
|
|
|
1062
1077
|
staticDefaults,
|
|
1063
1078
|
resolveDefaults: resolveDefaultsFn,
|
|
1064
1079
|
compute,
|
|
1065
|
-
|
|
1066
|
-
transformClass
|
|
1080
|
+
resolveRefine,
|
|
1081
|
+
transformClass,
|
|
1082
|
+
functionVariantKeys
|
|
1067
1083
|
};
|
|
1068
1084
|
const initComponent = (c, propKeys, style) => {
|
|
1069
1085
|
c.class = classFn;
|