@elliemae/ds-treeview 2.2.0-alpha.4 → 3.0.0-next.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 (206) hide show
  1. package/cjs/TreeView.js +27 -49
  2. package/cjs/TreeViewContext.js +37 -61
  3. package/cjs/config/cssClassesConstants.js +13 -41
  4. package/cjs/config/useTreeview.js +78 -116
  5. package/cjs/hoc/DnDTreeContext.js +18 -0
  6. package/cjs/hoc/SortableItemContext.js +21 -0
  7. package/cjs/hoc/WithConditionalDnDContext.js +138 -0
  8. package/cjs/hoc/WithDnDSortableItemContext.js +70 -0
  9. package/cjs/index.js +26 -37
  10. package/cjs/parts/CheckboxSelectable.js +59 -70
  11. package/cjs/parts/ChildrenCountDisplayer.js +28 -45
  12. package/cjs/parts/DnDHandle.js +46 -0
  13. package/cjs/parts/DropIndicator.js +75 -0
  14. package/cjs/parts/ExpandCaret.js +83 -85
  15. package/cjs/parts/Icon.js +31 -46
  16. package/cjs/parts/NestingSpace.js +35 -43
  17. package/cjs/parts/RadioSelectable.js +37 -52
  18. package/cjs/parts/TreeItem.js +141 -147
  19. package/cjs/parts/TreeItemText.js +95 -88
  20. package/cjs/parts/TreeList.js +130 -119
  21. package/cjs/plugins/dnd/TreeDndPlugin.js +7 -59
  22. package/cjs/plugins/dnd/index.js +9 -28
  23. package/cjs/plugins/index.js +21 -34
  24. package/cjs/plugins/roving/TreeRovingPlugin.js +7 -35
  25. package/cjs/plugins/roving/index.js +9 -28
  26. package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -35
  27. package/cjs/plugins/searchable/index.js +9 -28
  28. package/cjs/plugins/selectable/SelectablePluginTree.js +7 -35
  29. package/cjs/plugins/selectable/index.js +9 -28
  30. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -35
  31. package/cjs/plugins/toolbar/index.js +9 -28
  32. package/cjs/plugins/tree/TreeDataPlugin.js +7 -35
  33. package/cjs/plugins/tree/index.js +9 -28
  34. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -35
  35. package/cjs/plugins/virtualization/index.js +9 -28
  36. package/cjs/react-desc-prop-types.js +54 -82
  37. package/cjs/related-components/TreeViewSearchBar.js +40 -42
  38. package/cjs/sharedTypes.js +2 -27
  39. package/cjs/utils/array-helpers.js +11 -35
  40. package/cjs/utils/group-expands-helpers.js +59 -86
  41. package/cjs/utils/keyboard-helpers.js +90 -85
  42. package/cjs/utils/object-helpers.js +36 -43
  43. package/cjs/utils/refs-helpers.js +22 -43
  44. package/cjs/utils/selectable-helper.js +53 -61
  45. package/cjs/utils/string-helpers.js +7 -35
  46. package/cjs/utils/tree-helpers.js +161 -105
  47. package/cjs/utils/useInstanceRefActions.js +43 -54
  48. package/cjs/utils/useTree.js +80 -76
  49. package/esm/TreeView.js +16 -18
  50. package/esm/TreeViewContext.js +31 -32
  51. package/esm/config/cssClassesConstants.js +6 -12
  52. package/esm/config/useTreeview.js +56 -73
  53. package/esm/hoc/DnDTreeContext.js +14 -0
  54. package/esm/hoc/SortableItemContext.js +17 -0
  55. package/esm/hoc/WithConditionalDnDContext.js +128 -0
  56. package/esm/hoc/WithDnDSortableItemContext.js +61 -0
  57. package/esm/index.js +9 -8
  58. package/esm/parts/CheckboxSelectable.js +46 -36
  59. package/esm/parts/ChildrenCountDisplayer.js +20 -16
  60. package/esm/parts/DnDHandle.js +38 -0
  61. package/esm/parts/DropIndicator.js +68 -0
  62. package/esm/parts/ExpandCaret.js +72 -54
  63. package/esm/parts/Icon.js +22 -16
  64. package/esm/parts/NestingSpace.js +27 -14
  65. package/esm/parts/RadioSelectable.js +28 -20
  66. package/esm/parts/TreeItem.js +125 -114
  67. package/esm/parts/TreeItemText.js +85 -58
  68. package/esm/parts/TreeList.js +119 -91
  69. package/esm/plugins/dnd/TreeDndPlugin.js +3 -30
  70. package/esm/plugins/dnd/index.js +1 -3
  71. package/esm/plugins/index.js +7 -9
  72. package/esm/plugins/roving/TreeRovingPlugin.js +3 -6
  73. package/esm/plugins/roving/index.js +1 -3
  74. package/esm/plugins/searchable/SearchableTreePlugin.js +3 -6
  75. package/esm/plugins/searchable/index.js +1 -3
  76. package/esm/plugins/selectable/SelectablePluginTree.js +3 -6
  77. package/esm/plugins/selectable/index.js +1 -3
  78. package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -6
  79. package/esm/plugins/toolbar/index.js +1 -3
  80. package/esm/plugins/tree/TreeDataPlugin.js +3 -6
  81. package/esm/plugins/tree/index.js +1 -3
  82. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -6
  83. package/esm/plugins/virtualization/index.js +1 -3
  84. package/esm/react-desc-prop-types.js +44 -47
  85. package/esm/related-components/TreeViewSearchBar.js +32 -13
  86. package/esm/sharedTypes.js +1 -2
  87. package/esm/utils/array-helpers.js +6 -6
  88. package/esm/utils/group-expands-helpers.js +46 -56
  89. package/esm/utils/keyboard-helpers.js +74 -46
  90. package/esm/utils/object-helpers.js +31 -14
  91. package/esm/utils/refs-helpers.js +19 -15
  92. package/esm/utils/selectable-helper.js +43 -32
  93. package/esm/utils/string-helpers.js +3 -6
  94. package/esm/utils/tree-helpers.js +143 -73
  95. package/esm/utils/useInstanceRefActions.js +35 -21
  96. package/esm/utils/useTree.js +59 -35
  97. package/package.json +35 -19
  98. package/types/hoc/DnDTreeContext.d.ts +14 -0
  99. package/types/hoc/SortableItemContext.d.ts +19 -0
  100. package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
  101. package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
  102. package/types/parts/DnDHandle.d.ts +6 -0
  103. package/types/parts/DropIndicator.d.ts +10 -0
  104. package/types/parts/TreeItem.d.ts +4 -11
  105. package/types/parts/TreeList.d.ts +0 -4
  106. package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
  107. package/types/react-desc-prop-types.d.ts +17 -3
  108. package/types/sharedTypes.d.ts +1 -8
  109. package/types/utils/keyboard-helpers.d.ts +2 -1
  110. package/types/utils/refs-helpers.d.ts +1 -1
  111. package/types/utils/tree-helpers.d.ts +4 -1
  112. package/types/utils/useTree.d.ts +1 -0
  113. package/cjs/TreeView.js.map +0 -7
  114. package/cjs/TreeViewContext.js.map +0 -7
  115. package/cjs/config/cssClassesConstants.js.map +0 -7
  116. package/cjs/config/useTreeview.js.map +0 -7
  117. package/cjs/index.js.map +0 -7
  118. package/cjs/parts/CheckboxSelectable.js.map +0 -7
  119. package/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
  120. package/cjs/parts/ExpandCaret.js.map +0 -7
  121. package/cjs/parts/Icon.js.map +0 -7
  122. package/cjs/parts/NestingSpace.js.map +0 -7
  123. package/cjs/parts/RadioSelectable.js.map +0 -7
  124. package/cjs/parts/TreeItem.js.map +0 -7
  125. package/cjs/parts/TreeItemText.js.map +0 -7
  126. package/cjs/parts/TreeList.js.map +0 -7
  127. package/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
  128. package/cjs/plugins/dnd/index.js.map +0 -7
  129. package/cjs/plugins/index.js.map +0 -7
  130. package/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
  131. package/cjs/plugins/roving/index.js.map +0 -7
  132. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  133. package/cjs/plugins/searchable/index.js.map +0 -7
  134. package/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
  135. package/cjs/plugins/selectable/index.js.map +0 -7
  136. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  137. package/cjs/plugins/toolbar/index.js.map +0 -7
  138. package/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
  139. package/cjs/plugins/tree/index.js.map +0 -7
  140. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  141. package/cjs/plugins/virtualization/index.js.map +0 -7
  142. package/cjs/react-desc-prop-types.js.map +0 -7
  143. package/cjs/related-components/TreeViewSearchBar.js.map +0 -7
  144. package/cjs/sharedTypes.js.map +0 -7
  145. package/cjs/utils/array-helpers.js.map +0 -7
  146. package/cjs/utils/dnd-helpers.js +0 -146
  147. package/cjs/utils/dnd-helpers.js.map +0 -7
  148. package/cjs/utils/group-expands-helpers.js.map +0 -7
  149. package/cjs/utils/keyboard-helpers.js.map +0 -7
  150. package/cjs/utils/object-helpers.js.map +0 -7
  151. package/cjs/utils/refs-helpers.js.map +0 -7
  152. package/cjs/utils/selectable-helper.js.map +0 -7
  153. package/cjs/utils/string-helpers.js.map +0 -7
  154. package/cjs/utils/tree-helpers.js.map +0 -7
  155. package/cjs/utils/useDnDHelpers.js +0 -199
  156. package/cjs/utils/useDnDHelpers.js.map +0 -7
  157. package/cjs/utils/useInstanceRefActions.js.map +0 -7
  158. package/cjs/utils/useTree.js.map +0 -7
  159. package/esm/TreeView.js.map +0 -7
  160. package/esm/TreeViewContext.js.map +0 -7
  161. package/esm/config/cssClassesConstants.js.map +0 -7
  162. package/esm/config/useTreeview.js.map +0 -7
  163. package/esm/index.js.map +0 -7
  164. package/esm/parts/CheckboxSelectable.js.map +0 -7
  165. package/esm/parts/ChildrenCountDisplayer.js.map +0 -7
  166. package/esm/parts/ExpandCaret.js.map +0 -7
  167. package/esm/parts/Icon.js.map +0 -7
  168. package/esm/parts/NestingSpace.js.map +0 -7
  169. package/esm/parts/RadioSelectable.js.map +0 -7
  170. package/esm/parts/TreeItem.js.map +0 -7
  171. package/esm/parts/TreeItemText.js.map +0 -7
  172. package/esm/parts/TreeList.js.map +0 -7
  173. package/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
  174. package/esm/plugins/dnd/index.js.map +0 -7
  175. package/esm/plugins/index.js.map +0 -7
  176. package/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
  177. package/esm/plugins/roving/index.js.map +0 -7
  178. package/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  179. package/esm/plugins/searchable/index.js.map +0 -7
  180. package/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
  181. package/esm/plugins/selectable/index.js.map +0 -7
  182. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  183. package/esm/plugins/toolbar/index.js.map +0 -7
  184. package/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
  185. package/esm/plugins/tree/index.js.map +0 -7
  186. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  187. package/esm/plugins/virtualization/index.js.map +0 -7
  188. package/esm/react-desc-prop-types.js.map +0 -7
  189. package/esm/related-components/TreeViewSearchBar.js.map +0 -7
  190. package/esm/sharedTypes.js.map +0 -7
  191. package/esm/utils/array-helpers.js.map +0 -7
  192. package/esm/utils/dnd-helpers.js +0 -117
  193. package/esm/utils/dnd-helpers.js.map +0 -7
  194. package/esm/utils/group-expands-helpers.js.map +0 -7
  195. package/esm/utils/keyboard-helpers.js.map +0 -7
  196. package/esm/utils/object-helpers.js.map +0 -7
  197. package/esm/utils/refs-helpers.js.map +0 -7
  198. package/esm/utils/selectable-helper.js.map +0 -7
  199. package/esm/utils/string-helpers.js.map +0 -7
  200. package/esm/utils/tree-helpers.js.map +0 -7
  201. package/esm/utils/useDnDHelpers.js +0 -170
  202. package/esm/utils/useDnDHelpers.js.map +0 -7
  203. package/esm/utils/useInstanceRefActions.js.map +0 -7
  204. package/esm/utils/useTree.js.map +0 -7
  205. package/types/utils/dnd-helpers.d.ts +0 -39
  206. package/types/utils/useDnDHelpers.d.ts +0 -26
