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