@rkmodules/rules 0.0.118 → 0.0.120
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 +117 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +117 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Flow/Components/Control.d.ts +4 -1
- package/dist/lib/Flow/index.d.ts +3 -2
- package/dist/lib/Primitives/Json/arrayToList.d.ts +2 -0
- package/dist/lib/Primitives/Json/explodeObject.d.ts +2 -0
- package/dist/lib/Primitives/List/uniqueItems.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,8 +3,8 @@ import React, { createContext, memo, useEffect, useLayoutEffect, useState, useCa
|
|
|
3
3
|
import { Handle, Position, useReactFlow, useConnection, getSimpleBezierPath, ReactFlowProvider, useOnSelectionChange, applyNodeChanges, applyEdgeChanges, ReactFlow, Background, BackgroundVariant, Controls } from '@xyflow/react';
|
|
4
4
|
import katex from 'katex';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import rcin from 'rc-input-number';
|
|
7
6
|
import useInner from '@rkmodules/use-inner';
|
|
7
|
+
import rcin from 'rc-input-number';
|
|
8
8
|
import { useLongPress } from 'use-long-press';
|
|
9
9
|
import { create as create$1 } from 'zustand';
|
|
10
10
|
import { persist } from 'zustand/middleware';
|
|
@@ -1749,6 +1749,28 @@ var listInput = {
|
|
|
1749
1749
|
}); },
|
|
1750
1750
|
};
|
|
1751
1751
|
|
|
1752
|
+
var uniqueItems = {
|
|
1753
|
+
name: "uniqueItems",
|
|
1754
|
+
label: "Unique Items",
|
|
1755
|
+
description: "Removes duplicate items from a list",
|
|
1756
|
+
inputs: {
|
|
1757
|
+
items: "any",
|
|
1758
|
+
},
|
|
1759
|
+
outputs: {
|
|
1760
|
+
unique: "any",
|
|
1761
|
+
},
|
|
1762
|
+
impl: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
1763
|
+
var _c = _b.items, items = _c === void 0 ? {} : _c;
|
|
1764
|
+
return __generator(this, function (_d) {
|
|
1765
|
+
return [2 /*return*/, {
|
|
1766
|
+
unique: mapTreeBranch(items, function (items) {
|
|
1767
|
+
return Array.from(new Set(items));
|
|
1768
|
+
}),
|
|
1769
|
+
}];
|
|
1770
|
+
});
|
|
1771
|
+
}); },
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1752
1774
|
var _a$6;
|
|
1753
1775
|
var primitives$6 = (_a$6 = {},
|
|
1754
1776
|
_a$6[listInput.name] = listInput,
|
|
@@ -1758,6 +1780,7 @@ var primitives$6 = (_a$6 = {},
|
|
|
1758
1780
|
_a$6[relativeItem.name] = relativeItem,
|
|
1759
1781
|
_a$6[relativeItems.name] = relativeItems,
|
|
1760
1782
|
_a$6[concat.name] = concat,
|
|
1783
|
+
_a$6[uniqueItems.name] = uniqueItems,
|
|
1761
1784
|
_a$6);
|
|
1762
1785
|
|
|
1763
1786
|
var splitGroup = {
|
|
@@ -2312,12 +2335,87 @@ var objectEntries = {
|
|
|
2312
2335
|
}); },
|
|
2313
2336
|
};
|
|
2314
2337
|
|
|
2338
|
+
var arrayToList = {
|
|
2339
|
+
name: "arrayToList",
|
|
2340
|
+
label: "Array to List",
|
|
2341
|
+
description: "Separates array",
|
|
2342
|
+
inputs: {
|
|
2343
|
+
items: "any",
|
|
2344
|
+
},
|
|
2345
|
+
params: {
|
|
2346
|
+
split: { type: "boolean", default: false, label: "split groups" },
|
|
2347
|
+
},
|
|
2348
|
+
outputs: {
|
|
2349
|
+
arrays: "any",
|
|
2350
|
+
},
|
|
2351
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
2352
|
+
var _c = _b.items, items = _c === void 0 ? {} : _c;
|
|
2353
|
+
return __generator(this, function (_d) {
|
|
2354
|
+
if (params.split) {
|
|
2355
|
+
items = graftTree(items);
|
|
2356
|
+
}
|
|
2357
|
+
return [2 /*return*/, {
|
|
2358
|
+
arrays: mapTreeBranch(items, function (items) {
|
|
2359
|
+
return items.flat();
|
|
2360
|
+
}),
|
|
2361
|
+
}];
|
|
2362
|
+
});
|
|
2363
|
+
}); },
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
var explodeObject = {
|
|
2367
|
+
name: "explodeObject",
|
|
2368
|
+
label: "Explode Object",
|
|
2369
|
+
description: "Separates all fields of an object",
|
|
2370
|
+
nodeType: "DynamicOutput",
|
|
2371
|
+
inputs: {
|
|
2372
|
+
object: "any",
|
|
2373
|
+
},
|
|
2374
|
+
params: {
|
|
2375
|
+
split: { type: "boolean", default: false, label: "split groups" },
|
|
2376
|
+
},
|
|
2377
|
+
outputs: {
|
|
2378
|
+
// values: "any",
|
|
2379
|
+
},
|
|
2380
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
2381
|
+
var outputs;
|
|
2382
|
+
var _c = _b.object, object = _c === void 0 ? {} : _c;
|
|
2383
|
+
return __generator(this, function (_d) {
|
|
2384
|
+
outputs = {};
|
|
2385
|
+
if (params.split) {
|
|
2386
|
+
object = graftTree(object);
|
|
2387
|
+
}
|
|
2388
|
+
forEachBranch(object, function (branch, path) {
|
|
2389
|
+
branch.forEach(function (obj, index) {
|
|
2390
|
+
if (!obj)
|
|
2391
|
+
return;
|
|
2392
|
+
var props = obj || {};
|
|
2393
|
+
Object.entries(props).forEach(function (_a) {
|
|
2394
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
2395
|
+
if (key[0] === "_")
|
|
2396
|
+
return;
|
|
2397
|
+
if (!outputs[key]) {
|
|
2398
|
+
outputs[key] = {};
|
|
2399
|
+
}
|
|
2400
|
+
[].concat(value).forEach(function (v) {
|
|
2401
|
+
pushItem(outputs[key], path, v);
|
|
2402
|
+
});
|
|
2403
|
+
});
|
|
2404
|
+
});
|
|
2405
|
+
});
|
|
2406
|
+
return [2 /*return*/, outputs];
|
|
2407
|
+
});
|
|
2408
|
+
}); },
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2315
2411
|
var _a$1;
|
|
2316
2412
|
var primitives$1 = (_a$1 = {},
|
|
2317
2413
|
_a$1[object.name] = object,
|
|
2318
2414
|
_a$1[listToArray.name] = listToArray,
|
|
2415
|
+
_a$1[arrayToList.name] = arrayToList,
|
|
2319
2416
|
_a$1[mergeObject.name] = mergeObject,
|
|
2320
2417
|
_a$1[objectEntries.name] = objectEntries,
|
|
2418
|
+
_a$1[explodeObject.name] = explodeObject,
|
|
2321
2419
|
_a$1);
|
|
2322
2420
|
|
|
2323
2421
|
var Lib = {
|
|
@@ -5654,11 +5752,11 @@ var InputText = React.memo(function (_a) {
|
|
|
5654
5752
|
});
|
|
5655
5753
|
function Control(_a) {
|
|
5656
5754
|
var _b;
|
|
5657
|
-
var value = _a.value, vardef = _a.vardef, onChange = _a.onChange;
|
|
5755
|
+
var value = _a.value, vardef = _a.vardef, data = _a.data, onChange = _a.onChange;
|
|
5658
5756
|
var customControls = useControls();
|
|
5659
5757
|
if (vardef.type in customControls) {
|
|
5660
5758
|
var ControlComponent = customControls[vardef.type];
|
|
5661
|
-
return (React.createElement(ControlComponent, { value: value, vardef: vardef, onChange: onChange }));
|
|
5759
|
+
return (React.createElement(ControlComponent, { value: value, vardef: vardef, onChange: onChange, data: data }));
|
|
5662
5760
|
}
|
|
5663
5761
|
if (vardef.options) {
|
|
5664
5762
|
return (React.createElement("select", { value: value || "", onChange: function (e) { return onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value); } }, vardef.options.map(function (option) { return (React.createElement("option", { key: option, value: option }, option)); })));
|
|
@@ -5702,7 +5800,7 @@ var Input = function (_a) {
|
|
|
5702
5800
|
"--type-color": "var(--color-".concat(normalized.type, ")"),
|
|
5703
5801
|
}, onClick: onClick },
|
|
5704
5802
|
React.createElement("span", { className: styles$1.PortLabel }, normalized.label || name),
|
|
5705
|
-
!isRef && (React.createElement(Control, { vardef: normalized, value: value, onChange: handleInputChange(name) }))));
|
|
5803
|
+
!isRef && (React.createElement(Control, { vardef: normalized, value: value, onChange: handleInputChange(name), data: data }))));
|
|
5706
5804
|
};
|
|
5707
5805
|
|
|
5708
5806
|
var Param = function (_a) {
|
|
@@ -5721,7 +5819,7 @@ var Param = function (_a) {
|
|
|
5721
5819
|
"--type-color": "var(--color-".concat(normalized.type, ")"),
|
|
5722
5820
|
}, onClick: onClick },
|
|
5723
5821
|
React.createElement("span", { className: styles$1.PortLabel }, normalized.label || name),
|
|
5724
|
-
!isRef && (React.createElement(Control, { vardef: normalized, value: value, onChange: handleParamChange(name) }))));
|
|
5822
|
+
!isRef && (React.createElement(Control, { vardef: normalized, value: value, onChange: handleParamChange(name), data: data }))));
|
|
5725
5823
|
};
|
|
5726
5824
|
|
|
5727
5825
|
var Output = function (_a) {
|
|
@@ -5881,7 +5979,7 @@ function GenericNode(_a) {
|
|
|
5881
5979
|
var engine = useEngine();
|
|
5882
5980
|
var _d = __read(React.useState({}), 2), result = _d[0], setResult = _d[1];
|
|
5883
5981
|
var _e = __read(React.useState(null), 2), duration = _e[0], setDuration = _e[1];
|
|
5884
|
-
var _f = __read(
|
|
5982
|
+
var _f = __read(useInner(((_c = outputEntries[0]) === null || _c === void 0 ? void 0 : _c[0]) || null, [outputs, data.outputDefs]), 2), focus = _f[0], setFocus = _f[1];
|
|
5885
5983
|
var _g = __read(React.useState(false), 2), showPreview = _g[0], setShowPreview = _g[1];
|
|
5886
5984
|
var previewValue = focus ? result[focus] : Object.values(result)[0];
|
|
5887
5985
|
React.useEffect(function () {
|
|
@@ -5897,17 +5995,17 @@ function GenericNode(_a) {
|
|
|
5897
5995
|
React.createElement("div", { className: styles.Description }, data.description),
|
|
5898
5996
|
children,
|
|
5899
5997
|
React.createElement("div", { className: styles.Ports },
|
|
5900
|
-
outputEntries.map(function (_a) {
|
|
5998
|
+
outputEntries.map(function (_a, index) {
|
|
5901
5999
|
var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
|
|
5902
|
-
return (React.createElement(Output, { key: name, name: name, varDef: varDef, id: id, onClick: function () { return setFocus(name); }, focus: showPreview && focus === name }));
|
|
6000
|
+
return (React.createElement(Output, { key: "".concat(name, "_").concat(index), name: name, varDef: varDef, id: id, onClick: function () { return setFocus(name); }, focus: showPreview && focus === name }));
|
|
5903
6001
|
}),
|
|
5904
|
-
inputEntries.map(function (_a) {
|
|
6002
|
+
inputEntries.map(function (_a, index) {
|
|
5905
6003
|
var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
|
|
5906
|
-
return (React.createElement(Input, { key: name, name: name, varDef: varDef, id: id, data: data }));
|
|
6004
|
+
return (React.createElement(Input, { key: "".concat(name, "_").concat(index), name: name, varDef: varDef, id: id, data: data }));
|
|
5907
6005
|
}),
|
|
5908
|
-
paramEntries.map(function (_a) {
|
|
6006
|
+
paramEntries.map(function (_a, index) {
|
|
5909
6007
|
var _b = __read(_a, 2), name = _b[0], varDef = _b[1];
|
|
5910
|
-
return (React.createElement(Param, { key: name, name: name, varDef: varDef, id: id, data: data }));
|
|
6008
|
+
return (React.createElement(Param, { key: "".concat(name, "_").concat(index), name: name, varDef: varDef, id: id, data: data }));
|
|
5911
6009
|
})),
|
|
5912
6010
|
React.createElement("div", { className: classNames(styles.PreviewHead, (_b = {},
|
|
5913
6011
|
_b[styles.expanded] = showPreview,
|
|
@@ -6523,14 +6621,14 @@ var ConnectionLine = (function (_a) {
|
|
|
6523
6621
|
*/
|
|
6524
6622
|
var emptyObject = {};
|
|
6525
6623
|
function FlowInner(_a) {
|
|
6526
|
-
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, onInit = _a.onInit;
|
|
6527
|
-
var
|
|
6624
|
+
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, _d = _a.customNodes, customNodes = _d === void 0 ? {} : _d, onChange = _a.onChange, onClick = _a.onClick, onSelect = _a.onSelect, onInit = _a.onInit;
|
|
6625
|
+
var _e = __read(React.useState(null), 2), instance = _e[0], setInstance = _e[1];
|
|
6528
6626
|
var handleInit = function (instance) {
|
|
6529
6627
|
setInstance(instance);
|
|
6530
6628
|
onInit === null || onInit === void 0 ? void 0 : onInit(instance);
|
|
6531
6629
|
};
|
|
6532
6630
|
var updatePosition = useUpdatePositions(fn);
|
|
6533
|
-
var
|
|
6631
|
+
var _f = __read(usePositions(fn), 2), positions = _f[0], setPositions = _f[1];
|
|
6534
6632
|
var options = React.useMemo(function () {
|
|
6535
6633
|
var handleDataChange = function (id) { return function (newData) {
|
|
6536
6634
|
onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
|
|
@@ -6560,7 +6658,7 @@ function FlowInner(_a) {
|
|
|
6560
6658
|
React.useEffect(function () {
|
|
6561
6659
|
setPositions(__assign(__assign({}, positions), defaultPositions));
|
|
6562
6660
|
}, [defaultPositions]);
|
|
6563
|
-
var
|
|
6661
|
+
var _g = useFlow(fn, engine, options), nodes = _g.nodes, edges = _g.edges, setNodes = _g.setNodes, setEdges = _g.setEdges;
|
|
6564
6662
|
// node selection handler
|
|
6565
6663
|
var handleSelect = React.useCallback(function (_a) {
|
|
6566
6664
|
var nodes = _a.nodes;
|
|
@@ -6570,7 +6668,7 @@ function FlowInner(_a) {
|
|
|
6570
6668
|
onChange: handleSelect,
|
|
6571
6669
|
});
|
|
6572
6670
|
// dropping nodes
|
|
6573
|
-
var
|
|
6671
|
+
var _h = __read(useDrop({
|
|
6574
6672
|
accept: "flow-node",
|
|
6575
6673
|
drop: function (item, monitor) {
|
|
6576
6674
|
var pos = monitor.getClientOffset();
|
|
@@ -6590,7 +6688,7 @@ function FlowInner(_a) {
|
|
|
6590
6688
|
isOver: monitor.isOver(),
|
|
6591
6689
|
};
|
|
6592
6690
|
},
|
|
6593
|
-
}), 2);
|
|
6691
|
+
}), 2); _h[0].isOver; var drop = _h[1];
|
|
6594
6692
|
// connecting nodes
|
|
6595
6693
|
var onConnect = React.useCallback(function (params) {
|
|
6596
6694
|
var _a, _b;
|
|
@@ -6657,7 +6755,7 @@ function FlowInner(_a) {
|
|
|
6657
6755
|
return applyEdgeChanges(changes, edgesSnapshot);
|
|
6658
6756
|
});
|
|
6659
6757
|
}, []);
|
|
6660
|
-
return (React.createElement(ReactFlow, { ref: drop, nodes: nodes, edges: edges, nodeTypes: nodeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onNodesDelete: onNodesDelete, onEdgesDelete: onEdgesDelete, onNodeDragStop: function (e, n) { return updatePosition(n.id, n.position); }, onConnect: onConnect, onInit: handleInit, onPaneClick: handleClick, fitView: center || fitView, fitViewOptions: {
|
|
6758
|
+
return (React.createElement(ReactFlow, { ref: drop, nodes: nodes, edges: edges, nodeTypes: __assign(__assign({}, nodeTypes), customNodes), onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onNodesDelete: onNodesDelete, onEdgesDelete: onEdgesDelete, onNodeDragStop: function (e, n) { return updatePosition(n.id, n.position); }, onConnect: onConnect, onInit: handleInit, onPaneClick: handleClick, fitView: center || fitView, fitViewOptions: {
|
|
6661
6759
|
minZoom: fitView ? undefined : 1,
|
|
6662
6760
|
maxZoom: fitView ? undefined : 1,
|
|
6663
6761
|
},
|