@rkmodules/rules 0.0.103 → 0.0.104

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.cjs.js CHANGED
@@ -6159,11 +6159,16 @@ var ConnectionLine = (function (_a) {
6159
6159
  React.createElement("path", { d: d[0] })));
6160
6160
  });
6161
6161
 
6162
+ /**
6163
+ * goal: this component should only be responsible for updating the inner node graph, it should call the onChange handler
6164
+ * on any change, but not rerender when the given function changes, as it slows down the interface drastically
6165
+ */
6166
+ var emptyObject = {};
6162
6167
  function FlowInner(_a) {
6163
- var fn = _a.function, engine = _a.engine, _b = _a.center, center = _b === void 0 ? true : _b, fitView = _a.fitView, onChange = _a.onChange, onClick = _a.onClick, onSelect = _a.onSelect;
6164
- var _c = __read(React.useState(null), 2), instance = _c[0], setInstance = _c[1];
6168
+ var fn = _a.function, _b = _a.positions, defaultPositions = _b === void 0 ? emptyObject : _b, engine = _a.engine, _c = _a.center, center = _c === void 0 ? true : _c, fitView = _a.fitView, onChange = _a.onChange, onClick = _a.onClick, onSelect = _a.onSelect;
6169
+ var _d = __read(React.useState(null), 2), instance = _d[0], setInstance = _d[1];
6165
6170
  var updatePosition = useUpdatePositions(fn);
6166
- var _d = __read(usePositions(fn), 1), positions = _d[0];
6171
+ var _e = __read(usePositions(fn), 1), positions = _e[0];
6167
6172
  var options = React.useMemo(function () {
6168
6173
  var handleDataChange = function (id) { return function (newData) {
6169
6174
  onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
@@ -6185,12 +6190,12 @@ function FlowInner(_a) {
6185
6190
  };
6186
6191
  return {
6187
6192
  dragHandle: ".".concat(styles.Label),
6188
- positions: positions,
6193
+ positions: __assign(__assign({}, positions), defaultPositions),
6189
6194
  onDataChange: handleDataChange,
6190
6195
  onIOChange: handleIOChange,
6191
6196
  };
6192
- }, [fn, onChange]);
6193
- var _e = useFlow(fn, engine, options), nodes = _e.nodes, edges = _e.edges, setNodes = _e.setNodes, setEdges = _e.setEdges;
6197
+ }, [fn, onChange, defaultPositions]);
6198
+ var _f = useFlow(fn, engine, options), nodes = _f.nodes, edges = _f.edges, setNodes = _f.setNodes, setEdges = _f.setEdges;
6194
6199
  // node selection handler
6195
6200
  var handleSelect = React.useCallback(function (_a) {
6196
6201
  var nodes = _a.nodes;
@@ -6200,7 +6205,7 @@ function FlowInner(_a) {
6200
6205
  onChange: handleSelect,
6201
6206
  });
6202
6207
  // dropping nodes
6203
- var _f = __read(useDrop({
6208
+ var _g = __read(useDrop({
6204
6209
  accept: "flow-node",
6205
6210
  drop: function (item, monitor) {
6206
6211
  var pos = monitor.getClientOffset();
@@ -6220,7 +6225,7 @@ function FlowInner(_a) {
6220
6225
  isOver: monitor.isOver(),
6221
6226
  };
6222
6227
  },
6223
- }), 2); _f[0].isOver; var drop = _f[1];
6228
+ }), 2); _g[0].isOver; var drop = _g[1];
6224
6229
  // connecting nodes
6225
6230
  var onConnect = React.useCallback(function (params) {
6226
6231
  var _a, _b;