@elliemae/ds-treeview 2.0.0-next.7 → 2.0.0-rc.2

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.
Files changed (74) hide show
  1. package/cjs/TreeView.js +5 -0
  2. package/cjs/deprecated/TreeView.js +5 -0
  3. package/cjs/deprecated/__testUtils__/utils.js +9 -1
  4. package/cjs/deprecated/plugins/dnd/TreeDndPlugin.js +14 -8
  5. package/cjs/deprecated/plugins/dnd/renderers/DraggableItem.js +7 -3
  6. package/cjs/deprecated/plugins/dnd/renderers/DroppableList.js +20 -15
  7. package/cjs/deprecated/plugins/dnd/utils.js +41 -34
  8. package/cjs/deprecated/plugins/roving/TreeRovingPlugin.js +12 -3
  9. package/cjs/deprecated/plugins/searchable/SearchableTreePlugin.js +5 -3
  10. package/cjs/deprecated/plugins/selectable/SelectablePluginTree.js +52 -33
  11. package/cjs/deprecated/plugins/toolbar/TreeToolbarPlugin.js +11 -7
  12. package/cjs/deprecated/plugins/tree/TreeDataPlugin.js +38 -28
  13. package/cjs/deprecated/plugins/tree/useExpandTreeState.js +8 -5
  14. package/cjs/deprecated/plugins/tree/utils.js +17 -4
  15. package/cjs/deprecated/plugins/tree/walkTreeStrategy.js +11 -9
  16. package/cjs/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js +24 -10
  17. package/cjs/deprecated/renderers.js +16 -8
  18. package/cjs/parts/CheckboxSelectable.js +7 -3
  19. package/cjs/parts/ExpandCaret.js +10 -10
  20. package/cjs/parts/Icon.js +2 -2
  21. package/cjs/parts/NestingSpace.js +5 -0
  22. package/cjs/parts/RadioSelectable.js +2 -3
  23. package/cjs/parts/TreeItem.js +29 -19
  24. package/cjs/parts/TreeItemText.js +12 -9
  25. package/cjs/parts/TreeList.js +17 -7
  26. package/cjs/related-components/TreeViewSearchBar.js +2 -2
  27. package/cjs/utils/dnd-helpers.js +29 -25
  28. package/cjs/utils/group-expands-helpers.js +7 -5
  29. package/cjs/utils/keyboard-helpers.js +6 -3
  30. package/cjs/utils/object-helpers.js +8 -0
  31. package/cjs/utils/refs-helpers.js +11 -1
  32. package/cjs/utils/selectable-helper.js +9 -2
  33. package/cjs/utils/tree-helpers.js +26 -8
  34. package/cjs/utils/useDnDHelpers.js +18 -12
  35. package/cjs/utils/useInstanceRefActions.js +13 -10
  36. package/cjs/utils/useTree.js +5 -0
  37. package/esm/TreeView.js +5 -0
  38. package/esm/deprecated/TreeView.js +5 -0
  39. package/esm/deprecated/__testUtils__/utils.js +9 -1
  40. package/esm/deprecated/plugins/dnd/TreeDndPlugin.js +13 -7
  41. package/esm/deprecated/plugins/dnd/renderers/DraggableItem.js +6 -1
  42. package/esm/deprecated/plugins/dnd/renderers/DroppableList.js +17 -11
  43. package/esm/deprecated/plugins/dnd/utils.js +34 -27
  44. package/esm/deprecated/plugins/roving/TreeRovingPlugin.js +11 -2
  45. package/esm/deprecated/plugins/searchable/SearchableTreePlugin.js +4 -1
  46. package/esm/deprecated/plugins/selectable/SelectablePluginTree.js +44 -22
  47. package/esm/deprecated/plugins/toolbar/TreeToolbarPlugin.js +8 -3
  48. package/esm/deprecated/plugins/tree/TreeDataPlugin.js +28 -16
  49. package/esm/deprecated/plugins/tree/useExpandTreeState.js +6 -2
  50. package/esm/deprecated/plugins/tree/utils.js +17 -4
  51. package/esm/deprecated/plugins/tree/walkTreeStrategy.js +11 -9
  52. package/esm/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js +24 -10
  53. package/esm/deprecated/renderers.js +16 -8
  54. package/esm/parts/CheckboxSelectable.js +7 -2
  55. package/esm/parts/ExpandCaret.js +8 -6
  56. package/esm/parts/Icon.js +1 -1
  57. package/esm/parts/NestingSpace.js +5 -0
  58. package/esm/parts/RadioSelectable.js +2 -2
  59. package/esm/parts/TreeItem.js +29 -18
  60. package/esm/parts/TreeItemText.js +10 -7
  61. package/esm/parts/TreeList.js +16 -6
  62. package/esm/related-components/TreeViewSearchBar.js +1 -1
  63. package/esm/utils/dnd-helpers.js +29 -25
  64. package/esm/utils/group-expands-helpers.js +7 -5
  65. package/esm/utils/keyboard-helpers.js +6 -3
  66. package/esm/utils/object-helpers.js +8 -0
  67. package/esm/utils/refs-helpers.js +11 -1
  68. package/esm/utils/selectable-helper.js +9 -2
  69. package/esm/utils/tree-helpers.js +26 -8
  70. package/esm/utils/useDnDHelpers.js +18 -12
  71. package/esm/utils/useInstanceRefActions.js +13 -10
  72. package/esm/utils/useTree.js +5 -0
  73. package/package.json +11 -10
  74. package/types/deprecated/plugins/tree/useExpandTreeState.d.ts +12 -2
