@particle-academy/fancy-flow 0.20.0 → 0.21.0

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,5 +1,5 @@
1
- import { a as NodeKindDefinition, P as PortSpec } from '../types-D_jOR3Z2.cjs';
2
- export { C as ConfigField, b as CredentialConfigField, D as DocumentConfigField, E as ExpressionConfigField, J as JsonConfigField, K as KeyValueConfigField, N as NodeCategory, c as NumberConfigField, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField, S as SelectConfigField, f as SwitchConfigField, T as TextConfigField, g as TextareaConfigField } from '../types-D_jOR3Z2.cjs';
1
+ import { a as NodeKindDefinition, P as PortSpec } from '../types-LG-YckGh.cjs';
2
+ export { C as ConfigField, b as CredentialConfigField, D as DocumentConfigField, E as ExpressionConfigField, J as JsonConfigField, K as KeyValueConfigField, N as NodeCategory, c as NumberConfigField, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField, S as SelectConfigField, f as SwitchConfigField, T as TextConfigField, g as TextareaConfigField } from '../types-LG-YckGh.cjs';
3
3
  import { P as PortDescriptor, b as FlowNode, N as NodeExecutor } from '../types-sOmpCitB.cjs';
4
4
  import { Connection, Edge, NodeProps, NodeTypes } from '@xyflow/react';
5
5
  import { b as LlmRoute } from '../capabilities-ChE3Xi8R.cjs';
@@ -1,5 +1,5 @@
1
- import { a as NodeKindDefinition, P as PortSpec } from '../types-NerkPtHS.js';
2
- export { C as ConfigField, b as CredentialConfigField, D as DocumentConfigField, E as ExpressionConfigField, J as JsonConfigField, K as KeyValueConfigField, N as NodeCategory, c as NumberConfigField, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField, S as SelectConfigField, f as SwitchConfigField, T as TextConfigField, g as TextareaConfigField } from '../types-NerkPtHS.js';
1
+ import { a as NodeKindDefinition, P as PortSpec } from '../types-VGkCXEO6.js';
2
+ export { C as ConfigField, b as CredentialConfigField, D as DocumentConfigField, E as ExpressionConfigField, J as JsonConfigField, K as KeyValueConfigField, N as NodeCategory, c as NumberConfigField, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField, S as SelectConfigField, f as SwitchConfigField, T as TextConfigField, g as TextareaConfigField } from '../types-VGkCXEO6.js';
3
3
  import { P as PortDescriptor, b as FlowNode, N as NodeExecutor } from '../types-sOmpCitB.js';
4
4
  import { Connection, Edge, NodeProps, NodeTypes } from '@xyflow/react';
5
5
  import { b as LlmRoute } from '../capabilities-DUhAc-EJ.js';
