@octaviaflow/core 3.1.0-beta.105 → 3.1.0-beta.106
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
|
@@ -34682,13 +34682,19 @@ function ExpressionField({
|
|
|
34682
34682
|
const fieldId = id ?? generatedId;
|
|
34683
34683
|
const helperId = `${fieldId}-helper`;
|
|
34684
34684
|
const [editing, setEditing] = useState71(null);
|
|
34685
|
+
const resolveLabelRef = useRef50(resolveLabel);
|
|
34686
|
+
const resolveCallRef = useRef50(resolveCall);
|
|
34687
|
+
const pillEveryTokenRef = useRef50(pillEveryToken);
|
|
34688
|
+
resolveLabelRef.current = resolveLabel;
|
|
34689
|
+
resolveCallRef.current = resolveCall;
|
|
34690
|
+
pillEveryTokenRef.current = pillEveryToken;
|
|
34685
34691
|
const labelFor = useCallback50(
|
|
34686
|
-
(token) =>
|
|
34687
|
-
[
|
|
34692
|
+
(token) => resolveLabelRef.current?.(token) ?? shortReferenceLabel(token),
|
|
34693
|
+
[]
|
|
34688
34694
|
);
|
|
34689
34695
|
const callLabel = useCallback50(
|
|
34690
|
-
(name) =>
|
|
34691
|
-
[
|
|
34696
|
+
(name) => resolveCallRef.current?.(name)?.label ?? (name.startsWith("user.") ? name.slice(5) : name),
|
|
34697
|
+
[]
|
|
34692
34698
|
);
|
|
34693
34699
|
const chipText = useCallback50(
|
|
34694
34700
|
(name, args) => {
|
|
@@ -34734,7 +34740,7 @@ function ExpressionField({
|
|
|
34734
34740
|
if (!el) return;
|
|
34735
34741
|
el.innerHTML = "";
|
|
34736
34742
|
if (!raw) return;
|
|
34737
|
-
for (const segment of parseExpression(raw,
|
|
34743
|
+
for (const segment of parseExpression(raw, pillEveryTokenRef.current)) {
|
|
34738
34744
|
if (segment.kind === "text") {
|
|
34739
34745
|
el.appendChild(document.createTextNode(segment.raw));
|
|
34740
34746
|
continue;
|
|
@@ -34746,7 +34752,7 @@ function ExpressionField({
|
|
|
34746
34752
|
}
|
|
34747
34753
|
}
|
|
34748
34754
|
},
|
|
34749
|
-
[
|
|
34755
|
+
[makeToken]
|
|
34750
34756
|
);
|
|
34751
34757
|
useEffect56(() => {
|
|
34752
34758
|
if (fromSelf.current) {
|
|
@@ -34857,6 +34863,10 @@ function ExpressionField({
|
|
|
34857
34863
|
},
|
|
34858
34864
|
[editing, chipText, commit]
|
|
34859
34865
|
);
|
|
34866
|
+
const handleMouseDown = useCallback50((e) => {
|
|
34867
|
+
const token = e.target.closest(`.${PILL}, .${CHIP}`);
|
|
34868
|
+
if (token) e.preventDefault();
|
|
34869
|
+
}, []);
|
|
34860
34870
|
const handleClick = useCallback50(
|
|
34861
34871
|
(e) => {
|
|
34862
34872
|
const node = e.target;
|
|
@@ -34971,6 +34981,7 @@ function ExpressionField({
|
|
|
34971
34981
|
style: { minHeight: `${Math.max(1, rows) * 1.5 + 1}rem` },
|
|
34972
34982
|
onInput: commit,
|
|
34973
34983
|
onBlur: handleBlur,
|
|
34984
|
+
onMouseDown: handleMouseDown,
|
|
34974
34985
|
onClick: handleClick,
|
|
34975
34986
|
onKeyDown: handleKeyDown,
|
|
34976
34987
|
onCopy: handleCopy,
|
|
@@ -35027,6 +35038,13 @@ function CallEditor({
|
|
|
35027
35038
|
if (at) crumbs.push({ label: nameOf(at.name), path: path.slice(0, i) });
|
|
35028
35039
|
}
|
|
35029
35040
|
const setArg = (index, next) => setDraft((d) => replaceArgument(d, [...path, index], next));
|
|
35041
|
+
const removeArg = (index) => setDraft((d) => {
|
|
35042
|
+
const at = callAt(d, path);
|
|
35043
|
+
if (!at) return d;
|
|
35044
|
+
const next = at.args.filter((_, i) => i !== index);
|
|
35045
|
+
const rebuilt = path.length === 0 ? formatCall(at.name, next) : `${at.name}(${next.join(", ")})`;
|
|
35046
|
+
return path.length === 0 ? rebuilt : replaceArgument(d, path, rebuilt);
|
|
35047
|
+
});
|
|
35030
35048
|
const dropInto = (index) => (e) => {
|
|
35031
35049
|
const dropped = e.dataTransfer.getData("application/x-fx-insert");
|
|
35032
35050
|
if (!dropped) return;
|
|
@@ -35086,7 +35104,20 @@ function CallEditor({
|
|
|
35086
35104
|
return (
|
|
35087
35105
|
// eslint-disable-next-line react/no-array-index-key
|
|
35088
35106
|
/* @__PURE__ */ jsxs141("div", { className: "ods-expression-field__editor-row", children: [
|
|
35089
|
-
/* @__PURE__ */
|
|
35107
|
+
/* @__PURE__ */ jsxs141("span", { className: "ods-expression-field__editor-row-head", children: [
|
|
35108
|
+
/* @__PURE__ */ jsx147("span", { id: `arg-${index}-label`, children: rowLabel }),
|
|
35109
|
+
/* @__PURE__ */ jsx147(
|
|
35110
|
+
"button",
|
|
35111
|
+
{
|
|
35112
|
+
type: "button",
|
|
35113
|
+
className: "ods-expression-field__editor-remove",
|
|
35114
|
+
"aria-label": `Remove ${rowLabel}`,
|
|
35115
|
+
title: "Remove this argument",
|
|
35116
|
+
onClick: () => removeArg(index),
|
|
35117
|
+
children: "\u2715"
|
|
35118
|
+
}
|
|
35119
|
+
)
|
|
35120
|
+
] }),
|
|
35090
35121
|
nested ? /* @__PURE__ */ jsxs141(
|
|
35091
35122
|
"div",
|
|
35092
35123
|
{
|
|
@@ -35149,14 +35180,14 @@ function CallEditor({
|
|
|
35149
35180
|
"button",
|
|
35150
35181
|
{
|
|
35151
35182
|
type: "button",
|
|
35152
|
-
className: "ods-expression-field__editor-
|
|
35183
|
+
className: "ods-expression-field__editor-add",
|
|
35153
35184
|
onClick: () => setDraft((d) => {
|
|
35154
35185
|
const at = callAt(d, path);
|
|
35155
35186
|
if (!at) return d;
|
|
35156
35187
|
const next = [...at.args, '""'];
|
|
35157
35188
|
return path.length === 0 ? formatCall(at.name, next) : replaceArgument(d, path, `${at.name}(${next.join(", ")})`);
|
|
35158
35189
|
}),
|
|
35159
|
-
children: "+ argument"
|
|
35190
|
+
children: "+ Add argument"
|
|
35160
35191
|
}
|
|
35161
35192
|
)
|
|
35162
35193
|
] }),
|