@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/components/ExpressionField/ExpressionField.d.ts.map +1 -1
- package/dist/components/ExpressionField/parseExpression.d.ts +17 -1
- package/dist/components/ExpressionField/parseExpression.d.ts.map +1 -1
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionField.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionField/ExpressionField.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAML,KAAK,aAAa,EAIlB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpressionField.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionField/ExpressionField.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAML,KAAK,aAAa,EAIlB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAkBf,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAChC;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAC1D;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWzD;AAyBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAiBpE;AAsCD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAgB,EAChB,IAAQ,EACR,EAAE,EACF,SAAS,EACT,KAAK,EACL,YAAY,EACZ,WAAW,EACX,cAAsB,EACtB,YAAY,EAAE,SAAS,GACxB,EAAE,oBAAoB,2CA6ZtB;AA0RD,eAAe,eAAe,CAAC"}
|
|
@@ -22,7 +22,14 @@ export declare function parseCall(raw: string): {
|
|
|
22
22
|
name: string;
|
|
23
23
|
args: string[];
|
|
24
24
|
} | undefined;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Rebuild a call from its parts, in the wrapped form a field stores.
|
|
27
|
+
*
|
|
28
|
+
* Empty arguments are kept, not dropped: while the editor is open an argument
|
|
29
|
+
* whose text has just been deleted is still an argument, and removing it would
|
|
30
|
+
* take the row away from under the author's cursor. `normalizeCall` settles
|
|
31
|
+
* them when the edit finishes.
|
|
32
|
+
*/
|
|
26
33
|
export declare function formatCall(name: string, args: string[]): string;
|
|
27
34
|
/**
|
|
28
35
|
* Break a field's value into what the reader sees: plain text, references
|
|
@@ -41,6 +48,15 @@ export declare function callAt(raw: string, path: number[]): {
|
|
|
41
48
|
export declare function argumentAt(raw: string, path: number[]): string | undefined;
|
|
42
49
|
/** A nested call is written bare; only the outermost one wears braces. */
|
|
43
50
|
export declare function formatNestedCall(name: string, args: string[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* Settle a call that was being edited into something an engine can read.
|
|
53
|
+
*
|
|
54
|
+
* An argument left empty in the middle keeps its place as `""` — the arguments
|
|
55
|
+
* after it are positional, and quietly closing the gap would hand `zone` to
|
|
56
|
+
* the `value` parameter. Empty arguments at the END are simply dropped, since
|
|
57
|
+
* nothing depends on their position. Applies to nested calls too.
|
|
58
|
+
*/
|
|
59
|
+
export declare function normalizeCall(raw: string): string;
|
|
44
60
|
/**
|
|
45
61
|
* Replace the argument at `path`, rebuilding every call on the way back up.
|
|
46
62
|
* An empty path replaces the whole expression.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseExpression.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionField/parseExpression.ts"],"names":[],"mappings":"AASA,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,uDAAuD,CAAC;AAGrF,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA2ChE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE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AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASjD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAYjF;AAED,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAQtD"}
|
package/dist/index.cjs
CHANGED
|
@@ -16762,7 +16762,9 @@ function splitArguments(argsText) {
|
|
|
16762
16762
|
}
|
|
16763
16763
|
current += ch;
|
|
16764
16764
|
}
|
|
16765
|
-
|
|
16765
|
+
const tail = current.trim();
|
|
16766
|
+
if (tail) args.push(tail);
|
|
16767
|
+
else if (args.length) args.push("");
|
|
16766
16768
|
return args;
|
|
16767
16769
|
}
|
|
16768
16770
|
function parseCall(raw) {
|
|
@@ -16775,7 +16777,7 @@ function parseCall(raw) {
|
|
|
16775
16777
|
return { name: head[1], args: splitArguments(inner.slice(open + 1, close)) };
|
|
16776
16778
|
}
|
|
16777
16779
|
function formatCall(name, args) {
|
|
16778
|
-
return `{{${name}(${args.
|
|
16780
|
+
return `{{${name}(${args.join(", ")})}}`;
|
|
16779
16781
|
}
|
|
16780
16782
|
function parseExpression(value, pillEveryToken = false) {
|
|
16781
16783
|
const segments = [];
|
|
@@ -16817,7 +16819,15 @@ function callAt(raw, path) {
|
|
|
16817
16819
|
return current;
|
|
16818
16820
|
}
|
|
16819
16821
|
function formatNestedCall(name, args) {
|
|
16820
|
-
return `${name}(${args.
|
|
16822
|
+
return `${name}(${args.join(", ")})`;
|
|
16823
|
+
}
|
|
16824
|
+
function normalizeCall(raw) {
|
|
16825
|
+
const call = parseCall(raw);
|
|
16826
|
+
if (!call) return raw;
|
|
16827
|
+
const args = call.args.map((arg) => parseCall(arg) ? normalizeCall(arg) : arg);
|
|
16828
|
+
while (args.length > 0 && args[args.length - 1].trim() === "") args.pop();
|
|
16829
|
+
const held = args.map((arg) => arg.trim() === "" ? '""' : arg);
|
|
16830
|
+
return raw.trim().startsWith("{{") ? formatCall(call.name, held) : formatNestedCall(call.name, held);
|
|
16821
16831
|
}
|
|
16822
16832
|
function replaceArgument(raw, path, next) {
|
|
16823
16833
|
if (path.length === 0) return next;
|
|
@@ -17285,7 +17295,9 @@ function CallEditor({
|
|
|
17285
17295
|
const target = e.target;
|
|
17286
17296
|
if (panelRef.current?.contains(target)) return;
|
|
17287
17297
|
if (anchor.contains(target)) return;
|
|
17288
|
-
|
|
17298
|
+
const el = target instanceof Element ? target : target.parentElement;
|
|
17299
|
+
if (el?.closest('[draggable="true"]')) return;
|
|
17300
|
+
onApplyRef.current(normalizeCall(draftRef.current));
|
|
17289
17301
|
};
|
|
17290
17302
|
document.addEventListener("keydown", onKey);
|
|
17291
17303
|
document.addEventListener("mousedown", onPointerDown, true);
|
|
@@ -17482,7 +17494,7 @@ function CallEditor({
|
|
|
17482
17494
|
] }),
|
|
17483
17495
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "ods-expression-field__editor-foot", children: [
|
|
17484
17496
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }),
|
|
17485
|
-
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Button, { variant: "primary", size: "sm", onClick: () => onApply(draft), children: "Apply" })
|
|
17497
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Button, { variant: "primary", size: "sm", onClick: () => onApply(normalizeCall(draft)), children: "Apply" })
|
|
17486
17498
|
] })
|
|
17487
17499
|
]
|
|
17488
17500
|
}
|