clava 0.6.4 → 0.7.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 +56 -0
- package/README.md +116 -32
- package/dist/index.d.ts +104 -44
- package/dist/index.js +34 -34
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/index.ts +145 -119
- package/src/refine-warning.ts +6 -6
- package/src/types.ts +104 -48
package/dist/index.js
CHANGED
|
@@ -256,9 +256,9 @@ function formatCreationStack(frame) {
|
|
|
256
256
|
}
|
|
257
257
|
function isInternalCreationFrame(line) {
|
|
258
258
|
if (line.includes("captureCreationFrame")) return true;
|
|
259
|
-
if (line.startsWith("at
|
|
260
|
-
if (line.startsWith("at
|
|
261
|
-
if (line.startsWith("
|
|
259
|
+
if (line.startsWith("at buildRecipe ")) return true;
|
|
260
|
+
if (line.startsWith("at buildRecipe(")) return true;
|
|
261
|
+
if (line.startsWith("buildRecipe@")) return true;
|
|
262
262
|
if (line.startsWith("at cv ")) return true;
|
|
263
263
|
if (line.startsWith("at cv(")) return true;
|
|
264
264
|
if (line.startsWith("cv@")) return true;
|
|
@@ -310,7 +310,7 @@ function warnRefineLimit({ creationFrame, unstableChanges }) {
|
|
|
310
310
|
}
|
|
311
311
|
if (creationFrame) {
|
|
312
312
|
const creationStack = formatCreationStack(creationFrame);
|
|
313
|
-
if (creationStack) message += `\
|
|
313
|
+
if (creationStack) message += `\nRecipe created at:\n${creationStack}`;
|
|
314
314
|
}
|
|
315
315
|
console.warn(message);
|
|
316
316
|
}
|
|
@@ -402,7 +402,7 @@ function getVariantValueKey(value) {
|
|
|
402
402
|
if (typeof value === "boolean") return String(value);
|
|
403
403
|
}
|
|
404
404
|
const EMPTY_KEYS = [];
|
|
405
|
-
function
|
|
405
|
+
function isRecipeKeySource(source) {
|
|
406
406
|
if (!source) return false;
|
|
407
407
|
if (typeof source !== "object" && typeof source !== "function") return false;
|
|
408
408
|
const typed = source;
|
|
@@ -410,10 +410,10 @@ function isComponentKeySource(source) {
|
|
|
410
410
|
if (!Array.isArray(typed.propKeys)) return false;
|
|
411
411
|
return Array.isArray(typed.variantKeys);
|
|
412
412
|
}
|
|
413
|
-
function splitPropsImpl(selfKeys,
|
|
413
|
+
function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
|
|
414
414
|
const sourcesLength = sources.length;
|
|
415
415
|
const results = [];
|
|
416
|
-
let stylingClaimed =
|
|
416
|
+
let stylingClaimed = selfIsRecipe;
|
|
417
417
|
const selfResult = {};
|
|
418
418
|
const selfKeysLength = selfKeys.length;
|
|
419
419
|
for (let i = 0; i < selfKeysLength; i++) {
|
|
@@ -425,11 +425,11 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
|
|
|
425
425
|
for (let s = 0; s < sourcesLength; s++) {
|
|
426
426
|
const source = sources[s];
|
|
427
427
|
const sourceResult = {};
|
|
428
|
-
let
|
|
428
|
+
let sourceIsRecipe = false;
|
|
429
429
|
let effectiveKeys;
|
|
430
430
|
if (Array.isArray(source)) effectiveKeys = source;
|
|
431
|
-
else if (
|
|
432
|
-
|
|
431
|
+
else if (isRecipeKeySource(source)) {
|
|
432
|
+
sourceIsRecipe = true;
|
|
433
433
|
effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;
|
|
434
434
|
} else effectiveKeys = EMPTY_KEYS;
|
|
435
435
|
const effectiveKeysLength = effectiveKeys.length;
|
|
@@ -439,7 +439,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
|
|
|
439
439
|
}
|
|
440
440
|
results.push(sourceResult);
|
|
441
441
|
effectiveKeyArrays.push(effectiveKeys);
|
|
442
|
-
if (
|
|
442
|
+
if (sourceIsRecipe && !stylingClaimed) stylingClaimed = true;
|
|
443
443
|
}
|
|
444
444
|
const rest = {};
|
|
445
445
|
const propKeys = Object.keys(props);
|
|
@@ -461,7 +461,7 @@ function splitPropsImpl(selfKeys, selfIsComponent, props, sources) {
|
|
|
461
461
|
}
|
|
462
462
|
const splitProps = ((props, source1, ...sources) => {
|
|
463
463
|
if (Array.isArray(source1)) return splitPropsImpl(source1, false, props, sources);
|
|
464
|
-
if (
|
|
464
|
+
if (isRecipeKeySource(source1)) return splitPropsImpl(source1.propKeys, true, props, sources);
|
|
465
465
|
return splitPropsImpl(EMPTY_KEYS, false, props, sources);
|
|
466
466
|
});
|
|
467
467
|
function buildPrebuiltVariant(variantDef) {
|
|
@@ -491,7 +491,7 @@ function buildPrebuiltVariant(variantDef) {
|
|
|
491
491
|
function create(params = {}) {
|
|
492
492
|
const transformClass = getOwn(params, "transformClass") ?? identityClass;
|
|
493
493
|
const cx = (...classes) => transformClass(clsx(classes));
|
|
494
|
-
const
|
|
494
|
+
const buildRecipe = (config = {}) => {
|
|
495
495
|
const extend = getOwn(config, "extend");
|
|
496
496
|
const variants = getOwn(config, "variants");
|
|
497
497
|
const refine = getOwn(config, "refine");
|
|
@@ -1072,72 +1072,72 @@ function create(params = {}) {
|
|
|
1072
1072
|
functionVariantKeys,
|
|
1073
1073
|
computedDefaultKeys
|
|
1074
1074
|
};
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
return
|
|
1075
|
+
const initRecipe = (recipe, propKeys, style) => {
|
|
1076
|
+
recipe.class = classFn;
|
|
1077
|
+
recipe.style = style;
|
|
1078
|
+
recipe.getVariants = getVariants;
|
|
1079
|
+
recipe.variantKeys = variantKeys;
|
|
1080
|
+
recipe.propKeys = propKeys;
|
|
1081
|
+
recipe[META_KEY] = meta;
|
|
1082
|
+
return recipe;
|
|
1083
1083
|
};
|
|
1084
|
-
const
|
|
1084
|
+
const defaultRecipe = ((props = {}) => {
|
|
1085
1085
|
const { className, style } = computeResult(props);
|
|
1086
1086
|
return {
|
|
1087
1087
|
class: className,
|
|
1088
1088
|
style
|
|
1089
1089
|
};
|
|
1090
1090
|
});
|
|
1091
|
-
|
|
1091
|
+
initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
|
|
1092
1092
|
return computeResult(props).style;
|
|
1093
1093
|
});
|
|
1094
|
-
const
|
|
1094
|
+
const jsxRecipe = ((props = {}) => {
|
|
1095
1095
|
const { className, style } = computeResult(props);
|
|
1096
1096
|
return {
|
|
1097
1097
|
className,
|
|
1098
1098
|
style
|
|
1099
1099
|
};
|
|
1100
1100
|
});
|
|
1101
|
-
|
|
1101
|
+
initRecipe(jsxRecipe, [
|
|
1102
1102
|
"className",
|
|
1103
1103
|
"style",
|
|
1104
1104
|
...variantKeys
|
|
1105
1105
|
], (props = {}) => computeResult(props).style);
|
|
1106
|
-
const
|
|
1106
|
+
const htmlRecipe = ((props = {}) => {
|
|
1107
1107
|
const { className, style } = computeResult(props);
|
|
1108
1108
|
return {
|
|
1109
1109
|
class: className,
|
|
1110
1110
|
style: styleValueToHTMLStyle(style)
|
|
1111
1111
|
};
|
|
1112
1112
|
});
|
|
1113
|
-
|
|
1113
|
+
initRecipe(htmlRecipe, [
|
|
1114
1114
|
"class",
|
|
1115
1115
|
"style",
|
|
1116
1116
|
...variantKeys
|
|
1117
1117
|
], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
|
|
1118
|
-
const
|
|
1118
|
+
const htmlObjRecipe = ((props = {}) => {
|
|
1119
1119
|
const { className, style } = computeResult(props);
|
|
1120
1120
|
return {
|
|
1121
1121
|
class: className,
|
|
1122
1122
|
style: styleValueToHTMLObjStyle(style)
|
|
1123
1123
|
};
|
|
1124
1124
|
});
|
|
1125
|
-
|
|
1125
|
+
initRecipe(htmlObjRecipe, [
|
|
1126
1126
|
"class",
|
|
1127
1127
|
"style",
|
|
1128
1128
|
...variantKeys
|
|
1129
1129
|
], (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style));
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1130
|
+
defaultRecipe.jsx = jsxRecipe;
|
|
1131
|
+
defaultRecipe.html = htmlRecipe;
|
|
1132
|
+
defaultRecipe.htmlObj = htmlObjRecipe;
|
|
1133
1133
|
return {
|
|
1134
|
-
|
|
1134
|
+
recipe: defaultRecipe,
|
|
1135
1135
|
meta
|
|
1136
1136
|
};
|
|
1137
1137
|
};
|
|
1138
1138
|
return build(initialExtensions);
|
|
1139
1139
|
};
|
|
1140
|
-
const cv = (config = {}) =>
|
|
1140
|
+
const cv = (config = {}) => buildRecipe(config).recipe;
|
|
1141
1141
|
return {
|
|
1142
1142
|
cv,
|
|
1143
1143
|
cx
|