@rkmodules/rules 0.0.105 → 0.0.107
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 +23 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Flow/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2050,6 +2050,14 @@ function topSort(fn) {
|
|
|
2050
2050
|
var orderedBody = Object.fromEntries(ordered.map(function (id) { return [id, fn.body[id]]; }));
|
|
2051
2051
|
return __assign(__assign({}, fn), { body: orderedBody });
|
|
2052
2052
|
}
|
|
2053
|
+
function getDefault(varDef, inputs) {
|
|
2054
|
+
if (inputs === void 0) { inputs = {}; }
|
|
2055
|
+
var normDef = normalizeVarDef(varDef);
|
|
2056
|
+
if (typeof normDef.default === "function") {
|
|
2057
|
+
return normDef.default(inputs);
|
|
2058
|
+
}
|
|
2059
|
+
return normDef.default;
|
|
2060
|
+
}
|
|
2053
2061
|
var Engine = /** @class */ (function () {
|
|
2054
2062
|
function Engine(morePrimitives, env) {
|
|
2055
2063
|
if (morePrimitives === void 0) { morePrimitives = {}; }
|
|
@@ -2080,8 +2088,8 @@ var Engine = /** @class */ (function () {
|
|
|
2080
2088
|
Object.entries(node.inputs || {}).forEach(function (_a) {
|
|
2081
2089
|
var _b = __read(_a, 2), name = _b[0], def = _b[1];
|
|
2082
2090
|
var normDef = normalizeVarDef(def);
|
|
2083
|
-
if (
|
|
2084
|
-
inputs[name] = normDef
|
|
2091
|
+
if (inputs[name] === undefined && normDef.default !== undefined) {
|
|
2092
|
+
inputs[name] = getDefault(normDef, inputs);
|
|
2085
2093
|
}
|
|
2086
2094
|
});
|
|
2087
2095
|
context = {
|
|
@@ -2377,7 +2385,7 @@ var Engine = /** @class */ (function () {
|
|
|
2377
2385
|
if ((_a = fn.inputs) === null || _a === void 0 ? void 0 : _a[toField]) {
|
|
2378
2386
|
var normDef = normalizeVarDef(fn.inputs[toField]);
|
|
2379
2387
|
if (normDef.default !== undefined) {
|
|
2380
|
-
to.inputs[toField] = normDef.
|
|
2388
|
+
to.inputs[toField] = getDefault(normDef, to.inputs);
|
|
2381
2389
|
}
|
|
2382
2390
|
}
|
|
2383
2391
|
}
|
|
@@ -2408,7 +2416,7 @@ var Engine = /** @class */ (function () {
|
|
|
2408
2416
|
var _b = __read(_a, 2), key = _b[0], def = _b[1];
|
|
2409
2417
|
var normDef = normalizeVarDef(def);
|
|
2410
2418
|
if (normDef.default !== undefined) {
|
|
2411
|
-
inputs[key] = normDef
|
|
2419
|
+
inputs[key] = getDefault(normDef, inputs);
|
|
2412
2420
|
}
|
|
2413
2421
|
});
|
|
2414
2422
|
// get params defaults
|
|
@@ -2417,7 +2425,7 @@ var Engine = /** @class */ (function () {
|
|
|
2417
2425
|
var _b = __read(_a, 2), key = _b[0], def = _b[1];
|
|
2418
2426
|
var normDef = normalizeVarDef(def);
|
|
2419
2427
|
if (normDef.default !== undefined) {
|
|
2420
|
-
params[key] = normDef
|
|
2428
|
+
params[key] = getDefault(normDef, params);
|
|
2421
2429
|
}
|
|
2422
2430
|
});
|
|
2423
2431
|
var newCall = {
|
|
@@ -6165,10 +6173,14 @@ var ConnectionLine = (function (_a) {
|
|
|
6165
6173
|
*/
|
|
6166
6174
|
var emptyObject = {};
|
|
6167
6175
|
function FlowInner(_a) {
|
|
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;
|
|
6176
|
+
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;
|
|
6169
6177
|
var _d = __read(React.useState(null), 2), instance = _d[0], setInstance = _d[1];
|
|
6178
|
+
var handleInit = function (instance) {
|
|
6179
|
+
setInstance(instance);
|
|
6180
|
+
onInit === null || onInit === void 0 ? void 0 : onInit(instance);
|
|
6181
|
+
};
|
|
6170
6182
|
var updatePosition = useUpdatePositions(fn);
|
|
6171
|
-
var _e = __read(usePositions(fn),
|
|
6183
|
+
var _e = __read(usePositions(fn), 2), positions = _e[0], setPositions = _e[1];
|
|
6172
6184
|
var options = React.useMemo(function () {
|
|
6173
6185
|
var handleDataChange = function (id) { return function (newData) {
|
|
6174
6186
|
onChange === null || onChange === void 0 ? void 0 : onChange(function (fn) {
|
|
@@ -6195,6 +6207,9 @@ function FlowInner(_a) {
|
|
|
6195
6207
|
onIOChange: handleIOChange,
|
|
6196
6208
|
};
|
|
6197
6209
|
}, [fn, onChange, defaultPositions]);
|
|
6210
|
+
React.useEffect(function () {
|
|
6211
|
+
setPositions(__assign(__assign({}, positions), defaultPositions));
|
|
6212
|
+
}, [defaultPositions]);
|
|
6198
6213
|
var _f = useFlow(fn, engine, options), nodes = _f.nodes, edges = _f.edges, setNodes = _f.setNodes, setEdges = _f.setEdges;
|
|
6199
6214
|
// node selection handler
|
|
6200
6215
|
var handleSelect = React.useCallback(function (_a) {
|
|
@@ -6292,7 +6307,7 @@ function FlowInner(_a) {
|
|
|
6292
6307
|
return react.applyEdgeChanges(changes, edgesSnapshot);
|
|
6293
6308
|
});
|
|
6294
6309
|
}, []);
|
|
6295
|
-
return (React.createElement(react.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:
|
|
6310
|
+
return (React.createElement(react.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: {
|
|
6296
6311
|
minZoom: fitView ? undefined : 1,
|
|
6297
6312
|
maxZoom: fitView ? undefined : 1,
|
|
6298
6313
|
},
|