@novely/core 0.44.3 → 0.45.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.d.ts +16 -13
- package/dist/index.global.js +23 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +23 -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,29 @@ 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 activeValue = !active || active({
|
|
1744
|
+
lang: getLanguageFromStore(storageData),
|
|
1745
|
+
state: getStateAtCtx(ctx)
|
|
1746
|
+
});
|
|
1747
|
+
const visibleValue = !visible || visible({
|
|
1748
|
+
lang: getLanguageFromStore(storageData),
|
|
1749
|
+
state: getStateAtCtx(ctx)
|
|
1750
|
+
});
|
|
1751
|
+
active$.set(activeValue);
|
|
1752
|
+
visible$.set(visibleValue);
|
|
1753
|
+
};
|
|
1754
|
+
update();
|
|
1755
|
+
const onSelectGuarded = onSelect || noop;
|
|
1756
|
+
const onSelectWrapped = async () => {
|
|
1757
|
+
await onSelectGuarded();
|
|
1758
|
+
update();
|
|
1759
|
+
};
|
|
1747
1760
|
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];
|
|
1761
|
+
return [templateReplace(content, data2), active$, visible$, onSelectWrapped, imageValue];
|
|
1752
1762
|
});
|
|
1753
1763
|
if (DEV3 && transformedChoices.length === 0) {
|
|
1754
1764
|
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]`);
|