@@ -1,10 +1,15 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
2
  import _jsx from '@babel/runtime/helpers/esm/jsx';
3
3
  import 'core-js/modules/web.dom-collections.iterator.js';
4
+ import 'core-js/modules/esnext.async-iterator.filter.js';
5
+ import 'core-js/modules/esnext.iterator.constructor.js';
6
+ import 'core-js/modules/esnext.iterator.filter.js';
7
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
8
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
9
  import { useRef, useState, useContext, useMemo, useCallback } from 'react';
5
10
  import { SortableHandle, SortableElement } from '@elliemae/react-sortable-hoc';
6
11
  import { aggregatedClasses } from '@elliemae/ds-classnames';
7
- import GripperVertical from '@elliemae/ds-icons/GripperVertical';
12
+ import { GripperVertical } from '@elliemae/ds-icons';
8
13
  import RadioSelectable from './RadioSelectable.js';
9
14
  import CheckboxSelectable from './CheckboxSelectable.js';
10
15
  import TreeViewContext from '../TreeViewContext.js';
@@ -25,20 +30,23 @@ const TreeListItem = aggregatedClasses('li', {
25
30
  role: 'treeitem'
26
31
  })(treeItemBlockName);
27
32
  const TreeListItemAddonsWrapper = aggregatedClasses('div')(treeItemBlockName, 'addons');
28
- const DnDHandle = SortableHandle(({
29
- id
30
- }) => /*#__PURE__*/_jsx(GripperVertical, {
31
- "data-testid": "drag-handle",
32
- className: "drag-handle",
33
- size: "s",
34
- onMouseDown: e => {
35
- // prevent focusing the drag-handle to avoid borders
36
- if (e) {
37
- e.preventDefault();
38
- }
39
- },
40
- tabIndex: "0"
41
- }, "".concat(id, "-drag-handle")));
33
+ const DnDHandle = SortableHandle(_ref => {
34
+ let {
35
+ id
36
+ } = _ref;
37
+ return /*#__PURE__*/_jsx(GripperVertical, {
38
+ "data-testid": "drag-handle",
39
+ className: "drag-handle",
40
+ size: "s",
41
+ onMouseDown: e => {
42
+ // prevent focusing the drag-handle to avoid borders
43
+ if (e) {
44
+ e.preventDefault();
45
+ }
46
+ },
47
+ tabIndex: "0"
48
+ }, "".concat(id, "-drag-handle"));
49
+ });
42
50
  const TreeItem = props => {
43
51
  const {
44
52
  item,
@@ -118,9 +126,12 @@ const TreeItem = props => {
118
126
  setSelectedItem(item);
119
127
  onItemFocus({
120
128
  itemIndex: item.virtualIndex,
121
- scrollToItem: (opts = {
122
- align: 'start'
123
- }) => scrollToIndex(item.virtualIndex, opts),
129
+ scrollToItem: function () {
130
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
131
+ align: 'start'
132
+ };
133
+ return scrollToIndex(item.virtualIndex, opts);
134
+ },
124
135
  item
125
136
  });
126
137
  }, [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem]);
