@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.d.cts CHANGED
@@ -34,14 +34,25 @@ declare function wrapInNotAt(ast: ExprNode, path: AstPath): ExprNode;
34
34
  /** Add a `not` if absent, strip it if present. */
35
35
  declare function toggleNotAt(ast: ExprNode, path: AstPath): ExprNode;
36
36
  /**
37
- * If the node at `path` is one operand of an equality comparison (`==` / `!=`)
38
- * whose OTHER operand is a property reference, return that property — so a string
39
- * literal can offer the property's enum values. Null otherwise.
37
+ * If the node at `path` is one operand of a COMPARISON whose other operand is a property
38
+ * reference, return that property - so a literal can offer that property's choices (an enum's
39
+ * values, a quality's stages).
40
+ *
41
+ * Every comparison counts, not just `==` / `!=`. Equality was enough while an enum was the only
42
+ * type with a closed value list, because an enum is never ordered; a QUALITY is ordered, and
43
+ * `@investigation >= "certain"` is the shape its type exists for. Restricting to equality left
44
+ * exactly that clause offering a free-text box where the ladder should be.
45
+ *
46
+ * Whether the peer HAS choices is not decided here - that is `choicesOf`'s job. This answers only
47
+ * "which property is this literal being compared against", so a number's `> 1` resolves its peer
48
+ * and then offers nothing, as before.
40
49
  */
41
- declare function findEnumPeer(ast: ExprNode, path: AstPath): {
50
+ declare function findChoicePeer(ast: ExprNode, path: AstPath): {
42
51
  scope: string;
43
52
  name: string;
44
53
  } | null;
54
+ /** @deprecated Renamed to {@link findChoicePeer} - it serves qualities as well as enums now. */
55
+ declare const findEnumPeer: typeof findChoicePeer;
45
56
  /**
46
57
  * DFS for the first unfilled slot in a template-inserted clause: an empty string
47
58
  * literal (a tag / value the author still has to set) or an unnamed flag delta.
@@ -481,4 +492,4 @@ interface ValueWizardOptions {
481
492
  /** Build the wizard UI into a fresh element (drive it via the host's popover). */
482
493
  declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
483
494
 
484
- 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, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -34,14 +34,25 @@ declare function wrapInNotAt(ast: ExprNode, path: AstPath): ExprNode;
34
34
  /** Add a `not` if absent, strip it if present. */
35
35
  declare function toggleNotAt(ast: ExprNode, path: AstPath): ExprNode;
36
36
  /**
37
- * If the node at `path` is one operand of an equality comparison (`==` / `!=`)
38
- * whose OTHER operand is a property reference, return that property — so a string
39
- * literal can offer the property's enum values. Null otherwise.
37
+ * If the node at `path` is one operand of a COMPARISON whose other operand is a property
38
+ * reference, return that property - so a literal can offer that property's choices (an enum's
39
+ * values, a quality's stages).
40
+ *
41
+ * Every comparison counts, not just `==` / `!=`. Equality was enough while an enum was the only
42
+ * type with a closed value list, because an enum is never ordered; a QUALITY is ordered, and
43
+ * `@investigation >= "certain"` is the shape its type exists for. Restricting to equality left
44
+ * exactly that clause offering a free-text box where the ladder should be.
45
+ *
46
+ * Whether the peer HAS choices is not decided here - that is `choicesOf`'s job. This answers only
47
+ * "which property is this literal being compared against", so a number's `> 1` resolves its peer
48
+ * and then offers nothing, as before.
40
49
  */
41
- declare function findEnumPeer(ast: ExprNode, path: AstPath): {
50
+ declare function findChoicePeer(ast: ExprNode, path: AstPath): {
42
51
  scope: string;
43
52
  name: string;
44
53
  } | null;
54
+ /** @deprecated Renamed to {@link findChoicePeer} - it serves qualities as well as enums now. */
55
+ declare const findEnumPeer: typeof findChoicePeer;
45
56
  /**
46
57
  * DFS for the first unfilled slot in a template-inserted clause: an empty string
47
58
  * literal (a tag / value the author still has to set) or an unnamed flag delta.
@@ -481,4 +492,4 @@ interface ValueWizardOptions {
481
492
  /** Build the wizard UI into a fresh element (drive it via the host's popover). */
482
493
  declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
483
494
 
484
- 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, 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 };
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 };
package/dist/index.js CHANGED
@@ -82,14 +82,15 @@ function toggleNotAt(ast, path) {
82
82
  }
83
83
  return wrapInNotAt(ast, path);
84
84
  }
85
- function findEnumPeer(ast, path) {
85
+ function findChoicePeer(ast, path) {
86
86
  const last = path[path.length - 1];
87
87
  if (last !== "left" && last !== "right") return null;
88
88
  const parent = getNodeAt(ast, path.slice(0, -1));
89
- if (parent?.kind !== "binary" || parent.op !== "==" && parent.op !== "!=") return null;
89
+ if (parent?.kind !== "binary" || !isComparisonOp(parent.op)) return null;
90
90
  const other = last === "left" ? parent.right : parent.left;
91
91
  return other.kind === "scopedvar" ? { scope: other.scope, name: other.name } : null;
92
92
  }
93
+ var findEnumPeer = findChoicePeer;
93
94
  function firstEmptyLeafPath(node, base = []) {
94
95
  switch (node.kind) {
95
96
  case "string":
@@ -559,7 +560,7 @@ function numberEditor(ctx, path, value, anchor) {
559
560
  }));
560
561
  }
561
562
  function stringEditor(ctx, path, node, anchor) {
562
- const peer = findEnumPeer(ctx.getAst(), path);
563
+ const peer = findChoicePeer(ctx.getAst(), path);
563
564
  const enumEntry = peer ? lookup(ctx.catalogue, peer.scope, peer.name) : null;
564
565
  const rootValueEnums = path.length === 0 && ctx.valueEnumValues?.length ? ctx.valueEnumValues : null;
565
566
  const peerChoices = choicesOf(enumEntry);
@@ -1746,6 +1747,6 @@ function renderEffectsPreview(effects, o) {
1746
1747
  return wrap;
1747
1748
  }
1748
1749
 
1749
- 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, 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 };
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 };
1750
1751
  //# sourceMappingURL=index.js.map
1751
1752
  //# sourceMappingURL=index.js.map