@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.d.cts CHANGED
@@ -108,6 +108,12 @@ declare function moveChildInContainer(ast: ExprNode, chainPath: AstPath, from: n
108
108
  /** Human label for a binary operator (words for logical, glyphs for relational). */
109
109
  declare const BINARY_LABEL: Record<BinaryOp, string>;
110
110
  declare const UNARY_LABEL: Record<UnaryOp, string>;
111
+ /** Plain-language name for an operator. ONE table, because it is wanted in three places that must
112
+ * agree: a pill's accessible label, the clause wizard's operator step, and the swap menu. The swap
113
+ * menu once printed the label and the raw source instead ("> >"), which is what a second table
114
+ * buys you. Never the glyph twice: this reads NEXT to `BINARY_LABEL`, so it must say something the
115
+ * glyph does not. */
116
+ declare const OP_WORD: Record<BinaryOp | UnaryOp, string>;
111
117
  declare const COMPARISON_OPS: BinaryOp[];
112
118
  declare const ARITHMETIC_OPS: BinaryOp[];
113
119
  /** Property types a comparison clause can be built on - what the clause wizard offers as a left-hand
@@ -492,4 +498,4 @@ interface ValueWizardOptions {
492
498
  /** Build the wizard UI into a fresh element (drive it via the host's popover). */
493
499
  declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
494
500
 
495
- export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, type CatalogueEntry, EQUALITY_OPS, type EditCtx, type EditorEffect, type EffectsEditorHandle, type EffectsEditorOptions, type ExpressionEditorHandle, type ExpressionEditorOptions, type Filter, type FunctionTemplateSpec, type PreviewOptions, type TreeRow, UNARY_LABEL, type Validation, type ValueWizardOptions, type WizardSpec, type WizardStepSpec, type WizardValue, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
501
+ export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, type CatalogueEntry, EQUALITY_OPS, type EditCtx, type EditorEffect, type EffectsEditorHandle, type EffectsEditorOptions, type ExpressionEditorHandle, type ExpressionEditorOptions, type Filter, type FunctionTemplateSpec, OP_WORD, type PreviewOptions, type TreeRow, UNARY_LABEL, type Validation, type ValueWizardOptions, type WizardSpec, type WizardStepSpec, type WizardValue, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
package/dist/index.d.ts CHANGED
@@ -108,6 +108,12 @@ declare function moveChildInContainer(ast: ExprNode, chainPath: AstPath, from: n
108
108
  /** Human label for a binary operator (words for logical, glyphs for relational). */
109
109
  declare const BINARY_LABEL: Record<BinaryOp, string>;
110
110
  declare const UNARY_LABEL: Record<UnaryOp, string>;
111
+ /** Plain-language name for an operator. ONE table, because it is wanted in three places that must
112
+ * agree: a pill's accessible label, the clause wizard's operator step, and the swap menu. The swap
113
+ * menu once printed the label and the raw source instead ("> >"), which is what a second table
114
+ * buys you. Never the glyph twice: this reads NEXT to `BINARY_LABEL`, so it must say something the
115
+ * glyph does not. */
116
+ declare const OP_WORD: Record<BinaryOp | UnaryOp, string>;
111
117
  declare const COMPARISON_OPS: BinaryOp[];
112
118
  declare const ARITHMETIC_OPS: BinaryOp[];
113
119
  /** Property types a comparison clause can be built on - what the clause wizard offers as a left-hand
@@ -492,4 +498,4 @@ interface ValueWizardOptions {
492
498
  /** Build the wizard UI into a fresh element (drive it via the host's popover). */
493
499
  declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
494
500
 
495
- export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, type CatalogueEntry, EQUALITY_OPS, type EditCtx, type EditorEffect, type EffectsEditorHandle, type EffectsEditorOptions, type ExpressionEditorHandle, type ExpressionEditorOptions, type Filter, type FunctionTemplateSpec, type PreviewOptions, type TreeRow, UNARY_LABEL, type Validation, type ValueWizardOptions, type WizardSpec, type WizardStepSpec, type WizardValue, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
501
+ export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, type CatalogueEntry, EQUALITY_OPS, type EditCtx, type EditorEffect, type EffectsEditorHandle, type EffectsEditorOptions, type ExpressionEditorHandle, type ExpressionEditorOptions, type Filter, type FunctionTemplateSpec, OP_WORD, type PreviewOptions, type TreeRow, UNARY_LABEL, type Validation, type ValueWizardOptions, type WizardSpec, type WizardStepSpec, type WizardValue, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
package/dist/index.js CHANGED
@@ -219,6 +219,22 @@ var BINARY_LABEL = {
219
219
  "/": "\xF7"
220
220
  };
221
221
  var UNARY_LABEL = { not: "NOT", neg: "\u2212" };
222
+ var OP_WORD = {
223
+ "==": "equals",
224
+ "!=": "not equal to",
225
+ ">": "greater than",
226
+ ">=": "at least",
227
+ "<": "less than",
228
+ "<=": "at most",
229
+ and: "and",
230
+ or: "or",
231
+ "+": "plus",
232
+ "-": "minus",
233
+ "*": "times",
234
+ "/": "divided by",
235
+ not: "not",
236
+ neg: "negative"
237
+ };
222
238
  var COMPARISON_OPS = ["==", "!=", ">", ">=", "<", "<="];
223
239
  var ARITHMETIC_OPS = ["+", "-", "*", "/"];
224
240
  var COMPARABLE_TYPES = ["boolean", "number", "string", "enum", "quality"];
@@ -404,20 +420,6 @@ function pill(kind, label, onClick, opts = {}) {
404
420
  if (opts.path) b.dataset["exedPath"] = opts.path.join("/");
405
421
  return b;
406
422
  }
407
- var OP_ARIA = {
408
- "==": "equals",
409
- "!=": "not equal to",
410
- ">": "greater than",
411
- ">=": "at least",
412
- "<": "less than",
413
- "<=": "at most",
414
- "and": "and",
415
- "or": "or",
416
- "+": "plus",
417
- "-": "minus",
418
- "*": "times",
419
- "/": "divided by"
420
- };
421
423
  var issueText = (ctx, path) => {
422
424
  const list = issuesAt(ctx.byPath, path);
423
425
  return list.length ? list.map((i) => i.message).join("; ") : void 0;
@@ -471,7 +473,7 @@ function renderNode(node, path, ctx, parentOp, side) {
471
473
  }
472
474
  case "unary": {
473
475
  const row = el("span", "exed-unary");
474
- 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)` }));
476
+ row.append(pill("op", UNARY_LABEL[node.op], () => ctx.apply(deleteOrUnwrapNot(ctx, path, node)), { title: "remove", aria: `${OP_WORD[node.op]} (click to remove)` }));
475
477
  row.append(renderNode(node.operand, [...path, "operand"], ctx));
476
478
  return row;
477
479
  }
@@ -483,7 +485,7 @@ function renderNode(node, path, ctx, parentOp, side) {
483
485
  const swap = opSwapGroup(node.op);
484
486
  const opPill = pill("op", BINARY_LABEL[node.op], (b) => {
485
487
  if (swap) operatorEditor(ctx, path, node.op, swap, b);
486
- }, { title: swap ? "swap operator" : void 0, aria: OP_ARIA[node.op] ?? node.op });
488
+ }, { title: swap ? "swap operator" : void 0, aria: OP_WORD[node.op] });
487
489
  if (!swap) opPill.classList.add("exed-op-structural");
488
490
  row.append(opPill);
489
491
  row.append(renderNode(node.right, [...path, "right"], ctx, node.op, "right"));
@@ -594,12 +596,14 @@ function operatorEditor(ctx, path, current, group, anchor) {
594
596
  const wrap = el("div", "exed-menu");
595
597
  wrap.append(el("div", "exed-menu-head", ["Operator"]));
596
598
  for (const op of group) {
597
- wrap.append(button(`exed-opt${op === current ? " sel" : ""}`, `${BINARY_LABEL[op]} ${op}`, () => {
599
+ const row = button(`exed-opt exed-opt-op${op === current ? " sel" : ""}`, "", () => {
598
600
  const node = ctx.getAst();
599
601
  const cur = setNodeAt(node, path, { ...getBinary(ctx, path), op });
600
602
  ctx.apply(cur);
601
603
  close();
602
- }));
604
+ });
605
+ row.append(el("span", "exed-opt-name", [BINARY_LABEL[op]]), el("span", "exed-opt-purpose", [OP_WORD[op]]));
606
+ wrap.append(row);
603
607
  }
604
608
  return wrap;
605
609
  });
@@ -715,17 +719,9 @@ function propertyPicker(ctx, opts) {
715
719
  }
716
720
 
717
721
  // src/clausewizard.ts
718
- var OP_WORD = {
719
- "==": "equals",
720
- "!=": "not equal to",
721
- ">": "greater than",
722
- ">=": "at least",
723
- "<": "less than",
724
- "<=": "at most"
725
- };
726
722
  var opButton = (o, onClick) => {
727
- const b = button("exed-opt", "", onClick);
728
- b.append(el("span", "exed-opt-name", [BINARY_LABEL[o]]), el("span", "exed-opt-purpose", [OP_WORD[o] ?? ""]));
723
+ const b = button("exed-opt exed-opt-op", "", onClick);
724
+ b.append(el("span", "exed-opt-name", [BINARY_LABEL[o]]), el("span", "exed-opt-purpose", [OP_WORD[o]]));
729
725
  return b;
730
726
  };
731
727
  function header(host, title, back, cancel) {
@@ -1747,6 +1743,6 @@ function renderEffectsPreview(effects, o) {
1747
1743
  return wrap;
1748
1744
  }
1749
1745
 
1750
- export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, EQUALITY_OPS, UNARY_LABEL, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
1746
+ export { ARITHMETIC_OPS, BINARY_LABEL, COMPARABLE_TYPES, COMPARISON_OPS, EQUALITY_OPS, OP_WORD, UNARY_LABEL, addArg, addChildToContainer, addEmit, addSet, astToTree, binary, boolLit, buildSubGroupClause, callNode, choicesOf, comparisonOpsFor, deleteAt, displayName, filterCatalogue, findChoicePeer, findEnumPeer, firstEmptyLeafPath, flagDelta, flipContainerOp, formatNumber, getNodeAt, groupByScope, initialValueFor, insertSiblingClauseAt, isComparisonOp, isPlaceholderForOp, isWrappedInNot, issuesAt, lookup, mountEffectsEditor, mountExpressionEditor, moveAt, moveChildInContainer, needsParens, notNode, numLit, opSwapGroup, pathKey, placeholderForOp, redirectDeleteForPlaceholderSibling, refOf, removeArgAt, removeAt, renderConditionPreview, renderEffectsPreview, rhsTypesFor, scopedVar, searchCatalogue, seedValueSrc, setArgAt, setNodeAt, strLit, toggleContainerNot, toggleNotAt, updateAt, validateSource, valueWizard, wrapInNotAt };
1751
1747
  //# sourceMappingURL=index.js.map
1752
1748
  //# sourceMappingURL=index.js.map