@@ -1,7 +1,7 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import { useContext, useMemo } from 'react';
3
3
  import Highlighter from 'react-highlight-words';
4
- import { SimpleTruncatedTooltipText } from '@elliemae/ds-basic';
4
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
5
5
  import { aggregatedClasses } from '@elliemae/ds-classnames';
6
6
  import { ChildrenCountDisplayer } from './ChildrenCountDisplayer.js';
7
7
  import { treeItemBlockName, DSTreeViewPrefix } from '../config/cssClassesConstants.js';
@@ -14,12 +14,15 @@ const ItemValue = aggregatedClasses('span')(treeItemBlockName, 'value'); // cons
14
14
  const classNameModifierWrapAll = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "__value--wrap-all");
15
15
  const classNameModifierTruncate = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "__value--truncate"); // eslint-disable-next-line react/prop-types
16
16
 
17
- const CustomHighlight = ({
18
- children
19
- }) => /*#__PURE__*/_jsx("mark", {
20
- className: "tree-text-highlight",
21
- "data-testid": "tree-text-highlight"
22
- }, void 0, children);
17
+ const CustomHighlight = _ref => {
18
+ let {
19
+ children
20
+ } = _ref;
21
+ return /*#__PURE__*/_jsx("mark", {
22
+ className: "tree-text-highlight",
23
+ "data-testid": "tree-text-highlight"
24
+ }, void 0, children);
25
+ };
23
26
 
