@wildwinter/expr-editor 0.12.2 → 0.12.3

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
@@ -221,6 +221,22 @@ var BINARY_LABEL = {
221
221
  "/": "\xF7"
222
222
  };
223
223
  var UNARY_LABEL = { not: "NOT", neg: "\u2212" };
224
+ var OP_WORD = {
225
+ "==": "equals",
226
+ "!=": "not equal to",
227
+ ">": "greater than",
228
+ ">=": "at least",
229
+ "<": "less than",
230
+ "<=": "at most",
231
+ and: "and",
232
+ or: "or",
233
+ "+": "plus",
234
+ "-": "minus",
235
+ "*": "times",
236
+ "/": "divided by",
237
+ not: "not",
238
+ neg: "negative"
239
+ };
224
240
  var COMPARISON_OPS = ["==", "!=", ">", ">=", "<", "<="];
225
241
  var ARITHMETIC_OPS = ["+", "-", "*", "/"];
226
242
  var COMPARABLE_TYPES = ["boolean", "number", "string", "enum", "quality"];
@@ -406,20 +422,6 @@ function pill(kind, label, onClick, opts = {}) {
406
422
  if (opts.path) b.dataset["exedPath"] = opts.path.join("/");
407
423
  return b;
408
424
  }
409
- var OP_ARIA = {
410
- "==": "equals",
411
- "!=": "not equal to",
412
- ">": "greater than",
413
- ">=": "at least",
414
- "<": "less than",
415
- "<=": "at most",
416
- "and": "and",
417
- "or": "or",
418
- "+": "plus",
419
- "-": "minus",
420
- "*": "times",
421
- "/": "divided by"
422
- };
423
425
  var issueText = (ctx, path) => {
424
426
  const list = issuesAt(ctx.byPath, path);
425
427
  return list.length ? list.map((i) => i.message).join("; ") : void 0;
@@ -473,7 +475,7 @@ function renderNode(node, path, ctx, parentOp, side) {
473
475
  }
474
476
  case "unary": {
475
477
  const row = el("span", "exed-unary");
476
- row.append(pill("op", UNARY_LABEL[node.op], () => ctx.apply(deleteOrUnwrapNot(ctx, path, node)), { title: "remove", aria: `${OP_ARIA[node.op] ?? node.op} (click to remove)` }));
478
+ row.append(pill("op", UNARY_LABEL[node.op], () => ctx.apply(deleteOrUnwrapNot(ctx, path, node)), { title: "remove", aria: `${OP_WORD[node.op]} (click to remove)` }));
477
479
  row.append(renderNode(node.operand, [...path, "operand"], ctx));
478
480
  return row;
479
481
  }
@@ -485,7 +487,7 @@ function renderNode(node, path, ctx, parentOp, side) {
485
487
  const swap = opSwapGroup(node.op);
486
488
  const opPill = pill("op", BINARY_LABEL[node.op], (b) => {
487
489
  if (swap) operatorEditor(ctx, path, node.op, swap, b);
488
- }, { title: swap ? "swap operator" : void 0, aria: OP_ARIA[node.op] ?? node.op });
490
+ }, { title: swap ? "swap operator" : void 0, aria: OP_WORD[node.op] });
489
491
  if (!swap) opPill.classList.add("exed-op-structural");
490
492
  row.append(opPill);
491
493
  row.append(renderNode(node.right, [...path, "right"], ctx, node.op, "right"));
@@ -596,12 +598,14 @@ function operatorEditor(ctx, path, current, group, anchor) {
596
598
  const wrap = el("div", "exed-menu");
597
599
  wrap.append(el("div", "exed-menu-head", ["Operator"]));
598
600
  for (const op of group) {
599
- wrap.append(button(`exed-opt${op === current ? " sel" : ""}`, `${BINARY_LABEL[op]} ${op}`, () => {
601
+ const row = button(`exed-opt exed-opt-op${op === current ? " sel" : ""}`, "", () => {
600
602
  const node = ctx.getAst();
601
603
  const cur = setNodeAt(node, path, { ...getBinary(ctx, path), op });
602
604
  ctx.apply(cur);
603
605
  close();
604
- }));
606
+ });
607
+ row.append(el("span", "exed-opt-name", [BINARY_LABEL[op]]), el("span", "exed-opt-purpose", [OP_WORD[op]]));
608
+ wrap.append(row);
605
609
  }
606
610
  return wrap;
607
611
  });
@@ -717,17 +721,9 @@ function propertyPicker(ctx, opts) {
717
721
  }
718
722
 
719
723
  // src/clausewizard.ts
720
- var OP_WORD = {
721
- "==": "equals",
722
- "!=": "not equal to",
723
- ">": "greater than",
724
- ">=": "at least",
725
- "<": "less than",
726
- "<=": "at most"
727
- };
728
724
  var opButton = (o, onClick) => {
729
- const b = button("exed-opt", "", onClick);
730
- b.append(el("span", "exed-opt-name", [BINARY_LABEL[o]]), el("span", "exed-opt-purpose", [OP_WORD[o] ?? ""]));
725
+ const b = button("exed-opt exed-opt-op", "", onClick);
726
+ b.append(el("span", "exed-opt-name", [BINARY_LABEL[o]]), el("span", "exed-opt-purpose", [OP_WORD[o]]));
731
727
  return b;
732
728
  };
733
729
  function header(host, title, back, cancel) {
@@ -1754,6 +1750,7 @@ exports.BINARY_LABEL = BINARY_LABEL;
1754
1750
  exports.COMPARABLE_TYPES = COMPARABLE_TYPES;
1755
1751
  exports.COMPARISON_OPS = COMPARISON_OPS;
1756
1752
  exports.EQUALITY_OPS = EQUALITY_OPS;
1753
+ exports.OP_WORD = OP_WORD;
1757
1754
  exports.UNARY_LABEL = UNARY_LABEL;
1758
1755
  exports.addArg = addArg;
1759
1756
  exports.addChildToContainer = addChildToContainer;