@wildwinter/expr-editor 0.12.1 → 0.12.2

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 CHANGED
@@ -84,14 +84,15 @@ function toggleNotAt(ast, path) {
84
84
  }
85
85
  return wrapInNotAt(ast, path);
86
86
  }
87
- function findEnumPeer(ast, path) {
87
+ function findChoicePeer(ast, path) {
88
88
  const last = path[path.length - 1];
89
89
  if (last !== "left" && last !== "right") return null;
90
90
  const parent = getNodeAt(ast, path.slice(0, -1));
91
- if (parent?.kind !== "binary" || parent.op !== "==" && parent.op !== "!=") return null;
91
+ if (parent?.kind !== "binary" || !isComparisonOp(parent.op)) return null;
92
92
  const other = last === "left" ? parent.right : parent.left;
93
93
  return other.kind === "scopedvar" ? { scope: other.scope, name: other.name } : null;
94
94
  }
95
+ var findEnumPeer = findChoicePeer;
95
96
  function firstEmptyLeafPath(node, base = []) {
96
97
  switch (node.kind) {
97
98
  case "string":
@@ -561,7 +562,7 @@ function numberEditor(ctx, path, value, anchor) {
561
562
  }));
562
563
  }
563
564
  function stringEditor(ctx, path, node, anchor) {
564
- const peer = findEnumPeer(ctx.getAst(), path);
565
+ const peer = findChoicePeer(ctx.getAst(), path);
565
566
  const enumEntry = peer ? lookup(ctx.catalogue, peer.scope, peer.name) : null;
566
567
  const rootValueEnums = path.length === 0 && ctx.valueEnumValues?.length ? ctx.valueEnumValues : null;
567
568
  const peerChoices = choicesOf(enumEntry);
@@ -1768,6 +1769,7 @@ exports.comparisonOpsFor = comparisonOpsFor;
1768
1769
  exports.deleteAt = deleteAt;
1769
1770
  exports.displayName = displayName;
1770
1771
  exports.filterCatalogue = filterCatalogue;
1772
+ exports.findChoicePeer = findChoicePeer;
1771
1773
  exports.findEnumPeer = findEnumPeer;
1772
1774
  exports.firstEmptyLeafPath = firstEmptyLeafPath;
1773
1775
  exports.flagDelta = flagDelta;