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