@wildwinter/expr-editor 0.9.0 → 0.10.1

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
@@ -246,6 +246,11 @@ interface EditCtx {
246
246
  label: string;
247
247
  run: () => void;
248
248
  }>;
249
+ /** Read-only presentation hint: render more compactly than the editable tree.
250
+ * Set by the preview (never the interactive editor). Currently collapses a
251
+ * flag-delta call (e.g. `check_flags(@p, +a, -b)`) to `@p: +a -b`, dropping
252
+ * the function name and parentheses. */
253
+ compact?: boolean;
249
254
  }
250
255
 
251
256
  interface ExpressionEditorOptions {
package/dist/index.d.ts CHANGED
@@ -246,6 +246,11 @@ interface EditCtx {
246
246
  label: string;
247
247
  run: () => void;
248
248
  }>;
249
+ /** Read-only presentation hint: render more compactly than the editable tree.
250
+ * Set by the preview (never the interactive editor). Currently collapses a
251
+ * flag-delta call (e.g. `check_flags(@p, +a, -b)`) to `@p: +a -b`, dropping
252
+ * the function name and parentheses. */
253
+ compact?: boolean;
249
254
  }
250
255
 
251
256
  interface ExpressionEditorOptions {
package/dist/index.js CHANGED
@@ -441,6 +441,13 @@ function renderNode(node, path, ctx, parentOp, side) {
441
441
  case "flagdelta":
442
442
  return pill(node.sign === "+" ? "flagpos" : "flagneg", `${node.sign}${node.name || "flag"}`, (b) => flagEditor(ctx, path, node, b), { issue, path });
443
443
  case "call": {
444
+ if (ctx.compact && ctx.dialect.functions[node.name]?.flagDeltaArgs && node.args.length >= 2 && node.args[0].kind === "scopedvar" && node.args.slice(1).every((a) => a.kind === "flagdelta")) {
445
+ const row2 = el("span", "exed-call exed-call-flags");
446
+ row2.append(renderNode(node.args[0], [...path, "args", 0], ctx));
447
+ row2.append(el("span", "exed-flagsep", [":"]));
448
+ for (let i = 1; i < node.args.length; i++) row2.append(renderNode(node.args[i], [...path, "args", i], ctx));
449
+ return row2;
450
+ }
444
451
  const row = el("span", "exed-call");
445
452
  row.append(pill("func", node.name, (b) => callEditor(ctx, path, node, b), { issue }));
446
453
  row.append(el("span", "exed-paren", ["("]));
@@ -1654,6 +1661,7 @@ function frozenCtx(src, o) {
1654
1661
  catalogue: o.catalogue,
1655
1662
  scopeOrder: o.scopeOrder ?? [],
1656
1663
  functions: [],
1664
+ compact: true,
1657
1665
  byPath: v.byPath,
1658
1666
  getAst: () => v.ast,
1659
1667
  apply: () => {