package/dist/registry.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var ReactExports = require('react');
5
- require('react-dom');
5
+ var reactDom = require('react-dom');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
@@ -733,9 +733,9 @@ function creator_default(name) {
733
733
  // node_modules/d3-selection/src/selector.js
734
734
  function none() {
735
735
  }
736
- function selector_default(selector) {
737
- return selector == null ? none : function() {
738
- return this.querySelector(selector);
736
+ function selector_default(selector2) {
737
+ return selector2 == null ? none : function() {
738
+ return this.querySelector(selector2);
739
739
  };
740
740
  }
741
741
 
@@ -762,9 +762,9 @@ function array(x) {
762
762
  function empty() {
763
763
  return [];
764
764
  }
765
- function selectorAll_default(selector) {
766
- return selector == null ? empty : function() {
767
- return this.querySelectorAll(selector);
765
+ function selectorAll_default(selector2) {
766
+ return selector2 == null ? empty : function() {
767
+ return this.querySelectorAll(selector2);
768
768
  };
769
769
  }
770
770
 
@@ -789,14 +789,14 @@ function selectAll_default(select) {
789
789
  }
790
790
 
791
791
  // node_modules/d3-selection/src/matcher.js
792
- function matcher_default(selector) {
792
+ function matcher_default(selector2) {
793
793
  return function() {
794
- return this.matches(selector);
794
+ return this.matches(selector2);
795
795
  };
796
796
  }
797
- function childMatcher(selector) {
797
+ function childMatcher(selector2) {
798
798
  return function(node) {
799
- return node.matches(selector);
799
+ return node.matches(selector2);
800
800
  };
801
801
  }
802
802
 
@@ -865,11 +865,11 @@ EnterNode.prototype = {
865
865
  insertBefore: function(child, next) {
866
866
  return this._parent.insertBefore(child, next);
867
867
  },
868
- querySelector: function(selector) {
869
- return this._parent.querySelector(selector);
868
+ querySelector: function(selector2) {
869
+ return this._parent.querySelector(selector2);
870
870
  },
871
- querySelectorAll: function(selector) {
872
- return this._parent.querySelectorAll(selector);
871
+ querySelectorAll: function(selector2) {
872
+ return this._parent.querySelectorAll(selector2);
873
873
  }
874
874
  };
875
875
 
@@ -1480,8 +1480,8 @@ Selection.prototype = selection.prototype = {
1480
1480
  var selection_default = selection;
1481
1481
 
1482
1482
  // node_modules/d3-selection/src/select.js
1483
- function select_default2(selector) {
1484
- return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
1483
+ function select_default2(selector2) {
1484
+ return typeof selector2 === "string" ? new Selection([[document.querySelector(selector2)]], [document.documentElement]) : new Selection([[selector2]], root);
1485
1485
  }
1486
1486
 
1487
1487
  // node_modules/d3-selection/src/sourceEvent.js
@@ -4473,6 +4473,40 @@ function createMarkerIds(edges, { id: id2, defaultColor, defaultMarkerStart, def
4473
4473
  return markers;
4474
4474
  }, []).sort((a, b) => a.id.localeCompare(b.id));
4475
4475
  }
4476
+ function getNodeToolbarTransform(nodeRect, viewport, position, offset, align) {
4477
+ let alignmentOffset = 0.5;
4478
+ if (align === "start") {
4479
+ alignmentOffset = 0;
4480
+ } else if (align === "end") {
4481
+ alignmentOffset = 1;
4482
+ }
4483
+ let pos = [
4484
+ (nodeRect.x + nodeRect.width * alignmentOffset) * viewport.zoom + viewport.x,
4485
+ nodeRect.y * viewport.zoom + viewport.y - offset
4486
+ ];
4487
+ let shift = [-100 * alignmentOffset, -100];
4488
+ switch (position) {
4489
+ case Position.Right:
4490
+ pos = [
4491
+ (nodeRect.x + nodeRect.width) * viewport.zoom + viewport.x + offset,
4492
+ (nodeRect.y + nodeRect.height * alignmentOffset) * viewport.zoom + viewport.y
4493
+ ];
4494
+ shift = [0, -100 * alignmentOffset];
4495
+ break;
4496
+ case Position.Bottom:
4497
+ pos[1] = (nodeRect.y + nodeRect.height) * viewport.zoom + viewport.y + offset;
4498
+ shift[1] = 0;
4499
+ break;
4500
+ case Position.Left:
4501
+ pos = [
4502
+ nodeRect.x * viewport.zoom + viewport.x - offset,
4503
+ (nodeRect.y + nodeRect.height * alignmentOffset) * viewport.zoom + viewport.y
4504
+ ];
4505
+ shift = [-100, -100 * alignmentOffset];
4506
+ break;
4507
+ }
4508
+ return `translate(${pos[0]}px, ${pos[1]}px) translate(${shift[0]}%, ${shift[1]}%)`;
4509
+ }
4476
4510
  var SELECTED_NODE_Z = 1e3;
4477
4511
  var ROOT_PARENT_Z_INCREMENT = 10;
4478
4512
  var defaultOptions = {
@@ -4840,10 +4874,10 @@ function isParentSelected(node, nodeLookup) {
4840
4874
  }
4841
4875
  return isParentSelected(parentNode, nodeLookup);
4842
4876
  }
4843
- function hasSelector(target, selector, domNode) {
4877
+ function hasSelector(target, selector2, domNode) {
4844
4878
  let current = target;
4845
4879
  do {
4846
- if (current?.matches?.(selector))
4880
+ if (current?.matches?.(selector2))
4847
4881
  return true;
4848
4882
  if (current === domNode)
4849
4883
  return false;
@@ -5801,6 +5835,8 @@ var ResizeControlVariant;
5801
5835
  ResizeControlVariant2["Line"] = "line";
5802
5836
  ResizeControlVariant2["Handle"] = "handle";
5803
5837
  })(ResizeControlVariant || (ResizeControlVariant = {}));
5838
+ var XY_RESIZER_HANDLE_POSITIONS = ["top-left", "top-right", "bottom-left", "bottom-right"];
5839
+ var XY_RESIZER_LINE_POSITIONS = ["top", "right", "bottom", "left"];
5804
5840
  function getResizeDirection({ width, prevWidth, height, prevHeight, affectsX, affectsY }) {
5805
5841
  const deltaWidth = width - prevWidth;
5806
5842
  const deltaHeight = height - prevHeight;
@@ -6157,7 +6193,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
6157
6193
  destroy
6158
6194
  };
6159
6195
  }
6160
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
6196
+ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector2, isEqual) {
6161
6197
  const instRef = ReactExports.useRef(null);
6162
6198
  let inst;
6163
6199
  if (instRef.current === null) {
@@ -6174,7 +6210,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
6174
6210
  if (!hasMemo) {
6175
6211
  hasMemo = true;
6176
6212
  memoizedSnapshot = nextSnapshot;
6177
- const nextSelection2 = selector(nextSnapshot);
6213
+ const nextSelection2 = selector2(nextSnapshot);
6178
6214
  if (isEqual !== void 0 && inst.hasValue) {
6179
6215
  const currentSelection = inst.value;
6180
6216
  if (isEqual(currentSelection, nextSelection2)) {
@@ -6190,7 +6226,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
6190
6226
  if (Object.is(prevSnapshot, nextSnapshot)) {
6191
6227
  return prevSelection;
6192
6228
  }
6193
- const nextSelection = selector(nextSnapshot);
6229
+ const nextSelection = selector2(nextSnapshot);
6194
6230
  if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
6195
6231
  memoizedSnapshot = nextSnapshot;
6196
6232
  return prevSelection;
@@ -6203,7 +6239,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
6203
6239
  const getSnapshotWithSelector = () => memoizedSelector(getSnapshot());
6204
6240
  const getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : () => memoizedSelector(maybeGetServerSnapshot());
6205
6241
  return [getSnapshotWithSelector, getServerSnapshotWithSelector];
6206
- }, [getSnapshot, getServerSnapshot, selector, isEqual]);
6242
+ }, [getSnapshot, getServerSnapshot, selector2, isEqual]);
6207
6243
  const value = ReactExports.useSyncExternalStore(subscribe, getSelection, getServerSelection);
6208
6244
  ReactExports.useEffect(() => {
6209
6245
  inst.hasValue = true;
@@ -6250,12 +6286,12 @@ var createStore = (createState) => createState ? createStoreImpl(createState) :
6250
6286
  var { useDebugValue: useDebugValue2 } = ReactExports__default.default;
6251
6287
  var { useSyncExternalStoreWithSelector: useSyncExternalStoreWithSelector2 } = use_sync_external_store_with_selector_default;
6252
6288
  var identity3 = (arg) => arg;
6253
- function useStoreWithEqualityFn(api, selector = identity3, equalityFn) {
6289
+ function useStoreWithEqualityFn(api, selector2 = identity3, equalityFn) {
6254
6290
  const slice = useSyncExternalStoreWithSelector2(
6255
6291
  api.subscribe,
6256
6292
  api.getState,
6257
6293
  api.getServerState || api.getInitialState,
6258
- selector,
6294
+ selector2,
6259
6295
  equalityFn
6260
6296
  );
6261
6297
  useDebugValue2(slice);
@@ -6263,7 +6299,7 @@ function useStoreWithEqualityFn(api, selector = identity3, equalityFn) {
6263
6299
  }
6264
6300
  var createWithEqualityFnImpl = (createState, defaultEqualityFn) => {
6265
6301
  const api = createStore(createState);
6266
- const useBoundStoreWithEqualityFn = (selector, equalityFn = defaultEqualityFn) => useStoreWithEqualityFn(api, selector, equalityFn);
6302
+ const useBoundStoreWithEqualityFn = (selector2, equalityFn = defaultEqualityFn) => useStoreWithEqualityFn(api, selector2, equalityFn);
6267
6303
  Object.assign(useBoundStoreWithEqualityFn, api);
6268
6304
  return useBoundStoreWithEqualityFn;
6269
6305
  };
@@ -6309,12 +6345,12 @@ function shallow$1(objA, objB) {
6309
6345
  var StoreContext = ReactExports.createContext(null);
6310
6346
  var Provider$1 = StoreContext.Provider;
6311
6347
  var zustandErrorMessage = errorMessages["error001"]("react");
6312
- function useStore(selector, equalityFn) {
6348
+ function useStore(selector2, equalityFn) {
6313
6349
  const store = ReactExports.useContext(StoreContext);
6314
6350
  if (store === null) {
6315
6351
  throw new Error(zustandErrorMessage);
6316
6352
  }
6317
- return useStoreWithEqualityFn(store, selector, equalityFn);
6353
+ return useStoreWithEqualityFn(store, selector2, equalityFn);
6318
6354
  }
6319
6355
  function useStoreApi() {
6320
6356
  const store = ReactExports.useContext(StoreContext);
@@ -9506,7 +9542,69 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
9506
9542
  ...color2 && { [isHandleControl ? "backgroundColor" : "borderColor"]: color2 }
9507
9543
  }, children: children2 });
9508
9544
  }
9509
- ReactExports.memo(ResizeControl);
9545
+ var NodeResizeControl = ReactExports.memo(ResizeControl);
9546
+ function NodeResizer({ nodeId, isVisible = true, handleClassName, handleStyle, lineClassName, lineStyle, color: color2, minWidth = 10, minHeight = 10, maxWidth = Number.MAX_VALUE, maxHeight = Number.MAX_VALUE, keepAspectRatio = false, autoScale = true, shouldResize, onResizeStart, onResize, onResizeEnd }) {
9547
+ if (!isVisible) {
9548
+ return null;
9549
+ }
9550
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [XY_RESIZER_LINE_POSITIONS.map((position) => jsxRuntime.jsx(NodeResizeControl, { className: lineClassName, style: lineStyle, nodeId, position, variant: ResizeControlVariant.Line, color: color2, minWidth, minHeight, maxWidth, maxHeight, onResizeStart, keepAspectRatio, autoScale, shouldResize, onResize, onResizeEnd }, position)), XY_RESIZER_HANDLE_POSITIONS.map((position) => jsxRuntime.jsx(NodeResizeControl, { className: handleClassName, style: handleStyle, nodeId, position, color: color2, minWidth, minHeight, maxWidth, maxHeight, onResizeStart, keepAspectRatio, autoScale, shouldResize, onResize, onResizeEnd }, position))] });
9551
+ }
9552
+ var selector = (state) => state.domNode?.querySelector(".react-flow__renderer");
9553
+ function NodeToolbarPortal({ children: children2 }) {
9554
+ const wrapperRef = useStore(selector);
9555
+ if (!wrapperRef) {
9556
+ return null;
9557
+ }
9558
+ return reactDom.createPortal(children2, wrapperRef);
9559
+ }
9560
+ var nodeEqualityFn = (a, b) => a?.internals.positionAbsolute.x !== b?.internals.positionAbsolute.x || a?.internals.positionAbsolute.y !== b?.internals.positionAbsolute.y || a?.measured.width !== b?.measured.width || a?.measured.height !== b?.measured.height || a?.selected !== b?.selected || a?.internals.z !== b?.internals.z;
9561
+ var nodesEqualityFn = (a, b) => {
9562
+ if (a.size !== b.size) {
9563
+ return false;
9564
+ }
9565
+ for (const [key, node] of a) {
9566
+ if (nodeEqualityFn(node, b.get(key))) {
9567
+ return false;
9568
+ }
9569
+ }
9570
+ return true;
9571
+ };
9572
+ var storeSelector = (state) => ({
9573
+ x: state.transform[0],
9574
+ y: state.transform[1],
9575
+ zoom: state.transform[2],
9576
+ selectedNodesCount: state.nodes.filter((node) => node.selected).length
9577
+ });
9578
+ function NodeToolbar({ nodeId, children: children2, className, style: style2, isVisible, position = Position.Top, offset = 10, align = "center", ...rest }) {
9579
+ const contextNodeId = useNodeId();
9580
+ const nodesSelector = ReactExports.useCallback((state) => {
9581
+ const nodeIds = Array.isArray(nodeId) ? nodeId : [nodeId || contextNodeId || ""];
9582
+ const internalNodes = nodeIds.reduce((res, id2) => {
9583
+ const node = state.nodeLookup.get(id2);
9584
+ if (node) {
9585
+ res.set(node.id, node);
9586
+ }
9587
+ return res;
9588
+ }, /* @__PURE__ */ new Map());
9589
+ return internalNodes;
9590
+ }, [nodeId, contextNodeId]);
9591
+ const nodes = useStore(nodesSelector, nodesEqualityFn);
9592
+ const { x, y, zoom, selectedNodesCount } = useStore(storeSelector, shallow$1);
9593
+ const isActive = typeof isVisible === "boolean" ? isVisible : nodes.size === 1 && nodes.values().next().value?.selected && selectedNodesCount === 1;
9594
+ if (!isActive || !nodes.size) {
9595
+ return null;
9596
+ }
9597
+ const nodeRect = getInternalNodesBounds(nodes);
9598
+ const nodesArray = Array.from(nodes.values());
9599
+ const zIndex = Math.max(...nodesArray.map((node) => node.internals.z + 1));
9600
+ const wrapperStyle2 = {
9601
+ position: "absolute",
9602
+ transform: getNodeToolbarTransform(nodeRect, { x, y, zoom }, position, offset, align),
9603
+ zIndex,
9604
+ ...style2
9605
+ };
9606
+ return jsxRuntime.jsx(NodeToolbarPortal, { children: jsxRuntime.jsx("div", { style: wrapperStyle2, className: cc(["react-flow__node-toolbar", className]), ...rest, "data-id": nodesArray.reduce((acc, node) => `${acc}${node.id} `, "").trim(), children: children2 }) });
9607
+ }
9510
9608
  function RegistryNodeInner(props) {
9511
9609
  const kindName = props.data.kind ?? props.type;
9512
9610
  const kind = ReactExports.useMemo(() => getNodeKind(kindName), [kindName]);
@@ -9538,10 +9636,20 @@ function RegistryNodeInner(props) {
9538
9636
  "ff-node",
9539
9637
  `ff-node--status-${status}`,
9540
9638
  `ff-node--cat-${kind.category}`,
9541
- props.selected ? "ff-node--selected" : ""
9639
+ props.selected ? "ff-node--selected" : "",
9640
+ kind.resizable ? "ff-node--resizable" : ""
9542
9641
  ].filter(Boolean).join(" "),
9543
9642
  style: { borderColor: props.selected ? accent : void 0 },
9544
9643
  children: [
9644
+ kind.resizable && /* @__PURE__ */ jsxRuntime.jsx(
9645
+ NodeResizer,
9646
+ {
9647
+ isVisible: props.selected ?? false,
9648
+ color: accent,
9649
+ ...typeof kind.resizable === "object" ? kind.resizable : {}
9650
+ }
9651
+ ),
9652
+ kind.toolbar && /* @__PURE__ */ jsxRuntime.jsx(NodeToolbar, { isVisible: props.selected ?? false, children: kind.toolbar({ nodeId: props.id, config, selected: props.selected ?? false }) }),
9545
9653
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "ff-node__header", style: { background: accent }, children: [
9546
9654
  kind.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ff-node__icon", "aria-hidden": true, children: kind.icon }),
9547
9655
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ff-node__tag", children: kind.label.toUpperCase() }),