@octaviaflow/core 3.1.0-beta.108 → 3.1.0-beta.109

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.
@@ -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;AAgBf,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;AAuBD,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,2CAuatB;AAmQD,eAAe,eAAe,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;AAiBf,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;AAoRD,eAAe,eAAe,CAAC"}
package/dist/index.cjs CHANGED
@@ -41357,6 +41357,7 @@ ToolCard.displayName = "ToolCard";
41357
41357
 
41358
41358
  // src/components/ExpressionField/ExpressionField.tsx
41359
41359
  var import_react188 = require("react");
41360
+ var import_react_dom23 = require("react-dom");
41360
41361
  var import_icons68 = require("@octaviaflow/icons");
41361
41362
 
41362
41363
  // src/components/ExpressionField/parseExpression.ts
@@ -41577,6 +41578,16 @@ function insideCallArguments(textBeforeCaret) {
41577
41578
  }
41578
41579
  return depth > 0;
41579
41580
  }
41581
+ function anchorRect(el) {
41582
+ const box = el.getBoundingClientRect();
41583
+ const width = Math.max(300, box.width);
41584
+ return {
41585
+ top: box.bottom + 4,
41586
+ // Keep it on screen when the chip sits near the right edge.
41587
+ left: Math.max(8, Math.min(box.left, window.innerWidth - width - 8)),
41588
+ width
41589
+ };
41590
+ }
41580
41591
  function argSummary(arg, nameOf, depth = 2) {
41581
41592
  const trimmed = arg.trim();
41582
41593
  const call = parseCall(trimmed);
@@ -41765,17 +41776,7 @@ function ExpressionField({
41765
41776
  const openEditor = (0, import_react188.useCallback)((chip) => {
41766
41777
  const raw = chip.getAttribute("data-value") ?? "";
41767
41778
  if (!parseCall(raw)) return;
41768
- const box = chip.getBoundingClientRect();
41769
- const host = fieldRef.current?.getBoundingClientRect();
41770
- setEditing({
41771
- el: chip,
41772
- raw,
41773
- rect: {
41774
- top: box.bottom - (host?.top ?? 0) + 4,
41775
- left: Math.max(0, box.left - (host?.left ?? 0)),
41776
- width: Math.max(300, box.width)
41777
- }
41778
- });
41779
+ setEditing({ el: chip, raw, rect: anchorRect(chip) });
41779
41780
  }, []);
41780
41781
  const applyEditor = (0, import_react188.useCallback)(
41781
41782
  (raw) => {
@@ -42001,158 +42002,173 @@ function CallEditor({
42001
42002
  setDraft((d) => replaceArgument(d, [...path, index], bare));
42002
42003
  if (kind === "function" || parseCall(bare)) setPath((pth) => [...pth, index]);
42003
42004
  };
42004
- return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42005
- "div",
42006
- {
42007
- ref: panelRef,
42008
- className: "ods-expression-field__editor",
42009
- style: { top: rect.top, left: rect.left, width: rect.width },
42010
- role: "dialog",
42011
- "aria-label": `Edit ${crumbs[0]?.label ?? "function"}`,
42012
- children: [
42013
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-head", children: [
42014
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42015
- Breadcrumb,
42005
+ const [pos, setPos] = (0, import_react188.useState)(rect);
42006
+ (0, import_react188.useEffect)(() => {
42007
+ const follow = () => setPos(anchorRect(anchor));
42008
+ window.addEventListener("scroll", follow, true);
42009
+ window.addEventListener("resize", follow);
42010
+ return () => {
42011
+ window.removeEventListener("scroll", follow, true);
42012
+ window.removeEventListener("resize", follow);
42013
+ };
42014
+ }, [anchor]);
42015
+ if (typeof document === "undefined") return null;
42016
+ return (0, import_react_dom23.createPortal)(
42017
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42018
+ "div",
42019
+ {
42020
+ ref: panelRef,
42021
+ "data-ods-floating": "",
42022
+ className: "ods-expression-field__editor",
42023
+ style: { top: pos.top, left: pos.left, width: pos.width },
42024
+ role: "dialog",
42025
+ "aria-label": `Edit ${crumbs[0]?.label ?? "function"}`,
42026
+ children: [
42027
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-head", children: [
42028
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42029
+ Breadcrumb,
42030
+ {
42031
+ className: "ods-expression-field__editor-crumbs",
42032
+ items: crumbs.map((crumb) => ({
42033
+ label: crumb.label,
42034
+ onClick: () => setPath(crumb.path)
42035
+ }))
42036
+ }
42037
+ ),
42038
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "ghost", size: "sm", onClick: () => setRawMode((r) => !r), children: rawMode ? "Back to fields" : "Edit as text" })
42039
+ ] }),
42040
+ rawMode ? /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42041
+ "textarea",
42016
42042
  {
42017
- className: "ods-expression-field__editor-crumbs",
42018
- items: crumbs.map((crumb) => ({
42019
- label: crumb.label,
42020
- onClick: () => setPath(crumb.path)
42021
- }))
42043
+ className: "ods-expression-field__editor-raw",
42044
+ value: draft,
42045
+ rows: 3,
42046
+ "aria-label": "Expression",
42047
+ onChange: (e) => setDraft(e.target.value)
42022
42048
  }
42023
- ),
42024
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "ghost", size: "sm", onClick: () => setRawMode((r) => !r), children: rawMode ? "Back to fields" : "Edit as text" })
42025
- ] }),
42026
- rawMode ? /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42027
- "textarea",
42028
- {
42029
- className: "ods-expression-field__editor-raw",
42030
- value: draft,
42031
- rows: 3,
42032
- "aria-label": "Expression",
42033
- onChange: (e) => setDraft(e.target.value)
42034
- }
42035
- ) : /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-rows", children: [
42036
- args.map((arg, index) => {
42037
- const kind = argumentKind(arg);
42038
- const rowLabel = names[index] ?? `argument ${index + 1}`;
42039
- const nested = kind === "call" ? parseCall(arg) : void 0;
42040
- return (
42041
- // eslint-disable-next-line react/no-array-index-key
42042
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-row", children: [
42043
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("span", { className: "ods-expression-field__editor-row-head", children: [
42044
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("span", { className: "ods-expression-field__editor-row-name", id: `arg-${index}-label`, children: rowLabel }),
42045
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42046
- Button,
42047
- {
42048
- variant: "icon",
42049
- size: "sm",
42050
- "aria-label": `Remove ${rowLabel}`,
42051
- title: "Remove this argument",
42052
- onClick: () => removeArg(index),
42053
- children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_icons68.CloseIcon, { size: "sm" })
42054
- }
42055
- )
42056
- ] }),
42057
- nested ? /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42058
- "div",
42059
- {
42060
- className: "ods-expression-field__editor-nested",
42061
- onDragOver: (e) => {
42062
- if (e.dataTransfer.types.includes("application/x-fx-insert")) e.preventDefault();
42063
- },
42064
- onDrop: dropInto(index),
42065
- children: [
42066
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("code", { children: argSummary(arg, nameOf) }),
42067
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("span", { children: [
42068
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "secondary", size: "sm", onClick: () => setPath([...path, index]), children: "Open" }),
42069
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42070
- Button,
42071
- {
42072
- variant: "ghost",
42073
- size: "sm",
42074
- "aria-label": `Clear ${rowLabel}`,
42075
- onClick: () => setArg(index, ""),
42076
- children: "Clear"
42077
- }
42078
- )
42079
- ] })
42080
- ]
42081
- }
42082
- ) : kind === "reference" ? (
42083
- // A reference is a value from somewhere else — named, never
42084
- // its raw `ods://…` path, here as much as in the field.
42085
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42049
+ ) : /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-rows", children: [
42050
+ args.map((arg, index) => {
42051
+ const kind = argumentKind(arg);
42052
+ const rowLabel = names[index] ?? `argument ${index + 1}`;
42053
+ const nested = kind === "call" ? parseCall(arg) : void 0;
42054
+ return (
42055
+ // eslint-disable-next-line react/no-array-index-key
42056
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-row", children: [
42057
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("span", { className: "ods-expression-field__editor-row-head", children: [
42058
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("span", { className: "ods-expression-field__editor-row-name", id: `arg-${index}-label`, children: rowLabel }),
42059
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42060
+ Button,
42061
+ {
42062
+ variant: "icon",
42063
+ size: "sm",
42064
+ "aria-label": `Remove ${rowLabel}`,
42065
+ title: "Remove this argument",
42066
+ onClick: () => removeArg(index),
42067
+ children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_icons68.CloseIcon, { size: "sm" })
42068
+ }
42069
+ )
42070
+ ] }),
42071
+ nested ? /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42086
42072
  "div",
42087
42073
  {
42088
- className: "ods-expression-field__editor-ref",
42074
+ className: "ods-expression-field__editor-nested",
42089
42075
  onDragOver: (e) => {
42090
42076
  if (e.dataTransfer.types.includes("application/x-fx-insert")) e.preventDefault();
42091
42077
  },
42092
42078
  onDrop: dropInto(index),
42093
42079
  children: [
42094
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42095
- "span",
42096
- {
42097
- className: "ods-expression-field__pill",
42098
- title: arg,
42099
- "aria-labelledby": `arg-${index}-label`,
42100
- children: labelFor(arg.startsWith("ods://") ? `{{${arg}}}` : arg)
42101
- }
42102
- ),
42103
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42104
- Button,
42105
- {
42106
- variant: "ghost",
42107
- size: "sm",
42108
- "aria-label": `Clear ${rowLabel}`,
42109
- onClick: () => setArg(index, ""),
42110
- children: "Clear"
42111
- }
42112
- )
42080
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("code", { children: argSummary(arg, nameOf) }),
42081
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("span", { children: [
42082
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "secondary", size: "sm", onClick: () => setPath([...path, index]), children: "Open" }),
42083
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42084
+ Button,
42085
+ {
42086
+ variant: "ghost",
42087
+ size: "sm",
42088
+ "aria-label": `Clear ${rowLabel}`,
42089
+ onClick: () => setArg(index, ""),
42090
+ children: "Clear"
42091
+ }
42092
+ )
42093
+ ] })
42113
42094
  ]
