@wildwinter/expr-editor 0.12.0 → 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 +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -5
- package/dist/index.d.ts +33 -5
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
|
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.
|
|
@@ -407,6 +418,23 @@ declare function updateAt(list: EditorEffect[], i: number, patch: Partial<Editor
|
|
|
407
418
|
declare function setArgAt(list: EditorEffect[], i: number, argIdx: number, value: string): EditorEffect[];
|
|
408
419
|
declare function addArg(list: EditorEffect[], i: number, value?: string): EditorEffect[];
|
|
409
420
|
declare function removeArgAt(list: EditorEffect[], i: number, argIdx: number): EditorEffect[];
|
|
421
|
+
/**
|
|
422
|
+
* What a freshly targeted property's value should be, and whether the guided value wizard still has a
|
|
423
|
+
* question worth asking.
|
|
424
|
+
*
|
|
425
|
+
* BOTH paths that target a property go through this - "+ set property" (add) and re-picking an
|
|
426
|
+
* existing effect's target - because when they answered separately they drifted: 0.11.0 seeded a
|
|
427
|
+
* quality with `advance(...)` on re-pick while the add path opened a wizard that did not know what a
|
|
428
|
+
* quality was, so the same job offered two different affordances depending on how you arrived.
|
|
429
|
+
*
|
|
430
|
+
* `ask: false` means the type has a canonical outcome and the wizard would be ceremony: a QUALITY
|
|
431
|
+
* moves to its next stage, which is the insertion-safe form the type exists for, and an author who
|
|
432
|
+
* meant a specific stage clicks the pill.
|
|
433
|
+
*/
|
|
434
|
+
declare function initialValueFor(entry: CatalogueEntry, defaultScope: string): {
|
|
435
|
+
src: string;
|
|
436
|
+
ask: boolean;
|
|
437
|
+
};
|
|
410
438
|
/** A sensible starting value-expression for a freshly targeted property. Literals
|
|
411
439
|
* are seeded so the value editor opens on an editable pill, never the empty state.
|
|
412
440
|
*
|
|
@@ -464,4 +492,4 @@ interface ValueWizardOptions {
|
|
|
464
492
|
/** Build the wizard UI into a fresh element (drive it via the host's popover). */
|
|
465
493
|
declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
|
|
466
494
|
|
|
467
|
-
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, 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
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
|
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.
|
|
@@ -407,6 +418,23 @@ declare function updateAt(list: EditorEffect[], i: number, patch: Partial<Editor
|
|
|
407
418
|
declare function setArgAt(list: EditorEffect[], i: number, argIdx: number, value: string): EditorEffect[];
|
|
408
419
|
declare function addArg(list: EditorEffect[], i: number, value?: string): EditorEffect[];
|
|
409
420
|
declare function removeArgAt(list: EditorEffect[], i: number, argIdx: number): EditorEffect[];
|
|
421
|
+
/**
|
|
422
|
+
* What a freshly targeted property's value should be, and whether the guided value wizard still has a
|
|
423
|
+
* question worth asking.
|
|
424
|
+
*
|
|
425
|
+
* BOTH paths that target a property go through this - "+ set property" (add) and re-picking an
|
|
426
|
+
* existing effect's target - because when they answered separately they drifted: 0.11.0 seeded a
|
|
427
|
+
* quality with `advance(...)` on re-pick while the add path opened a wizard that did not know what a
|
|
428
|
+
* quality was, so the same job offered two different affordances depending on how you arrived.
|
|
429
|
+
*
|
|
430
|
+
* `ask: false` means the type has a canonical outcome and the wizard would be ceremony: a QUALITY
|
|
431
|
+
* moves to its next stage, which is the insertion-safe form the type exists for, and an author who
|
|
432
|
+
* meant a specific stage clicks the pill.
|
|
433
|
+
*/
|
|
434
|
+
declare function initialValueFor(entry: CatalogueEntry, defaultScope: string): {
|
|
435
|
+
src: string;
|
|
436
|
+
ask: boolean;
|
|
437
|
+
};
|
|
410
438
|
/** A sensible starting value-expression for a freshly targeted property. Literals
|
|
411
439
|
* are seeded so the value editor opens on an editable pill, never the empty state.
|
|
412
440
|
*
|
|
@@ -464,4 +492,4 @@ interface ValueWizardOptions {
|
|
|
464
492
|
/** Build the wizard UI into a fresh element (drive it via the host's popover). */
|
|
465
493
|
declare function valueWizard(opts: ValueWizardOptions): HTMLElement;
|
|
466
494
|
|
|
467
|
-
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, 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
|
|
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
|
|
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 =
|
|
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, 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
|