@wildwinter/expr-editor 0.14.0 → 0.14.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.cjs +25 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -18
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -429,6 +429,14 @@ function textField(opts) {
|
|
|
429
429
|
setTimeout(() => input.focus(), 0);
|
|
430
430
|
return wrap;
|
|
431
431
|
}
|
|
432
|
+
function propertyMenuBody(actions, close) {
|
|
433
|
+
const wrap = el("div", "exed-menu");
|
|
434
|
+
for (const a of actions) wrap.append(button("exed-opt", a.label, () => {
|
|
435
|
+
a.run();
|
|
436
|
+
close();
|
|
437
|
+
}));
|
|
438
|
+
return wrap;
|
|
439
|
+
}
|
|
432
440
|
|
|
433
441
|
// src/flat.ts
|
|
434
442
|
var FLAG_FNS = /* @__PURE__ */ new Set(["check_flags", "set_flags"]);
|
|
@@ -547,14 +555,7 @@ function attachPropertyMenu(ctx, node, pillEl) {
|
|
|
547
555
|
const open = ctx.openMenu ?? ctx.openPopover;
|
|
548
556
|
pillEl.addEventListener("contextmenu", (e) => {
|
|
549
557
|
e.preventDefault();
|
|
550
|
-
open(pillEl, (close) =>
|
|
551
|
-
const wrap = el("div", "exed-menu");
|
|
552
|
-
for (const a of actions) wrap.append(button("exed-opt", a.label, () => {
|
|
553
|
-
a.run();
|
|
554
|
-
close();
|
|
555
|
-
}));
|
|
556
|
-
return wrap;
|
|
557
|
-
});
|
|
558
|
+
open(pillEl, (close) => propertyMenuBody(actions, close));
|
|
558
559
|
});
|
|
559
560
|
}
|
|
560
561
|
function isCompoundComparison(node, ctx) {
|
|
@@ -1623,14 +1624,7 @@ function mountEffectsEditor(host, opts) {
|
|
|
1623
1624
|
if (actions.length) targetBtn.addEventListener("contextmenu", (e) => {
|
|
1624
1625
|
e.preventDefault();
|
|
1625
1626
|
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 });
|
|
1627
|
+
popover = openPopover(targetBtn, (close) => propertyMenuBody(actions, close), { container: opts.popoverContainer });
|
|
1634
1628
|
});
|
|
1635
1629
|
}
|
|
1636
1630
|
const advances = isSelfAdvance(eff, defaultScope, opts.dialect);
|
|
@@ -1796,13 +1790,26 @@ function renderConditionPreview(src, o) {
|
|
|
1796
1790
|
const cls = o.propertyActions ? "exed-preview exed-preview-interactive" : "exed-preview";
|
|
1797
1791
|
return el("div", cls, [exprPills(src, o)]);
|
|
1798
1792
|
}
|
|
1793
|
+
function targetPill(ref, o) {
|
|
1794
|
+
const pill2 = el("span", "exed-pill exed-pill-prop", [ref || "(property)"]);
|
|
1795
|
+
const entry = o.catalogue.find((e) => refOf(e, o.dialect.defaultScope) === ref);
|
|
1796
|
+
if (!entry) return pill2;
|
|
1797
|
+
const tip = propertyTip(entry);
|
|
1798
|
+
if (tip) pill2.title = tip;
|
|
1799
|
+
const actions = o.propertyActions?.({ scope: entry.scope, name: entry.name }) ?? [];
|
|
1800
|
+
if (actions.length) pill2.addEventListener("contextmenu", (e) => {
|
|
1801
|
+
e.preventDefault();
|
|
1802
|
+
openPopover(pill2, (close) => propertyMenuBody(actions, close), { container: o.popoverContainer });
|
|
1803
|
+
});
|
|
1804
|
+
return pill2;
|
|
1805
|
+
}
|
|
1799
1806
|
function renderEffectsPreview(effects, o) {
|
|
1800
|
-
const wrap = el("div",
|
|
1807
|
+
const wrap = el("div", `exed-preview exed-preview-effects${o.propertyActions ? " exed-preview-interactive" : ""}`);
|
|
1801
1808
|
for (const eff of effects) {
|
|
1802
1809
|
const row = el("div", "exed-preview-eff");
|
|
1803
1810
|
if (eff.kind === "set") {
|
|
1804
1811
|
const advances = isSelfAdvance(eff, o.dialect.defaultScope, o.dialect);
|
|
1805
|
-
row.append(
|
|
1812
|
+
row.append(targetPill(eff.target, o));
|
|
1806
1813
|
if (!advances) row.append(el("span", "exed-effect-eq", ["="]));
|
|
1807
1814
|
row.append(exprPills(eff.value, o, advances ? eff.target : void 0));
|
|
1808
1815
|
} else {
|