Socket
Socket
Sign inDemoInstall

react-complex-tree

Package Overview
Dependencies
0
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.10 to 1.1.11

lib/cjs/waitFor.d.ts

1

lib/cjs/controlledEnvironment/DragAndDropProvider.js

@@ -47,3 +47,2 @@ "use strict";

var callSoon = useCallSoon_1.useCallSoon();
var shouldCancelDrag = react_1.useRef(false);
var resetProgrammaticDragIndexForCurrentTree = react_1.useCallback(function (viableDragPositions, draggingItems) {

@@ -50,0 +49,0 @@ var _a;

@@ -21,2 +21,38 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {

@@ -34,19 +70,32 @@ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)

var useCreatedEnvironmentRef_1 = require("./useCreatedEnvironmentRef");
var useRefCopy_1 = require("../useRefCopy");
var waitFor_1 = require("../waitFor");
var EnvironmentActionsContext = React.createContext(null);
var useEnvironmentActions = function () { return React.useContext(EnvironmentActionsContext); };
exports.useEnvironmentActions = useEnvironmentActions;
var recursiveExpand = function (itemId, items, onExpand) {
var _a, _b;
for (var _i = 0, _c = (_b = (_a = items[itemId]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []; _i < _c.length; _i++) {
var childId = _c[_i];
var item = items[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
var recursiveExpand = function (itemId, items, onExpand) { return __awaiter(void 0, void 0, void 0, function () {
var _loop_1, _i, _a, childId;
var _b, _c, _d;
return __generator(this, function (_e) {
_loop_1 = function (childId) {
waitFor_1.waitFor(function () { var _a; return !!((_a = items.current) === null || _a === void 0 ? void 0 : _a[childId]); }).then(function () {
var _a;
var item = (_a = items.current) === null || _a === void 0 ? void 0 : _a[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
}
});
};
for (_i = 0, _a = (_d = (_c = (_b = items.current) === null || _b === void 0 ? void 0 : _b[itemId]) === null || _c === void 0 ? void 0 : _c.children) !== null && _d !== void 0 ? _d : []; _i < _a.length; _i++) {
childId = _a[_i];
_loop_1(childId);
}
}
};
return [2 /*return*/];
});
}); };
exports.EnvironmentActionsProvider = React.forwardRef(function (props, ref) {
var _a = ControlledTreeEnvironment_1.useTreeEnvironment(), onCollapseItem = _a.onCollapseItem, items = _a.items, trees = _a.trees, viewState = _a.viewState, onExpandItem = _a.onExpandItem, onFocusItem = _a.onFocusItem, setActiveTree = _a.setActiveTree, onRenameItem = _a.onRenameItem, onSelectItems = _a.onSelectItems, onPrimaryAction = _a.onPrimaryAction, linearItems = _a.linearItems;
var _b = DragAndDropProvider_1.useDragAndDrop(), abortProgrammaticDrag = _b.abortProgrammaticDrag, completeProgrammaticDrag = _b.completeProgrammaticDrag, programmaticDragDown = _b.programmaticDragDown, programmaticDragUp = _b.programmaticDragUp, startProgrammaticDrag = _b.startProgrammaticDrag;
var itemsRef = useRefCopy_1.useRefCopy(items);
// TODO change environment childs to use actions rather than output events where possible

@@ -131,7 +180,12 @@ var actions = {

}, [items, onPrimaryAction]),
expandAll: react_1.useCallback(function (treeId) {
recursiveExpand(trees[treeId].rootItem, items, function (item) {
onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId);
expandAll: react_1.useCallback(function (treeId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, recursiveExpand(trees[treeId].rootItem, itemsRef, function (item) { return onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId); })];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}, [items, onExpandItem, trees]),
}); }, [itemsRef, onExpandItem, trees]),
collapseAll: react_1.useCallback(function (treeId) {

@@ -138,0 +192,0 @@ var _a, _b;

@@ -92,3 +92,2 @@ "use strict";

expandAll: function () {
console.log('!!');
envActions.expandAll(tree.treeId);

@@ -95,0 +94,0 @@ },

import * as React from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useTreeEnvironment } from './ControlledTreeEnvironment';

@@ -24,3 +24,2 @@ import { useOnDragOverTreeHandler } from './useOnDragOverTreeHandler';

var callSoon = useCallSoon();
var shouldCancelDrag = useRef(false);
var resetProgrammaticDragIndexForCurrentTree = useCallback(function (viableDragPositions, draggingItems) {

@@ -27,0 +26,0 @@ var _a;

@@ -0,1 +1,37 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {

@@ -11,18 +47,31 @@ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)

import { useCreatedEnvironmentRef } from './useCreatedEnvironmentRef';
import { useRefCopy } from '../useRefCopy';
import { waitFor } from '../waitFor';
var EnvironmentActionsContext = React.createContext(null);
export var useEnvironmentActions = function () { return React.useContext(EnvironmentActionsContext); };
var recursiveExpand = function (itemId, items, onExpand) {
var _a, _b;
for (var _i = 0, _c = (_b = (_a = items[itemId]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []; _i < _c.length; _i++) {
var childId = _c[_i];
var item = items[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
var recursiveExpand = function (itemId, items, onExpand) { return __awaiter(void 0, void 0, void 0, function () {
var _loop_1, _i, _a, childId;
var _b, _c, _d;
return __generator(this, function (_e) {
_loop_1 = function (childId) {
waitFor(function () { var _a; return !!((_a = items.current) === null || _a === void 0 ? void 0 : _a[childId]); }).then(function () {
var _a;
var item = (_a = items.current) === null || _a === void 0 ? void 0 : _a[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
}
});
};
for (_i = 0, _a = (_d = (_c = (_b = items.current) === null || _b === void 0 ? void 0 : _b[itemId]) === null || _c === void 0 ? void 0 : _c.children) !== null && _d !== void 0 ? _d : []; _i < _a.length; _i++) {
childId = _a[_i];
_loop_1(childId);
}
}
};
return [2 /*return*/];
});
}); };
export var EnvironmentActionsProvider = React.forwardRef(function (props, ref) {
var _a = useTreeEnvironment(), onCollapseItem = _a.onCollapseItem, items = _a.items, trees = _a.trees, viewState = _a.viewState, onExpandItem = _a.onExpandItem, onFocusItem = _a.onFocusItem, setActiveTree = _a.setActiveTree, onRenameItem = _a.onRenameItem, onSelectItems = _a.onSelectItems, onPrimaryAction = _a.onPrimaryAction, linearItems = _a.linearItems;
var _b = useDragAndDrop(), abortProgrammaticDrag = _b.abortProgrammaticDrag, completeProgrammaticDrag = _b.completeProgrammaticDrag, programmaticDragDown = _b.programmaticDragDown, programmaticDragUp = _b.programmaticDragUp, startProgrammaticDrag = _b.startProgrammaticDrag;
var itemsRef = useRefCopy(items);
// TODO change environment childs to use actions rather than output events where possible

@@ -107,7 +156,12 @@ var actions = {

}, [items, onPrimaryAction]),
expandAll: useCallback(function (treeId) {
recursiveExpand(trees[treeId].rootItem, items, function (item) {
onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId);
expandAll: useCallback(function (treeId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, recursiveExpand(trees[treeId].rootItem, itemsRef, function (item) { return onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId); })];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}, [items, onExpandItem, trees]),
}); }, [itemsRef, onExpandItem, trees]),
collapseAll: useCallback(function (treeId) {

@@ -114,0 +168,0 @@ var _a, _b;

@@ -69,3 +69,2 @@ import * as React from 'react';

expandAll: function () {
console.log('!!');
envActions.expandAll(tree.treeId);

@@ -72,0 +71,0 @@ },

import * as React from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useTreeEnvironment } from './ControlledTreeEnvironment';

@@ -24,3 +24,2 @@ import { useOnDragOverTreeHandler } from './useOnDragOverTreeHandler';

var callSoon = useCallSoon();
var shouldCancelDrag = useRef(false);
var resetProgrammaticDragIndexForCurrentTree = useCallback(function (viableDragPositions, draggingItems) {

@@ -27,0 +26,0 @@ var _a;

@@ -0,1 +1,37 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {

@@ -11,18 +47,31 @@ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)

import { useCreatedEnvironmentRef } from './useCreatedEnvironmentRef';
import { useRefCopy } from '../useRefCopy';
import { waitFor } from '../waitFor';
var EnvironmentActionsContext = React.createContext(null);
export var useEnvironmentActions = function () { return React.useContext(EnvironmentActionsContext); };
var recursiveExpand = function (itemId, items, onExpand) {
var _a, _b;
for (var _i = 0, _c = (_b = (_a = items[itemId]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []; _i < _c.length; _i++) {
var childId = _c[_i];
var item = items[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
var recursiveExpand = function (itemId, items, onExpand) { return __awaiter(void 0, void 0, void 0, function () {
var _loop_1, _i, _a, childId;
var _b, _c, _d;
return __generator(this, function (_e) {
_loop_1 = function (childId) {
waitFor(function () { var _a; return !!((_a = items.current) === null || _a === void 0 ? void 0 : _a[childId]); }).then(function () {
var _a;
var item = (_a = items.current) === null || _a === void 0 ? void 0 : _a[childId];
if (item === null || item === void 0 ? void 0 : item.hasChildren) {
onExpand(item);
recursiveExpand(childId, items, onExpand);
}
});
};
for (_i = 0, _a = (_d = (_c = (_b = items.current) === null || _b === void 0 ? void 0 : _b[itemId]) === null || _c === void 0 ? void 0 : _c.children) !== null && _d !== void 0 ? _d : []; _i < _a.length; _i++) {
childId = _a[_i];
_loop_1(childId);
}
}
};
return [2 /*return*/];
});
}); };
export var EnvironmentActionsProvider = React.forwardRef(function (props, ref) {
var _a = useTreeEnvironment(), onCollapseItem = _a.onCollapseItem, items = _a.items, trees = _a.trees, viewState = _a.viewState, onExpandItem = _a.onExpandItem, onFocusItem = _a.onFocusItem, setActiveTree = _a.setActiveTree, onRenameItem = _a.onRenameItem, onSelectItems = _a.onSelectItems, onPrimaryAction = _a.onPrimaryAction, linearItems = _a.linearItems;
var _b = useDragAndDrop(), abortProgrammaticDrag = _b.abortProgrammaticDrag, completeProgrammaticDrag = _b.completeProgrammaticDrag, programmaticDragDown = _b.programmaticDragDown, programmaticDragUp = _b.programmaticDragUp, startProgrammaticDrag = _b.startProgrammaticDrag;
var itemsRef = useRefCopy(items);
// TODO change environment childs to use actions rather than output events where possible

@@ -107,7 +156,12 @@ var actions = {

}, [items, onPrimaryAction]),
expandAll: useCallback(function (treeId) {
recursiveExpand(trees[treeId].rootItem, items, function (item) {
onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId);
expandAll: useCallback(function (treeId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, recursiveExpand(trees[treeId].rootItem, itemsRef, function (item) { return onExpandItem === null || onExpandItem === void 0 ? void 0 : onExpandItem(item, treeId); })];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}, [items, onExpandItem, trees]),
}); }, [itemsRef, onExpandItem, trees]),
collapseAll: useCallback(function (treeId) {

@@ -114,0 +168,0 @@ var _a, _b;

@@ -69,3 +69,2 @@ import * as React from 'react';

expandAll: function () {
console.log('!!');
envActions.expandAll(tree.treeId);

@@ -72,0 +71,0 @@ },

{
"name": "react-complex-tree",
"version": "1.1.10",
"version": "1.1.11",
"main": "lib/cjs/index.js",

@@ -36,3 +36,3 @@ "module": "lib/esm/index.js",

"cpy-cli": "^3.1.1",
"demodata": "^1.1.10",
"demodata": "^1.1.11",
"jest": "^26.6.3",

@@ -58,3 +58,3 @@ "loader-utils": "^2.0.0",

},
"gitHead": "f945cbb68e849095c378fa160b1655cca90a8511"
"gitHead": "e3dcc435933284376a0fc6e3cc651e67ead678b5"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc