@wildwinter/expr-editor 0.13.0 → 0.14.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.cjs +38 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -288,6 +288,13 @@ var choicesOf = (e) => {
|
|
|
288
288
|
if (e.type === "enum") return e.enumValues;
|
|
289
289
|
return void 0;
|
|
290
290
|
};
|
|
291
|
+
var propertyTip = (e) => {
|
|
292
|
+
if (!e) return void 0;
|
|
293
|
+
const lines = [];
|
|
294
|
+
if (e.purpose) lines.push(e.purpose);
|
|
295
|
+
if (e.type === "quality" && e.stages?.length) lines.push(`Stages: ${e.stages.join(" \u2192 ")}`);
|
|
296
|
+
return lines.length ? lines.join("\n") : void 0;
|
|
297
|
+
};
|
|
291
298
|
var refOf = (e, defaultScope) => e.scope === defaultScope ? `@${e.name}` : `@${e.scope}.${e.name}`;
|
|
292
299
|
var displayName = (e, defaultScope) => e.scope === defaultScope ? e.name : `${e.scope}.${e.name}`;
|
|
293
300
|
function filterCatalogue(entries, filter = {}) {
|
|
@@ -459,7 +466,12 @@ function renderNode(node, path, ctx, parentOp, side) {
|
|
|
459
466
|
case "scopedvar": {
|
|
460
467
|
const entry = lookup(ctx.catalogue, node.scope, node.name);
|
|
461
468
|
const label = displayName({ scope: node.scope, name: node.name }, ctx.defaultScope);
|
|
462
|
-
const varPill = pill(
|
|
469
|
+
const varPill = pill(
|
|
470
|
+
"var",
|
|
471
|
+
label,
|
|
472
|
+
(b) => variableEditor(ctx, path, node, b),
|
|
473
|
+
{ issue: issue ?? (entry ? void 0 : `Unknown property ${label}`), title: propertyTip(entry) }
|
|
474
|
+
);
|
|
463
475
|
attachPropertyMenu(ctx, node, varPill);
|
|
464
476
|
return varPill;
|
|
465
477
|
}
|
|
@@ -1545,8 +1557,14 @@ function mountEffectsEditor(host, opts) {
|
|
|
1545
1557
|
scopeOrder: opts.scopeOrder,
|
|
1546
1558
|
functions: opts.functions,
|
|
1547
1559
|
mode: "flat",
|
|
1560
|
+
// Every editor here holds a VALUE (a set's value, an emit's argument), never a condition. Say
|
|
1561
|
+
// so, or emptying one falls back to the condition empty state and an outcome row reads
|
|
1562
|
+
// "always / + Add your first condition" - condition vocabulary, offering clauses where a value
|
|
1563
|
+
// belongs, and no way back to a value. `valueField` renders an editable empty literal instead.
|
|
1564
|
+
valueField: true,
|
|
1548
1565
|
...addTerm ? { addTerm } : {},
|
|
1549
1566
|
...selfAdvanceRef ? { selfAdvanceRef } : {},
|
|
1567
|
+
...opts.propertyActions ? { propertyActions: opts.propertyActions } : {},
|
|
1550
1568
|
...opts.popoverContainer ? { popoverContainer: opts.popoverContainer } : {},
|
|
1551
1569
|
text: textMode,
|
|
1552
1570
|
onChange
|
|
@@ -1597,6 +1615,24 @@ function mountEffectsEditor(host, opts) {
|
|
|
1597
1615
|
commit(updateAt(effects, i, { target: refOf(entry, defaultScope), value: initialValueFor(entry, defaultScope).src }));
|
|
1598
1616
|
});
|
|
1599
1617
|
}, "change the target property");
|
|
1618
|
+
const targetEntry = opts.catalogue.find((e) => refOf(e, defaultScope) === eff.target);
|
|
1619
|
+
const tip = propertyTip(targetEntry);
|
|
1620
|
+
if (tip) targetBtn.title = tip;
|
|
1621
|
+
if (targetEntry && opts.propertyActions) {
|
|
1622
|
+
const actions = opts.propertyActions({ scope: targetEntry.scope, name: targetEntry.name });
|
|
1623
|
+
if (actions.length) targetBtn.addEventListener("contextmenu", (e) => {
|
|
1624
|
+
e.preventDefault();
|
|
1625
|
+
closePopover();
|
|
1626
|
+
popover = openPopover(targetBtn, (close) => {
|
|
1627
|
+
const wrap = el("div", "exed-menu");
|
|
1628
|
+
for (const a of actions) wrap.append(button("exed-opt", a.label, () => {
|
|
1629
|
+
a.run();
|
|
1630
|
+
close();
|
|
1631
|
+
}));
|
|
1632
|
+
return wrap;
|
|
1633
|
+
}, { container: opts.popoverContainer });
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1600
1636
|
const advances = isSelfAdvance(eff, defaultScope, opts.dialect);
|
|
1601
1637
|
row.append(targetBtn);
|
|
1602
1638
|
if (!advances) row.append(el("span", "exed-effect-eq", ["="]));
|
|
@@ -1832,6 +1868,7 @@ exports.numLit = numLit;
|
|
|
1832
1868
|
exports.opSwapGroup = opSwapGroup;
|
|
1833
1869
|
exports.pathKey = pathKey;
|
|
1834
1870
|
exports.placeholderForOp = placeholderForOp;
|
|
1871
|
+
exports.propertyTip = propertyTip;
|
|
1835
1872
|
exports.redirectDeleteForPlaceholderSibling = redirectDeleteForPlaceholderSibling;
|
|
1836
1873
|
exports.refOf = refOf;
|
|
1837
1874
|
exports.removeArgAt = removeArgAt;
|