24
27
  function TreeItemText(props) {
25
28
  var _ChildrenCountDisplay, _ChildrenCountDisplay2, _ChildrenCountDisplay3, _ChildrenCountDisplay4;
@@ -1,9 +1,16 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
2
  import _jsx from '@babel/runtime/helpers/esm/jsx';
3
+ import 'core-js/modules/esnext.async-iterator.map.js';
4
+ import 'core-js/modules/esnext.iterator.map.js';
5
+ import 'core-js/modules/esnext.async-iterator.filter.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
9
+ import 'core-js/modules/esnext.iterator.for-each.js';
3
10
  import { useContext } from 'react';
4
11
  import { SortableContainer } from '@elliemae/react-sortable-hoc';
5
12
  import { aggregatedClasses } from '@elliemae/ds-classnames';
6
- import { DSCircularProgressIndicator } from '@elliemae/ds-basic/CircularProgressIndicator';
13
+ import { DSCircularProgressIndicator } from '@elliemae/ds-circular-progress-indicator';
7
14
  import TreeViewContext from '../TreeViewContext.js';
8
15
  import { DragAndDropTreeItem, TreeItem } from './TreeItem.js';
9
16
  import { treeListBlockName, DSTreeViewPrefix } from '../config/cssClassesConstants.js';
@@ -19,11 +26,14 @@ const TreeListNoItems = aggregatedClasses('div', {
19
26
  const TreeListWrapper = aggregatedClasses('ul', {
20
27
  'data-testid': treeListBlockName,
21
28
  role: 'tree'
22
- })(treeListBlockName, null, ({
23
- rowSize
24
- }) => ({
25
- ["rowsize-".concat(rowSize)]: rowSize
26
- }));
29
+ })(treeListBlockName, null, _ref => {
30
+ let {
31
+ rowSize
32
+ } = _ref;
33
+ return {
34
+ ["rowsize-".concat(rowSize)]: rowSize
35
+ };
36
+ });
27
37
  const compactRowClass = "".concat(DSTreeViewPrefix, "-tv-row-size-compact");
28
38
  const normaRowClass = "".concat(DSTreeViewPrefix, "-tv-row-size-normal");
29
39
  const TreeList = props => {
@@ -1,6 +1,6 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import 'react';
3
- import { DSNavSearchBox } from '@elliemae/ds-basic';
3
+ import { DSNavSearchBox } from '@elliemae/ds-form';
4
4
 
5
5
  function TreeViewSearchBar(props) {
6
6
  const {
@@ -8,13 +8,14 @@ const keyCodes = {
8
8
  up: [38, 37],
9
9
  down: [40, 39]
10
10
  };
11
- const sameParentAsHoverItemDrop = ({
12
- isBefore,
13
- isAfter,
14
- draggedItem,
15
- overItem,
16
- movementDirection
17
- }) => {
11
+ const sameParentAsHoverItemDrop = _ref => {
12
+ let {
13
+ isBefore,
14
+ isAfter,
15
+ draggedItem,
16
+ overItem,
17
+ movementDirection
18
+ } = _ref;
18
19
  const hoveredItemNodeNestedIndex = overItem.node.getIndex();
19
20
  let newParentNode = getItemsParentNode([overItem], true);
20
21
  const {
@@ -40,13 +41,14 @@ const sameParentAsHoverItemDrop = ({
40
41
  newParentNode
41
42
  };
42
43
  };
43
- const inferHoverItemKinshipDrop = ({
44
- isBefore,
45
- isAfter,
46
- draggedItem,
47
- overItem,
48
- movementDirection
49
- }) => {
44
+ const inferHoverItemKinshipDrop = _ref2 => {
45
+ let {
46
+ isBefore,
47
+ isAfter,
48
+ draggedItem,
49
+ overItem,
50
+ movementDirection
51
+ } = _ref2;
50
52
  const hoverItemModel = overItem.node.model;
51
53
  const isGroupAndIsExpanded = hoverItemModel.isExpanded && hoverItemModel.children.length > 0;
52
54
 
@@ -75,13 +77,14 @@ const inferHoverItemKinshipDrop = ({
75
77
  newParentNode: overItem.node
76
78
  };
77
79
  };
78
- const isDropValid = ({
79
- isBefore,
80
- isAfter,
81
- draggedItem,
82
- overItem,
83
- restrictDragAndDrop
84
- }) => {
80
+ const isDropValid = _ref3 => {
81
+ let {
82
+ isBefore,
83
+ isAfter,
84
+ draggedItem,
85
+ overItem,
86
+ restrictDragAndDrop
87
+ } = _ref3;
85
88
  const {
86
89
  id: movedId
87
90
  } = draggedItem;
@@ -105,11 +108,12 @@ const isDropValid = ({
105
108
 
106
109
  return true;
107
110
  };
108
- const inferKeyboardKinshipDrop = ({
109
- items,
110
- newIndex // movementDirection,
111
+ const inferKeyboardKinshipDrop = _ref4 => {
112
+ let {
113
+ items,
114
+ newIndex // movementDirection,
111
115
 
112
- }) => {
116
+ } = _ref4;
113
117
  const kinship = {}; // const directionOffset = movementDirection === 'topToBottom' ? 0 : 0;
114
118
 
115
119
  const itemBefore = items[newIndex];
@@ -1,7 +1,8 @@
1
1
  import { useCallback, useEffect } from 'react';
2
2
 
3
3
  /* eslint-disable max-params */
4
- const toggleItemExpand = (itemToToggle, triggerTreeRerender, scrollTo = () => {}) => {
4
+ const toggleItemExpand = function (itemToToggle, triggerTreeRerender) {
5
+ let scrollTo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
5
6
  const {
6
7
  node: {
7
8
  model: {
@@ -59,10 +60,11 @@ const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLates
59
60
  }
60
61
  setLatestToggledItem(null);
61
62
  };
62
- const useNotifyExpandedChange = (propsWithDefaults, {
63
- latestToggledItem,
64
- expandedGroups
65
- }) => {
63
+ const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
64
+ let {
65
+ latestToggledItem,
66
+ expandedGroups
67
+ } = _ref;
66
68
  const notifyExpandedChange = useCallback(expandedGroupHashmap => propsWithDefaults.onExpandChange(expandedGroupHashmap, latestToggledItem), [propsWithDefaults, latestToggledItem]);
67
69
  useEffect(() => {
68
70
  notifyExpandedChange(expandedGroups);
@@ -37,9 +37,12 @@ const useOnItemKeyDown = item => {
37
37
  } = item;
38
38
  const onItemFocusCurry = useCallback(newFocusItem => onItemFocus({
39
39
  itemIndex: newFocusItem.virtualIndex,
40
- scrollToItem: (opts = {
41
- align: 'start'
42
- }) => scrollToIndex(newFocusItem.virtualIndex, opts),
40
+ scrollToItem: function () {
41
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
42
+ align: 'start'
43
+ };
44
+ return scrollToIndex(newFocusItem.virtualIndex, opts);
45
+ },
43
46
  item: newFocusItem
44
47
  }), [onItemFocus]);
45
48
  const onItemKeyDown = useCallback(e => {
@@ -1,3 +1,11 @@
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
+ import 'core-js/modules/esnext.async-iterator.reduce.js';
5
+ import 'core-js/modules/esnext.iterator.reduce.js';
6
+ import 'core-js/modules/esnext.async-iterator.filter.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+
1
9
  /* eslint-disable no-sequences */
2
10
 
3
11
  /* eslint-disable no-return-assign */
@@ -1,5 +1,15 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+
1
7
  // allow multiple refs to be set to point to the same DOM element
2
- const setMultipleRefs = (...refs) => {
8
+ const setMultipleRefs = function () {
9
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ refs[_key] = arguments[_key];
11
+ }
12
+
3
13
  const filteredRefs = refs.filter(Boolean);
4
14
  if (!filteredRefs.length) return null;
5
15
  if (filteredRefs.length === 0) return filteredRefs[0];
@@ -1,3 +1,8 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
1
6
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
7
  import { walkAllNodeChildren, walkParents } from './tree-helpers.js';
3
8
 
@@ -19,7 +24,8 @@ const getGroupCheckState = node => {
19
24
  if (anyChildChecked) return 'mixed';
20
25
  return false;
21
26
  };
22
- const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerender = null) => {
27
+ const selectCheckboxItemModelParentsTillRoot = function (modelToCheck) {
28
+ let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
23
29
  const newSelections = {};
24
30
  const {
25
31
  nodePath
@@ -32,7 +38,8 @@ const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerende
32
38
  if (triggerTreeRerender) triggerTreeRerender();
33
39
  return newSelections;
34
40
  };
35
- const toggleCheckboxItem = (itemToSelect, triggerTreeRerender = null) => {
41
+ const toggleCheckboxItem = function (itemToSelect) {
42
+ let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
36
43
  const {
37
44
  node: {
38
45
  model: {
@@ -1,8 +1,17 @@
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.for-each.js';
1
4
  import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.find.js';
6
+ import 'core-js/modules/esnext.iterator.find.js';
7
+ import 'core-js/modules/esnext.async-iterator.every.js';
8
+ import 'core-js/modules/esnext.iterator.every.js';
2
9
  import { createRef } from 'react';
3
10
  import { standardizeSearchQueryString } from './string-helpers.js';
4
11
 
5
- const walkVisibles = (node, callback, skipRoot = true, highlightOnlyQuery = false) => {
12
+ const walkVisibles = function (node, callback) {
13
+ let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
14
+ let highlightOnlyQuery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
6
15
  const {
7
16
  children,
8
17
  model
@@ -24,7 +33,8 @@ const walkVisibles = (node, callback, skipRoot = true, highlightOnlyQuery = fals
24
33
  });
25
34
  }
26
35
  };
27
- const walkParents = (nodePath, callback, skipRoot = true) => {
36
+ const walkParents = function (nodePath, callback) {
37
+ let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
28
38
  const parents = [...nodePath].reverse();
29
39
  parents.shift(); // remove current node from the parents array
30
40
 
@@ -32,7 +42,8 @@ const walkParents = (nodePath, callback, skipRoot = true) => {
32
42
 
33
43
  parents.forEach(callback);
34
44
  };
35
- const walkAllNodeChildren = (node, callback, isFirst = true) => {
45
+ const walkAllNodeChildren = function (node, callback) {
46
+ let isFirst = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
36
47
  const {
37
48
  children = []
38
49
  } = node;
@@ -50,7 +61,9 @@ const getNodeById = (treeRoot, id) => {
50
61
  return nodes[0];
51
62
  };
52
63
  const cloneNode = (tree, node) => tree.parse(node.model);
53
- const getItemsParentNode = (items = [], skipSameParentCheck = false) => {
64
+ const getItemsParentNode = function () {
65
+ let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
66
+ let skipSameParentCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
54
67
  if (items.length === 0) throw new Error("Received empty items, can't retrieve parent"); // in case we already know the items compared shares the same parent
55
68
 
56
69
  if (!skipSameParentCheck) if (!itemsShareSameParent(items)) // if we don't know (default, we don't) check if they share the parent
@@ -67,7 +80,8 @@ const getItemsParentNode = (items = [], skipSameParentCheck = false) => {
67
80
  const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
68
81
  return directParentNode;
69
82
  };
70
- const itemsShareSameParent = (items = []) => {
83
+ const itemsShareSameParent = function () {
84
+ let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
71
85
  if (items.length === 0) throw new Error('Received empty items for comparison');
72
86
  if (items.length === 1) return true; // when moving in first position we receive [undefined,...{items}]
73
87
  // when moving in last position we receive [...{items}, undefined]
@@ -88,21 +102,25 @@ const itemsShareSameParent = (items = []) => {
88
102
  return directParentNode === itemDirectParent;
89
103
  });
90
104
  };
91
- const getNodeMatchesSearchQuery = (node, searchQuery = '') => {
105
+ const getNodeMatchesSearchQuery = function (node) {
106
+ let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
92
107
  const standardizedName = standardizeSearchQueryString(node.model.name);
93
108
  const standardizedSearchQuery = standardizeSearchQueryString(searchQuery);
94
109
  return standardizedName.includes(standardizedSearchQuery);
95
110
  };
96
- const getChildrenMatchesSearchQuery = (parentNode, searchQuery = '') => {
111
+ const getChildrenMatchesSearchQuery = function (parentNode) {
112
+ let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
97
113
  let anyChildMatch = false;
98
114
  walkAllNodeChildren(parentNode, node => {
99
115
  if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;
100
116
  });
101
117
  return anyChildMatch;
102
118
  };
103
- const enrichNodeModelInPlace = (node, searchQuery = '', selection = null) => {
119
+ const enrichNodeModelInPlace = function (node) {
104
120
  var _node$model, _node$model$children;
105
121
 
122
+ let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
123
+ let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
106
124
  const path = node.getPath();
107
125
  const depth = path.length - 1;
108
126
  node.model.nodePath = path;
@@ -1,3 +1,7 @@
1
+ import 'core-js/modules/esnext.async-iterator.constructor.js';
2
+ import 'core-js/modules/esnext.async-iterator.drop.js';
3
+ import 'core-js/modules/esnext.iterator.constructor.js';
4
+ import 'core-js/modules/esnext.iterator.drop.js';
1
5
  import 'core-js/modules/web.dom-collections.iterator.js';
2
6
  import { useContext, useCallback } from 'react';
3
7
  import { cloneDeep } from 'lodash';
@@ -27,11 +31,12 @@ const useDnDHelpers = () => {
27
31
  treeRoot,
28
32
  draggedItem
29
33
  } = ctx;
30
- const onSortEnd = useCallback(({
31
- oldIndex,
32
- newIndex,
33
- isKeySorting
34
- }) => {
34
+ const onSortEnd = useCallback(_ref => {
35
+ let {
36
+ oldIndex,
37
+ newIndex,
38
+ isKeySorting
39
+ } = _ref;
35
40
  let newItems = cloneDeep(data);
36
41
  const {
37
42
  isBefore,
@@ -126,13 +131,14 @@ const useDnDHelpers = () => {
126
131
  // at the top/center/bottom of an element to choose where to move the element
127
132
  // requested in the specs
128
133
 
129
- const onMouseDragOverItem = useCallback(({
130
- event,
131
- item,
132
- itemIndex,
133
- setIsDraggingOverThis,
134
- openFolderOnHoverTimeout
135
- }) => {
134
+ const onMouseDragOverItem = useCallback(_ref2 => {
135
+ let {
136
+ event,
137
+ item,
138
+ itemIndex,
139
+ setIsDraggingOverThis,
140
+ openFolderOnHoverTimeout
141
+ } = _ref2;
136
142
  const {
137
143
  node
138
144
  } = item;
@@ -3,9 +3,10 @@ import { useRef, useMemo, useState, useEffect, useCallback } from 'react';
3
3
  import { focusItem } from './tree-helpers.js';
4
4
  import { toggleExpandAllHelper } from './group-expands-helpers.js';
5
5
 
6
- const useInstanceRefActions = ({
7
- actions
8
- }, ctx) => {
6
+ const useInstanceRefActions = (_ref, ctx) => {
7
+ let {
8
+ actions
9
+ } = _ref;
9
10
  const {
10
11
  props: {
11
12
  onItemFocus
@@ -40,19 +41,21 @@ const useInstanceRefActions = ({
40
41
  setPromise(p);
41
42
  return p;
42
43
  }, [promises, treeRoot, triggerTreeRerender, setLatestToggledItem]);
43
- actions.scrollTo = useCallback((indx, opts = {
44
- align: 'start'
45
- }) => {
44
+ actions.scrollTo = useCallback(function (indx) {
45
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
46
+ align: 'start'
47
+ };
46
48
  if (scrollToIndex) scrollToIndex(indx, opts);
47
49
  }, [scrollToIndex]);
48
50
  actions.setSelectedItemByVirtualIndex = useCallback(index => {
49
51
  const itemByIndex = visibleItems[index];
50
52
  setSelectedItem(itemByIndex);
51
53
  }, [visibleItems, setSelectedItem]);
52
- actions.setFocusedItemByVirtualIndex = useCallback((index, opts = {
53
- align: 'start',
54
- withScroll: false
55
- }) => {
54
+ actions.setFocusedItemByVirtualIndex = useCallback(function (index) {
55
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
56
+ align: 'start',
57
+ withScroll: false
58
+ };
56
59
  const itemByIndex = visibleItems[index];
57
60
  const onItemFocusParams = {
58
61
  itemIndex: itemByIndex.virtualIndex,
@@ -1,3 +1,8 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
1
6
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
7
  import 'core-js/modules/web.dom-collections.iterator.js';
3
8
  import { useMemo, useState, useEffect, useCallback } from 'react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-treeview",
3
- "version": "2.0.0-next.7",
3
+ "version": "2.0.0-rc.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Tree View",
6
6
  "module": "./esm/index.js",
@@ -319,18 +319,19 @@
319
319
  "generateSubmodules": true
320
320
  },
321
321
  "dependencies": {
322
- "@elliemae/ds-basic": "2.0.0-next.7",
323
- "@elliemae/ds-classnames": "2.0.0-next.7",
324
- "@elliemae/ds-dropdownmenu": "2.0.0-next.7",
325
- "@elliemae/ds-icons": "2.0.0-next.7",
326
- "@elliemae/ds-shared": "2.0.0-next.7",
327
- "@elliemae/ds-utilities": "2.0.0-next.7",
322
+ "@elliemae/ds-basic": "2.0.0-rc.2",
323
+ "@elliemae/ds-classnames": "2.0.0-rc.2",
324
+ "@elliemae/ds-dropdownmenu": "2.0.0-rc.2",
325
+ "@elliemae/ds-icons": "2.0.0-rc.2",
326
+ "@elliemae/ds-shared": "2.0.0-rc.2",
327
+ "@elliemae/ds-utilities": "2.0.0-rc.2",
328
328
  "@elliemae/react-sortable-hoc": "^1.0.0",
329
329
  "@john-osullivan/react-window-dynamic-fork": "1.9.0-alpha.1",
330
330
  "prop-types": "~15.7.2",
331
331
  "react-beautiful-dnd": "~13.0.0",
332
+ "react-desc": "~4.1.3",
332
333
  "react-highlight-words": "~0.17.0",
333
- "react-virtual": "^2.3.2",
334
+ "react-virtual": "~2.3.2",
334
335
  "react-virtualized-auto-sizer": "~1.0.6",
335
336
  "react-window": "~1.8.6",
336
337
  "resize-observer-polyfill": "~1.5.1",
@@ -339,12 +340,12 @@
339
340
  "uuid": "~8.3.2"
340
341
  },
341
342
  "devDependencies": {
342
- "styled-components": "~5.3.1"
343
+ "styled-components": "~5.3.3"
343
344
  },
344
345
  "peerDependencies": {
345
346
  "lodash": "^4.17.21",
346
347
  "react": "~17.0.2",
347
348
  "react-dom": "^17.0.2",
348
- "styled-components": "^5.3.1"
349
+ "styled-components": "^5.3.3"
349
350
  }
350
351
  }
@@ -1,4 +1,14 @@
1
1
  export declare const useExpandTreeState: (instance: any) => {
2
- state: any;
3
- actions: any;
2
+ state: {
3
+ expandedAll: boolean;
4
+ expanded: any;
5
+ isExpandedAll: boolean;
6
+ };
7
+ actions: {
8
+ toggleExpandAll: (expanded: any) => Promise<any>;
9
+ toggleExpand: (item: any, opts: any) => void;
10
+ _toggleExpand: (item: any, opts: any) => void;
11
+ expand: (item: any, stateData?: boolean | undefined) => void;
12
+ collapse: (item: any) => void;
13
+ };
4
14
  };