@novely/core 0.44.3 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -13
- package/dist/index.global.js +26 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1201,6 +1201,7 @@ var novely = ({
|
|
|
1201
1201
|
flatActions(choice.children),
|
|
1202
1202
|
choice.active,
|
|
1203
1203
|
choice.visible,
|
|
1204
|
+
choice.onSelect,
|
|
1204
1205
|
choice.image
|
|
1205
1206
|
];
|
|
1206
1207
|
}
|
|
@@ -1735,20 +1736,32 @@ var novely = ({
|
|
|
1735
1736
|
choices.unshift(question);
|
|
1736
1737
|
question = "";
|
|
1737
1738
|
}
|
|
1738
|
-
const transformedChoices = choices.map(([content,
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1739
|
+
const transformedChoices = choices.map(([content, _children, active, visible, onSelect, image]) => {
|
|
1740
|
+
const active$ = store(false);
|
|
1741
|
+
const visible$ = store(false);
|
|
1742
|
+
const update = () => {
|
|
1743
|
+
const lang = getLanguageFromStore(storageData);
|
|
1744
|
+
const state = getStateAtCtx(ctx);
|
|
1745
|
+
const activeValue = !active || active({
|
|
1746
|
+
lang,
|
|
1747
|
+
state
|
|
1748
|
+
});
|
|
1749
|
+
const visibleValue = !visible || visible({
|
|
1750
|
+
lang,
|
|
1751
|
+
state
|
|
1752
|
+
});
|
|
1753
|
+
active$.set(activeValue);
|
|
1754
|
+
visible$.set(visibleValue);
|
|
1755
|
+
};
|
|
1756
|
+
update();
|
|
1757
|
+
const onSelectGuarded = onSelect || noop;
|
|
1758
|
+
const onSelectWrapped = () => {
|
|
1759
|
+
onSelectGuarded({
|
|
1760
|
+
recompute: update
|
|
1761
|
+
});
|
|
1762
|
+
};
|
|
1747
1763
|
const imageValue = image ? handleImageAsset(image) : "";
|
|
1748
|
-
|
|
1749
|
-
console.warn(`Choice children should not be empty, either add content there or make item not selectable`);
|
|
1750
|
-
}
|
|
1751
|
-
return [templateReplace(content, data2), activeValue, visibleValue, imageValue];
|
|
1764
|
+
return [templateReplace(content, data2), active$, visible$, onSelectWrapped, imageValue];
|
|
1752
1765
|
});
|
|
1753
1766
|
if (DEV3 && transformedChoices.length === 0) {
|
|
1754
1767
|
throw new Error(`Running choice without variants to choose from, look at how to use Choice action properly [https://novely.pages.dev/guide/actions/choice#usage]`);
|