@@ -1,123 +1,133 @@
1
- import * as React from "react";
2
- import React2, { useContext, useState, useMemo, useRef, useCallback } from "react";
3
- import { SortableElement, SortableHandle } from "@elliemae/react-sortable-hoc";
4
- import { aggregatedClasses } from "@elliemae/ds-classnames";
5
- import { GripperVertical } from "@elliemae/ds-icons";
6
- import RadioSelectable from "./RadioSelectable";
7
- import CheckboxSelectable from "./CheckboxSelectable";
8
- import TreeViewContext from "../TreeViewContext";
9
- import { setMultipleRefs } from "../utils/refs-helpers";
10
- import { useOnItemKeyDown } from "../utils/keyboard-helpers";
11
- import { NestingSpace } from "./NestingSpace";
12
- import { Icon } from "./Icon";
13
- import { ExpandCaret } from "./ExpandCaret";
14
- import { TreeItemText } from "./TreeItemText";
15
- import { DSTreeViewPrefix, treeItemBlockName } from "../config/cssClassesConstants";
16
- const TreeListItem = aggregatedClasses("li", {
17
- "data-testid": treeItemBlockName,
18
- role: "treeitem"
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
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
7
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
+ import { useContext, useMemo, useCallback } from 'react';
9
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
10
+ import RadioSelectable from './RadioSelectable.js';
11
+ import CheckboxSelectable from './CheckboxSelectable.js';
12
+ import TreeViewContext from '../TreeViewContext.js';
13
+ import { setMultipleRefs } from '../utils/refs-helpers.js';
14
+ import { useOnItemKeyDown } from '../utils/keyboard-helpers.js';
15
+ import { NestingSpace } from './NestingSpace.js';
16
+ import { Icon } from './Icon.js';
17
+ import { ExpandCaret } from './ExpandCaret.js';
18
+ import { TreeItemText } from './TreeItemText.js';
19
+ import { treeItemBlockName, DSTreeViewPrefix } from '../config/cssClassesConstants.js';
20
+ import { DnDHandle } from './DnDHandle.js';
21
+ import { withDnDSortableItemContext } from '../hoc/WithDnDSortableItemContext.js';
22
+ import { SortableItemContext, DropIndicatorPosition } from '../hoc/SortableItemContext.js';
23
+ import DropIndicator from './DropIndicator.js';
24
+ import { jsxs } from 'react/jsx-runtime';
25
+
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
+
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
+ const TreeListItem = aggregatedClasses('li', {
30
+ 'data-testid': treeItemBlockName,
31
+ role: 'treeitem' // temp fix untill we move to styled components
32
+
19
33
  })(treeItemBlockName);
20
- const TreeListItemAddonsWrapper = aggregatedClasses("div")(treeItemBlockName, "addons");
21
- const DnDHandle = SortableHandle(({ id }) => /* @__PURE__ */ React2.createElement(GripperVertical, {
22
- "data-testid": "drag-handle",
23
- key: `${id}-drag-handle`,
24
- className: "drag-handle",
25
- size: "s",
26
- onMouseDown: (e) => {
27
- if (e) {
28
- e.preventDefault();
29
- }
30
- },
31
- tabIndex: "0"
32
- }));
33
- const TreeItem = (props) => {
34
+ const TreeListItemAddonsWrapper = aggregatedClasses('div')(treeItemBlockName, 'addons' // temp fix untill we move to styled components
35
+ );
36
+ const TreeItem = props => {
34
37
  const {
35
38
  item,
36
39
  itemIndex,
37
40
  itemWrapperStyle = {},
38
41
  virtualItemRef,
39
42
  spaceForNestingLevel = 1.5,
40
- onMouseDragOverItem
43
+ isDragOverlay = false
41
44
  } = props;
42
- const { id, node } = item;
43
- const { nodeItemRef } = node.model;
44
- const openFolderOnHoverTimeout = useRef(null);
45
- const [isDraggingOverThis, setIsDraggingOverThis] = useState(false);
46
- const onItemKeyDown = useOnItemKeyDown(item);
45
+ const {
46
+ id,
47
+ node
48
+ } = item;
49
+ const {
50
+ nodeItemRef
51
+ } = node.model;
52
+ const {
53
+ draggableProps
54
+ } = useContext(SortableItemContext);
55
+ const onItemKeyDown = useOnItemKeyDown(item, draggableProps);
47
56
  const ctx = useContext(TreeViewContext);
48
57
  const {
49
- props: { disableIcons, rightAddons, onItemClick, onItemFocus, rowSize, labelOverflow },
50
- relativeMouseCord,
58
+ props: {
59
+ disableIcons,
60
+ rightAddons,
61
+ onItemClick,
62
+ onItemFocus,
63
+ rowSize,
64
+ labelOverflow
65
+ },
51
66
  withRadioChecks,
52
67
  withCheckboxChecks,
53
68
  withDragAndDrop,
54
69
  selectedItem,
55
70
  selectedCheckboxes,
56
71
  hoverItem,
57
- isDragging,
58
- virtualListHelpers: { scrollToIndex },
72
+ virtualListHelpers: {
73
+ scrollToIndex
74
+ },
59
75
  setHoverItem,
60
76
  setSelectedItem,
61
77
  setFocusedItem
62
- } = ctx;
63
- const setItemRefs = (ref) => {
64
- setMultipleRefs(virtualItemRef, nodeItemRef)(ref);
78
+ } = ctx; // Sortable Items needs to update
79
+ // - the virtual list ref (for react-virtual requirement)
80
+ // - nodeItemRef which is a prop avaiable in the TreeModel nodes
81
+ // - the drag and drop node reference
82
+
83
+ const setItemRefs = ref => {
84
+ setMultipleRefs(virtualItemRef, !isDragOverlay && nodeItemRef, !isDragOverlay && draggableProps && draggableProps.setNodeRef)(ref);
65
85
  };
86
+
87
+ const dropIndicatorPosition = draggableProps && draggableProps.shouldShowDropIndicatorPosition && draggableProps.dropIndicatorPosition;
88
+ const isDropIndicatorPositionInside = dropIndicatorPosition === DropIndicatorPosition.Inside;
89
+ const isDragging = draggableProps && draggableProps.isDragging;
90
+ const isDropValid = draggableProps && draggableProps.isDropValid;
66
91
  const dropPreviewClassName = useMemo(() => {
67
- if (!withDragAndDrop || !relativeMouseCord || !isDraggingOverThis)
68
- return "";
69
- const { isBefore, isAfter, isValid } = relativeMouseCord;
70
- let className = `${DSTreeViewPrefix}-${treeItemBlockName}${isValid ? "--valid" : "--invalid"}`;
71
- if (isBefore)
72
- className += "-drop-before";
73
- else if (isAfter)
74
- className += "-drop-after";
75
- else
76
- className += "-drop-in";
77
- return className;
78
- }, [withDragAndDrop, relativeMouseCord, isDraggingOverThis]);
79
- const selectedClassName = useMemo(() => selectedItem?.id === item.id ? "selected" : "", [item.id, selectedItem?.id]);
80
- const hoverClassName = useMemo(() => hoverItem?.id !== item.id || withDragAndDrop && isDragging ? "" : "hover", [hoverItem?.id, item.id, withDragAndDrop, isDragging]);
92
+ if (isDropIndicatorPositionInside) {
93
+ const className = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName).concat(isDropValid ? '--valid' : '--invalid', "-drop-in");
94
+ return className;
95
+ }
96
+
97
+ return '';
98
+ }, [isDropIndicatorPositionInside, isDropValid]);
99
+ const dragOverlayClassName = useMemo(() => isDragOverlay ? 'drag-overlay' : '', [isDragOverlay]);
100
+ const selectedClassName = useMemo(() => (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id) === item.id && !isDragOverlay ? 'selected' : '', [isDragOverlay, item.id, selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id]);
101
+ const hoverClassName = useMemo(() => !isDragOverlay && ((hoverItem === null || hoverItem === void 0 ? void 0 : hoverItem.id) === item.id || isDragging) ? 'hover' : '', [isDragOverlay, hoverItem === null || hoverItem === void 0 ? void 0 : hoverItem.id, item.id, isDragging]);
81
102
  const fixedHeightClassname = useMemo(() => {
82
- if (labelOverflow === "truncate") {
83
- if (rowSize === "compact")
84
- return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height-compact`;
85
- return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height`;
103
+ if (labelOverflow === 'truncate') {
104
+ if (rowSize === 'compact') return "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "--fixed-height-compact");
105
+ return "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "--fixed-height");
86
106
  }
87
- return "";
107
+
108
+ return '';
88
109
  }, [labelOverflow, rowSize]);
89
- const finalClassName = useMemo(() => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName}`, [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname]);
90
- const handleItemClick = useCallback((e) => {
110
+ const finalClassName = useMemo(() => "".concat(dropPreviewClassName, " ").concat(fixedHeightClassname, " ").concat(selectedClassName, " ").concat(hoverClassName, " ").concat(dragOverlayClassName), [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname, dragOverlayClassName]);
111
+ const handleItemClick = useCallback(e => {
91
112
  onItemClick(item, e);
92
113
  setFocusedItem(item);
93
114
  setSelectedItem(item);
94
- const itemVirtualIndex = typeof item.virtualIndex === "number" ? item.virtualIndex : -1;
115
+ const itemVirtualIndex = typeof item.virtualIndex === 'number' ? item.virtualIndex : -1;
95
116
  onItemFocus({
96
117
  itemIndex: itemVirtualIndex,
97
- scrollToItem: (opts = { align: "start" }) => scrollToIndex(itemVirtualIndex, opts),
118
+ scrollToItem: function () {
119
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
120
+ align: 'start'
121
+ };
122
+ return scrollToIndex(itemVirtualIndex, opts);
123
+ },
98
124
  item
99
125
  });
100
126
  }, [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem]);
101
- return /* @__PURE__ */ React2.createElement(TreeListItem, {
127
+ return /*#__PURE__*/jsxs(TreeListItem, {
102
128
  tabIndex: 0,
103
- onMouseMove: (event) => {
104
- if (withDragAndDrop && onMouseDragOverItem) {
105
- onMouseDragOverItem({
106
- event,
107
- item,
108
- itemIndex,
109
- setIsDraggingOverThis,
110
- openFolderOnHoverTimeout
111
- });
112
- }
113
- },
114
129
  onMouseLeave: () => {
115
- if (withDragAndDrop) {
116
- setIsDraggingOverThis(false);
117
- if (openFolderOnHoverTimeout?.current)
118
- clearTimeout(openFolderOnHoverTimeout.current);
119
- }
120
- if (hoverItem?.id === item.id) {
130
+ if ((hoverItem === null || hoverItem === void 0 ? void 0 : hoverItem.id) === item.id) {
121
131
  setHoverItem(null);
122
132
  }
123
133
  },
@@ -125,38 +135,39 @@ const TreeItem = (props) => {
125
135
  setHoverItem(item);
126
136
  },
127
137
  onClick: handleItemClick,
138
+ onBlur: () => setFocusedItem(null),
128
139
  ref: setItemRefs,
129
- style: { ...itemWrapperStyle },
140
+ style: _objectSpread({}, itemWrapperStyle),
130
141
  className: finalClassName,
131
142
  "aria-expanded": !!item.isExpanded,
132
143
  "aria-selected": !!selectedCheckboxes[item.id],
133
144
  "data-id": item.id,
134
145
  "data-index": item.virtualIndex,
135
- onKeyDown: onItemKeyDown
136
- }, /* @__PURE__ */ React2.createElement(TreeListItemAddonsWrapper, null, withDragAndDrop ? /* @__PURE__ */ React2.createElement(DnDHandle, {
137
- id
138
- }) : null, withRadioChecks ? /* @__PURE__ */ React2.createElement(RadioSelectable, {
139
- item,
140
- itemIndex
141
- }) : null, withCheckboxChecks ? /* @__PURE__ */ React2.createElement(CheckboxSelectable, {
142
- item,
143
- itemIndex
144
- }) : null, /* @__PURE__ */ React2.createElement(NestingSpace, {
145
- item,
146
- spaceForNestingLevel
147
- }), /* @__PURE__ */ React2.createElement(ExpandCaret, {
148
- item
149
- }), !disableIcons ? /* @__PURE__ */ React2.createElement(Icon, {
150
- item
151
- }) : null), /* @__PURE__ */ React2.createElement(TreeItemText, {
152
- item
153
- }), rightAddons && /* @__PURE__ */ React2.createElement(TreeListItemAddonsWrapper, null, typeof rightAddons === "function" ? rightAddons(item) : rightAddons));
154
- };
155
- const DragAndDropTreeItem = SortableElement(TreeItem);
156
- export {
157
- DragAndDropTreeItem,
158
- TreeItem,
159
- TreeListItem,
160
- TreeListItemAddonsWrapper
146
+ onKeyDown: onItemKeyDown,
147
+ children: [/*#__PURE__*/_jsx(TreeListItemAddonsWrapper, {}, void 0, withDragAndDrop ? /*#__PURE__*/_jsx(DnDHandle, {
148
+ id: id,
149
+ isDragOverlay: isDragOverlay
150
+ }) : null, withRadioChecks && !isDragOverlay ? /*#__PURE__*/_jsx(RadioSelectable, {
151
+ item: item,
152
+ itemIndex: itemIndex
153
+ }) : null, withCheckboxChecks && !isDragOverlay ? /*#__PURE__*/_jsx(CheckboxSelectable, {
154
+ item: item,
155
+ itemIndex: itemIndex
156
+ }) : null, !isDragOverlay && /*#__PURE__*/_jsx(NestingSpace, {
157
+ item: item,
158
+ spaceForNestingLevel: spaceForNestingLevel
159
+ }), !isDragOverlay && /*#__PURE__*/_jsx(ExpandCaret, {
160
+ item: item
161
+ }), !disableIcons ? /*#__PURE__*/_jsx(Icon, {
162
+ item: item
163
+ }) : null), /*#__PURE__*/_jsx(TreeItemText, {
164
+ item: item
165
+ }), rightAddons && /*#__PURE__*/_jsx(TreeListItemAddonsWrapper, {}, void 0, typeof rightAddons === 'function' ? rightAddons(item) : rightAddons), /*#__PURE__*/_jsx(DropIndicator, {
166
+ dropIndicatorPosition: dropIndicatorPosition,
167
+ isDropValid: isDropValid
168
+ })]
169
+ });
161
170
  };
162
- //# sourceMappingURL=TreeItem.js.map
171
+ var TreeItem$1 = withDnDSortableItemContext(TreeItem);
172
+
173
+ export { TreeItem, TreeListItem, TreeListItemAddonsWrapper, TreeItem$1 as default };
@@ -1,72 +1,99 @@
1
- import * as React from "react";
2
- import React2, { useMemo, useContext } from "react";
3
- import Highlighter from "react-highlight-words";
4
- import { SimpleTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
5
- import { aggregatedClasses } from "@elliemae/ds-classnames";
6
- import { ChildrenCountDisplayer } from "./ChildrenCountDisplayer";
7
- import { DSTreeViewPrefix, treeItemBlockName } from "../config/cssClassesConstants";
8
- import TreeViewContext from "../TreeViewContext";
9
- const ItemContent = aggregatedClasses("div")(`${treeItemBlockName}-content`);
10
- const ItemValue = aggregatedClasses("span")(treeItemBlockName, "value");
11
- const classNameModifierWrapAll = `${DSTreeViewPrefix}-${treeItemBlockName}__value--wrap-all`;
12
- const classNameModifierTruncate = `${DSTreeViewPrefix}-${treeItemBlockName}__value--truncate`;
13
- const CustomHighlight = ({ children }) => /* @__PURE__ */ React2.createElement("mark", {
14
- className: "tree-text-highlight",
15
- "data-testid": "tree-text-highlight"
16
- }, children);
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext, useMemo } from 'react';
3
+ import Highlighter from 'react-highlight-words';
4
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
5
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
6
+ import { ChildrenCountDisplayer } from './ChildrenCountDisplayer.js';
7
+ import { treeItemBlockName, DSTreeViewPrefix } from '../config/cssClassesConstants.js';
8
+ import TreeViewContext from '../TreeViewContext.js';
9
+ import { jsxs, Fragment } from 'react/jsx-runtime';
10
+
11
+ const ItemContent = aggregatedClasses('div')("".concat(treeItemBlockName, "-content"));
12
+ const ItemValue = aggregatedClasses('span')(treeItemBlockName, 'value'); // const wrapperClassName = `${DSTreeViewPrefix}-${treeItemBlockName}-content`;
13
+
14
+ const classNameModifierWrapAll = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "__value--wrap-all");
15
+ const classNameModifierTruncate = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "__value--truncate"); // eslint-disable-next-line react/prop-types
16
+
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
+ };
26
+
17
27
  function TreeItemText(props) {
18
- const { item } = props;
28
+ var _ChildrenCountDisplay, _ChildrenCountDisplay2, _ChildrenCountDisplay3, _ChildrenCountDisplay4;
29
+
30
+ const {
31
+ item
32
+ } = props;
19
33
  const ctx = useContext(TreeViewContext);
20
34
  const {
21
- props: { searchQuery, showChildrenAmount, labelOverflow, nameKey }
35
+ props: {
36
+ searchQuery,
37
+ showChildrenAmount,
38
+ labelOverflow,
39
+ nameKey
40
+ }
22
41
  } = ctx;
23
42
  const Text = useMemo(() => {
24
43
  const itemLabelText = item[nameKey];
44
+
25
45
  if (searchQuery) {
26
- if (labelOverflow === "truncate") {
27
- return /* @__PURE__ */ React2.createElement(SimpleTruncatedTooltipText, {
28
- value: /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Highlighter, {
29
- autoEscape: true,
30
- highlightTag: CustomHighlight,
31
- searchWords: [searchQuery],
32
- textToHighlight: itemLabelText
33
- }), showChildrenAmount ? /* @__PURE__ */ React2.createElement(ChildrenCountDisplayer, {
34
- item
35
- }) : null)
46
+ if (labelOverflow === 'truncate') {
47
+ return /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
48
+ value: /*#__PURE__*/jsxs(Fragment, {
49
+ children: [/*#__PURE__*/_jsx(Highlighter, {
50
+ autoEscape: true,
51
+ highlightTag: CustomHighlight,
52
+ searchWords: [searchQuery],
53
+ textToHighlight: itemLabelText
54
+ }), showChildrenAmount ? _ChildrenCountDisplay || (_ChildrenCountDisplay = /*#__PURE__*/_jsx(ChildrenCountDisplayer, {
55
+ item: item
56
+ })) : null]
57
+ })
36
58
  });
37
59
  }
38
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Highlighter, {
39
- autoEscape: true,
40
- highlightTag: CustomHighlight,
41
- searchWords: [searchQuery],
42
- textToHighlight: itemLabelText
43
- }), showChildrenAmount ? /* @__PURE__ */ React2.createElement(ChildrenCountDisplayer, {
44
- item
45
- }) : null);
60
+
61
+ return /*#__PURE__*/jsxs(Fragment, {
62
+ children: [/*#__PURE__*/_jsx(Highlighter, {
63
+ autoEscape: true,
64
+ highlightTag: CustomHighlight,
65
+ searchWords: [searchQuery],
66
+ textToHighlight: itemLabelText
67
+ }), showChildrenAmount ? _ChildrenCountDisplay2 || (_ChildrenCountDisplay2 = /*#__PURE__*/_jsx(ChildrenCountDisplayer, {
68
+ item: item
69
+ })) : null]
70
+ });
46
71
  }
47
- if (labelOverflow === "truncate") {
48
- return /* @__PURE__ */ React2.createElement(SimpleTruncatedTooltipText, {
49
- value: /* @__PURE__ */ React2.createElement(React2.Fragment, null, itemLabelText, showChildrenAmount ? /* @__PURE__ */ React2.createElement(ChildrenCountDisplayer, {
50
- item
51
- }) : null)
72
+
73
+ if (labelOverflow === 'truncate') {
74
+ return /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
75
+ value: /*#__PURE__*/jsxs(Fragment, {
76
+ children: [itemLabelText, showChildrenAmount ? _ChildrenCountDisplay3 || (_ChildrenCountDisplay3 = /*#__PURE__*/_jsx(ChildrenCountDisplayer, {
77
+ item: item
78
+ })) : null]
79
+ })
52
80
  });
53
81
  }
54
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, itemLabelText, showChildrenAmount ? /* @__PURE__ */ React2.createElement(ChildrenCountDisplayer, {
55
- item
56
- }) : null);
82
+
83
+ return /*#__PURE__*/jsxs(Fragment, {
84
+ children: [itemLabelText, showChildrenAmount ? _ChildrenCountDisplay4 || (_ChildrenCountDisplay4 = /*#__PURE__*/_jsx(ChildrenCountDisplayer, {
85
+ item: item
86
+ })) : null]
87
+ });
57
88
  }, [item, searchQuery, nameKey, showChildrenAmount, labelOverflow]);
58
- let className = "";
59
- if (labelOverflow === "wrap-all")
60
- className += `${classNameModifierWrapAll} `;
61
- if (labelOverflow === "truncate")
62
- className += `${classNameModifierTruncate} `;
63
- return /* @__PURE__ */ React2.createElement(ItemContent, {
64
- "data-testid": `${treeItemBlockName}-content`
65
- }, /* @__PURE__ */ React2.createElement(ItemValue, {
66
- className
67
- }, Text));
89
+ let className = '';
90
+ if (labelOverflow === 'wrap-all') className += "".concat(classNameModifierWrapAll, " ");
91
+ if (labelOverflow === 'truncate') className += "".concat(classNameModifierTruncate, " ");
92
+ return /*#__PURE__*/_jsx(ItemContent, {
93
+ "data-testid": "".concat(treeItemBlockName, "-content")
94
+ }, void 0, /*#__PURE__*/_jsx(ItemValue, {
95
+ className: className
96
+ }, void 0, Text));
68
97
  }
69
- export {
70
- TreeItemText
71
- };
72
- //# sourceMappingURL=TreeItemText.js.map
98
+
99
+ export { TreeItemText };