42114
42095
  }
42096
+ ) : kind === "reference" ? (
42097
+ // A reference is a value from somewhere else — named, never
42098
+ // its raw `ods://…` path, here as much as in the field.
42099
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(
42100
+ "div",
42101
+ {
42102
+ className: "ods-expression-field__editor-ref",
42103
+ onDragOver: (e) => {
42104
+ if (e.dataTransfer.types.includes("application/x-fx-insert")) e.preventDefault();
42105
+ },
42106
+ onDrop: dropInto(index),
42107
+ children: [
42108
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42109
+ "span",
42110
+ {
42111
+ className: "ods-expression-field__pill",
42112
+ title: arg,
42113
+ "aria-labelledby": `arg-${index}-label`,
42114
+ children: labelFor(arg.startsWith("ods://") ? `{{${arg}}}` : arg)
42115
+ }
42116
+ ),
42117
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42118
+ Button,
42119
+ {
42120
+ variant: "ghost",
42121
+ size: "sm",
42122
+ "aria-label": `Clear ${rowLabel}`,
42123
+ onClick: () => setArg(index, ""),
42124
+ children: "Clear"
42125
+ }
42126
+ )
42127
+ ]
42128
+ }
42129
+ )
42130
+ ) : /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42131
+ "input",
42132
+ {
42133
+ "aria-labelledby": `arg-${index}-label`,
42134
+ value: arg,
42135
+ placeholder: 'a value, "text", or drag one in',
42136
+ "data-kind": kind,
42137
+ onChange: (e) => setArg(index, e.target.value),
42138
+ onDragOver: (e) => {
42139
+ if (e.dataTransfer.types.includes("application/x-fx-insert")) e.preventDefault();
42140
+ },
42141
+ onDrop: dropInto(index)
42142
+ }
42115
42143
  )
42116
- ) : /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42117
- "input",
42118
- {
42119
- "aria-labelledby": `arg-${index}-label`,
42120
- value: arg,
42121
- placeholder: 'a value, "text", or drag one in',
42122
- "data-kind": kind,
42123
- onChange: (e) => setArg(index, e.target.value),
42124
- onDragOver: (e) => {
42125
- if (e.dataTransfer.types.includes("application/x-fx-insert")) e.preventDefault();
42126
- },
42127
- onDrop: dropInto(index)
42128
- }
42129
- )
42130
- ] }, index)
42131
- );
42132
- }),
42133
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42134
- Button,
42135
- {
42136
- variant: "ghost",
42137
- size: "sm",
42138
- fullWidth: true,
42139
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_icons68.AddIcon, { size: "sm" }),
42140
- onClick: () => setDraft((d) => {
42141
- const at = callAt(d, path);
42142
- if (!at) return d;
42143
- const next = [...at.args, '""'];
42144
- return path.length === 0 ? formatCall(at.name, next) : replaceArgument(d, path, `${at.name}(${next.join(", ")})`);
42145
- }),
42146
- children: "Add argument"
42147
- }
42148
- )
42149
- ] }),
42150
- /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-foot", children: [
42151
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }),
42152
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "primary", size: "sm", onClick: () => onApply(draft), children: "Apply" })
42153
- ] })
42154
- ]
42155
- }
42144
+ ] }, index)
42145
+ );
42146
+ }),
42147
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
42148
+ Button,
42149
+ {
42150
+ variant: "ghost",
42151
+ size: "sm",
42152
+ fullWidth: true,
42153
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_icons68.AddIcon, { size: "sm" }),
42154
+ onClick: () => setDraft((d) => {
42155
+ const at = callAt(d, path);
42156
+ if (!at) return d;
42157
+ const next = [...at.args, '""'];
42158
+ return path.length === 0 ? formatCall(at.name, next) : replaceArgument(d, path, `${at.name}(${next.join(", ")})`);
42159
+ }),
42160
+ children: "Add argument"
42161
+ }
42162
+ )
42163
+ ] }),
42164
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "ods-expression-field__editor-foot", children: [
42165
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }),
42166
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Button, { variant: "primary", size: "sm", onClick: () => onApply(draft), children: "Apply" })
42167
+ ] })
42168
+ ]
42169
+ }
42170
+ ),
42171
+ document.body
42156
42172
  );
42157
42173
  }
42158
42174