@octaviaflow/core 3.0.18-beta.32 → 3.0.18-beta.34

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
@@ -2,11 +2,13 @@ import {
2
2
  FlowCanvas,
3
3
  FlowInstanceContext,
4
4
  FlowStoreContext,
5
+ HandleRegistryContext,
5
6
  applyEdgeChanges,
6
7
  applyNodeChanges,
7
8
  buildEdgePath,
9
+ handleCentre,
8
10
  useViewportOrNull
9
- } from "./chunk-XSRJM2TR.js";
11
+ } from "./chunk-KOE4VS4I.js";
10
12
  import {
11
13
  __export,
12
14
  cn
@@ -4858,6 +4860,20 @@ var Select = forwardRef14(function Select2({
4858
4860
  };
4859
4861
  }, [state.isOpen, state.close, closeOnOutsideClick]);
4860
4862
  const selectedOption = options.find((o) => o.value === String(state.selectedKey ?? ""));
4863
+ const wasOpenBeforePressRef = useRef8(false);
4864
+ const handleTriggerPointerDown = (e) => {
4865
+ wasOpenBeforePressRef.current = state.isOpen;
4866
+ const baseHandler = buttonProps.onPointerDown;
4867
+ baseHandler?.(e);
4868
+ };
4869
+ const handleTriggerClick = (e) => {
4870
+ const baseHandler = buttonProps.onClick;
4871
+ baseHandler?.(e);
4872
+ if (wasOpenBeforePressRef.current && state.isOpen) {
4873
+ state.close();
4874
+ }
4875
+ wasOpenBeforePressRef.current = false;
4876
+ };
4861
4877
  return /* @__PURE__ */ jsxs15(
4862
4878
  "div",
4863
4879
  {
@@ -4875,6 +4891,8 @@ var Select = forwardRef14(function Select2({
4875
4891
  "button",
4876
4892
  {
4877
4893
  ...buttonProps,
4894
+ onPointerDown: handleTriggerPointerDown,
4895
+ onClick: handleTriggerClick,
4878
4896
  ref: setTriggerRef,
4879
4897
  id: baseId,
4880
4898
  form,
@@ -12644,6 +12662,7 @@ function ExecutionConsole({
12644
12662
  }) {
12645
12663
  const logEndRef = useRef23(null);
12646
12664
  const logsRef = useRef23(null);
12665
+ const lastScrollTopRef = useRef23(0);
12647
12666
  const [query, setQuery] = useState22("");
12648
12667
  const [activeLevels, setActiveLevels] = useState22(() => new Set(ALL_LEVELS));
12649
12668
  const [activeNode, setActiveNode] = useState22("all");
@@ -12681,9 +12700,13 @@ function ExecutionConsole({
12681
12700
  const handleLogsScroll = () => {
12682
12701
  const el = logsRef.current;
12683
12702
  if (!el) return;
12684
- const distance = el.scrollHeight - el.scrollTop - el.clientHeight;
12685
- if (distance > 60 && autoScroll) setAutoScroll(false);
12703
+ const prev = lastScrollTopRef.current;
12704
+ const curr = el.scrollTop;
12705
+ const distance = el.scrollHeight - curr - el.clientHeight;
12706
+ const userScrolledUp = curr < prev - 1;
12707
+ if (userScrolledUp && distance > 60 && autoScroll) setAutoScroll(false);
12686
12708
  if (distance <= 8 && !autoScroll) setAutoScroll(true);
12709
+ lastScrollTopRef.current = curr;
12687
12710
  };
12688
12711
  const toggleLevel = (level) => {
12689
12712
  setActiveLevels((prev) => {
@@ -14323,11 +14346,17 @@ function FlowMinimap(props) {
14323
14346
  } = props;
14324
14347
  const store = useContext(FlowStoreContext);
14325
14348
  const instance = useContext(FlowInstanceContext);
14349
+ const handleRegistry = useContext(HandleRegistryContext);
14326
14350
  const { sub, snap } = useMemo16(
14327
14351
  () => store ? { sub: store.subscribe, snap: () => store.getSnapshot() } : { sub: NO_STORE_SUBSCRIBE, snap: NO_STORE_SNAPSHOT },
14328
14352
  [store]
14329
14353
  );
14330
14354
  const liveSnapshot = useSyncExternalStore(sub, snap, snap);
14355
+ const [registryVersion, setRegistryVersion] = useState26(0);
14356
+ useEffect22(() => {
14357
+ if (!handleRegistry) return;
14358
+ return handleRegistry.subscribe(() => setRegistryVersion((v) => v + 1));
14359
+ }, [handleRegistry]);
14331
14360
  const resolvedNodes = useMemo16(() => {
14332
14361
  if (nodesProp) return nodesProp;
14333
14362
  if (!liveSnapshot) return [];
@@ -14342,19 +14371,41 @@ function FlowMinimap(props) {
14342
14371
  const resolvedEdges = useMemo16(() => {
14343
14372
  if (edgesProp) return edgesProp;
14344
14373
  if (!liveSnapshot) return [];
14345
- const nodeIndex = new Map(resolvedNodes.map((n) => [n.id, n]));
14374
+ const nodeIndex = new Map(
14375
+ liveSnapshot.nodes.filter((n) => !n.hidden).map((n) => [n.id, n])
14376
+ );
14377
+ const centreOf = (n) => {
14378
+ const w = n.width ?? DEFAULT_NODE_WIDTH2;
14379
+ const h = n.height ?? DEFAULT_NODE_HEIGHT2;
14380
+ return { x: n.position.x + w / 2, y: n.position.y + h / 2 };
14381
+ };
14346
14382
  return liveSnapshot.edges.flatMap((e) => {
14383
+ if (e.hidden) return [];
14347
14384
  const s = nodeIndex.get(e.source);
14348
14385
  const t = nodeIndex.get(e.target);
14349
14386
  if (!s || !t) return [];
14350
- return [
14351
- {
14352
- from: { x: s.x + s.width / 2, y: s.y + s.height / 2 },
14353
- to: { x: t.x + t.width / 2, y: t.y + t.height / 2 }
14354
- }
14355
- ];
14387
+ const srcDesc = handleRegistry?.resolve(
14388
+ s.id,
14389
+ "source",
14390
+ e.sourceHandle ?? "default"
14391
+ );
14392
+ const tgtDesc = handleRegistry?.resolve(
14393
+ t.id,
14394
+ "target",
14395
+ e.targetHandle ?? "default"
14396
+ );
14397
+ const from = srcDesc ? handleCentre(s, srcDesc.side, srcDesc.index, srcDesc.total) : (
14398
+ // Fallback: source defaults to bottom centre (matches the
14399
+ // canvas's source default before any Handle registers).
14400
+ s.sourcePosition ? handleCentre(s, s.sourcePosition, 0, 1) : centreOf(s)
14401
+ );
14402
+ const to = tgtDesc ? handleCentre(t, tgtDesc.side, tgtDesc.index, tgtDesc.total) : (
14403
+ // Fallback: target defaults to top centre.
14404
+ t.targetPosition ? handleCentre(t, t.targetPosition, 0, 1) : centreOf(t)
14405
+ );
14406
+ return [{ from, to }];
14356
14407
  });
14357
- }, [edgesProp, liveSnapshot, resolvedNodes]);
14408
+ }, [edgesProp, liveSnapshot, handleRegistry, registryVersion]);
14358
14409
  const minimapRef = useRef27(null);
14359
14410
  const [canvasSize, setCanvasSize] = useState26(null);
14360
14411
  useEffect22(() => {
@@ -18325,7 +18376,10 @@ var MultiSelect = forwardRef60(
18325
18376
  "aria-label": labelId ? void 0 : ariaLabel ?? placeholder,
18326
18377
  "aria-disabled": disabled,
18327
18378
  tabIndex: disabled ? -1 : 0,
18328
- onClick: () => !disabled && setOpen(true),
18379
+ onClick: () => {
18380
+ if (disabled) return;
18381
+ setOpen((prev) => !prev);
18382
+ },
18329
18383
  onKeyDown: (e) => {
18330
18384
  if (disabled) return;
18331
18385
  if (!open && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {