@octaviaflow/core 3.1.0-beta.110 → 3.1.0-beta.111

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.js CHANGED
@@ -11637,7 +11637,9 @@ function splitArguments(argsText) {
11637
11637
  }
11638
11638
  current += ch;
11639
11639
  }
11640
- if (current.trim()) args.push(current.trim());
11640
+ const tail = current.trim();
11641
+ if (tail) args.push(tail);
11642
+ else if (args.length) args.push("");
11641
11643
  return args;
11642
11644
  }
11643
11645
  function parseCall(raw) {
@@ -11650,7 +11652,7 @@ function parseCall(raw) {
11650
11652
  return { name: head[1], args: splitArguments(inner.slice(open + 1, close)) };
11651
11653
  }
11652
11654
  function formatCall(name, args) {
11653
- return `{{${name}(${args.filter((a) => a.trim() !== "").join(", ")})}}`;
11655
+ return `{{${name}(${args.join(", ")})}}`;
11654
11656
  }
11655
11657
  function parseExpression(value, pillEveryToken = false) {
11656
11658
  const segments = [];
@@ -11692,7 +11694,15 @@ function callAt(raw, path) {
11692
11694
  return current;
11693
11695
  }
11694
11696
  function formatNestedCall(name, args) {
11695
- return `${name}(${args.filter((a) => a.trim() !== "").join(", ")})`;
11697
+ return `${name}(${args.join(", ")})`;
11698
+ }
11699
+ function normalizeCall(raw) {
11700
+ const call = parseCall(raw);
11701
+ if (!call) return raw;
11702
+ const args = call.args.map((arg) => parseCall(arg) ? normalizeCall(arg) : arg);
11703
+ while (args.length > 0 && args[args.length - 1].trim() === "") args.pop();
11704
+ const held = args.map((arg) => arg.trim() === "" ? '""' : arg);
11705
+ return raw.trim().startsWith("{{") ? formatCall(call.name, held) : formatNestedCall(call.name, held);
11696
11706
  }
11697
11707
  function replaceArgument(raw, path, next) {
11698
11708
  if (path.length === 0) return next;
@@ -12160,7 +12170,9 @@ function CallEditor({
12160
12170
  const target = e.target;
12161
12171
  if (panelRef.current?.contains(target)) return;
12162
12172
  if (anchor.contains(target)) return;
12163
- onApplyRef.current(draftRef.current);
12173
+ const el = target instanceof Element ? target : target.parentElement;
12174
+ if (el?.closest('[draggable="true"]')) return;
12175
+ onApplyRef.current(normalizeCall(draftRef.current));
12164
12176
  };
12165
12177
  document.addEventListener("keydown", onKey);
12166
12178
  document.addEventListener("mousedown", onPointerDown, true);
@@ -12357,7 +12369,7 @@ function CallEditor({
12357
12369
  ] }),
12358
12370
  /* @__PURE__ */ jsxs49("div", { className: "ods-expression-field__editor-foot", children: [
12359
12371
  /* @__PURE__ */ jsx49(Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }),
12360
- /* @__PURE__ */ jsx49(Button, { variant: "primary", size: "sm", onClick: () => onApply(draft), children: "Apply" })
12372
+ /* @__PURE__ */ jsx49(Button, { variant: "primary", size: "sm", onClick: () => onApply(normalizeCall(draft)), children: "Apply" })
12361
12373
  ] })
12362
12374
  ]
12363
12375
  }